Can't put Python listing in LaTeX - latex

I'm trying to put a Python listing into a \fbox\parbox but I always get errors.
Here is my code:
\documentclass[12pt]{article}
% Packages
\usepackage[utf8]{inputenc} % support for accents
\usepackage[T1]{fontenc}
\usepackage[francais]{babel} % doc language
\usepackage{lmodern}
\usepackage[a4paper]{geometry} % marges
\usepackage{xcolor} % text color
\usepackage{sectsty} % colorize sections
\usepackage{changepage}
\usepackage{moreverb} % code with indent
\usepackage{listings} % display code with magnification
\usepackage{amssymb}
\usepackage{amsmath} % Text into equation
\usepackage{enumitem} % Continue enumerate numbers
\usepackage{fourier} % Double brackets
% Python listing
\newcommand\pythonstyle{\lstset{
language=Python,
basicstyle=\sffamily,
keywordstyle=\textbf,
commentstyle=\color{blue},
showstringspaces=false,
frame=tb, numbers=left }}
% Python environment
\lstnewenvironment{python}[1][]{
\pythonstyle \lstset{#1} }{}
\begin{document}
\begin{enumerate}
\item On suppose qu'on dispose d'une fonction \texttt{binom(n,k)}, prenant en entrée deux entiers, et qui calcule $\binom{n}{k}$. Ecrire en langage \textsc{Python} une fonction \texttt{bernoulli(n)}, qui prend en entrée un entier naturel, et qui renvoie la liste \texttt{[b\_0, b\_1, ..., b\_n]}. \par
\fbox{\parbox{\linewidth-2\fboxrule-2\fboxsep}{
La relation précédente donne, pour $n \ge 2$ :
\[ \binom{n}{n-1} b_{n-1} = - \sum_{j=0}^{n-2} \binom{n}{j} b_j \]
autrement dit on a la relation de récurrence, pour tout $m \ge 1$ :
\[ b_m = -\frac{1}{m+1} \sum_{j=0}^{m-1} \binom{n}{j} b_j \]
On en déduit le code demandé :
}}
\fbox{\parbox{\linewidth-2\fboxrule-2\fboxsep}{
\begin{python}
def bernoulli(n) :
liste_bj = [1]
for m in range(1,n+1):
b = 0
for j in range(m):
b -= binom(m+1,j) * liste_bj[j]
b /= m+1
liste_bj.append(b)
return liste_bj
\end{python}
}} %err1
\end{enumerate}
I got the following errors:
On documentclass : Emergency stop, Fatal error occured, no output PDF produced!
On err1 : Argument of \lst#next has an extra }. Paragraph ended before \lst#next was complete. Extra }, or forgotten \endgroup
On \end{enumerate} : \begin{python} ended by \end{enumerate}
On \end{document} : \begin{enumerate} ended by \end{document}. You can't use '\end' in internal vertical mode. Missing { inserted
I tried to erase the "python listing" and "python environment" on the preamble and replace \begin{python} with \begin{listings} (same with \end) to reset my LaTeX project with the standard presentation of code, but I still get the same errors. So it seems that LaTeX has trouble to read that my listing closure command is put before closing the enumerate one. Maybe it's because I put the listing into a \fbox\parbox?
The \fbox\parbox works well with text and equations in it, so the issue does not come from there.

You must not use fragile content, such as listings, as argument of other macros.
Anyway, the fbox\parbox is really superfluous - lstings has a frame option for this:
\documentclass[12pt]{article}
% Packages
\usepackage[utf8]{inputenc} % support for accents
\usepackage[T1]{fontenc}
\usepackage[french]{babel} % doc language
\usepackage{lmodern}
\usepackage[a4paper]{geometry} % marges
\usepackage{xcolor} % text color
\usepackage{sectsty} % colorize sections
\usepackage{changepage}
\usepackage{moreverb} % code with indent
\usepackage{listings} % display code with magnification
\usepackage{amssymb}
\usepackage{amsmath} % Text into equation
\usepackage{enumitem} % Continue enumerate numbers
\usepackage{fourier} % Double brackets
% Python listing
\newcommand\pythonstyle{\lstset{
language=Python,
basicstyle=\sffamily,
keywordstyle=\textbf,
commentstyle=\color{blue},
showstringspaces=false,
frame=tb, numbers=left }}
% Python environment
\lstnewenvironment{python}[1][]{
\pythonstyle \lstset{#1} }{}
\begin{document}
\begin{enumerate}
\item On suppose qu'on dispose d'une fonction \texttt{binom(n,k)}, prenant en entrée deux entiers, et qui calcule $\binom{n}{k}$. Ecrire en langage \textsc{Python} une fonction \texttt{bernoulli(n)}, qui prend en entrée un entier naturel, et qui renvoie la liste \texttt{[b\_0, b\_1, ..., b\_n]}. \par
\fbox{\parbox{\linewidth-2\fboxrule-2\fboxsep}{
La relation précédente donne, pour $n \ge 2$ :
\[ \binom{n}{n-1} b_{n-1} = - \sum_{j=0}^{n-2} \binom{n}{j} b_j \]
autrement dit on a la relation de récurrence, pour tout $m \ge 1$ :
\[ b_m = -\frac{1}{m+1} \sum_{j=0}^{m-1} \binom{n}{j} b_j \]
On en déduit le code demandé :
}}
% \fbox{\parbox{\linewidth-2\fboxrule-2\fboxsep}{
\begin{python}[frame=single,linewidth=1.035\linewidth]
def bernoulli(n) :
liste_bj = [1]
for m in range(1,n+1):
b = 0
for j in range(m):
b -= binom(m+1,j) * liste_bj[j]
b /= m+1
liste_bj.append(b)
return liste_bj
\end{python}
% }} %err1
\end{enumerate}
\end{document}
(and \end{document} was obviously missing)

Related

LaTeX with overleaf editor - adding another line of text without it overlapping

I want to add another line of italic text below 'Surbiton high school'. When I add another line it just overlaps on top of what is there, instead of underneath my A-level description.
I am very new to all of this and am using a template to create my CV. Any help much appreciated!
I have included a screenshot of the CV
%-------------------------
% Resume in Latex
% Author : Jake Gutierrez
% Based off of: https://github.com/sb2nov/resume
% License : MIT
%------------------------
\documentclass[letterpaper,11pt]{article}
\usepackage{latexsym}
\usepackage[empty]{fullpage}
\usepackage{titlesec}
\usepackage{marvosym}
\usepackage[usenames,dvipsnames]{color}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage[hidelinks]{hyperref}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{contour}
\usepackage{ulem}
\input{glyphtounicode}
%----------FONT OPTIONS----------
% sans-serif
% \usepackage[sfdefault]{FiraSans}
% \usepackage[sfdefault]{roboto}
% \usepackage[sfdefault]{noto-sans}
% \usepackage[default]{sourcesanspro}
% serif
% \usepackage{CormorantGaramond}
% \usepackage{charter}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
% Adjust margins
\addtolength{\oddsidemargin}{-0.5in}
\addtolength{\evensidemargin}{-0.5in}
\addtolength{\textwidth}{1in}
\addtolength{\topmargin}{-.5in}
\addtolength{\textheight}{1.0in}
\urlstyle{same}
\raggedbottom
\raggedright
\setlength{\tabcolsep}{0in}
% Sections formatting
\titleformat{\section}{
\vspace{-4pt}\scshape\raggedright\large
}{}{0em}{}[\color{black}\titlerule \vspace{-5pt}]
% Ensure that generate pdf is machine readable/ATS parsable
\pdfgentounicode=1
%-------------------------
% Custom commands
\newcommand{\resumeItem}[1]{
\item\small{
{#1 \vspace{-2pt}}
}
}
\newcommand{\resumeSubheading}[4]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\textbf{#1} & #2 \\
\textit{\small#3} & \textit{\small #4} \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeSubSubheading}[2]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\text{#1} & #2 \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeProjectHeading}[2]{
\item
\begin{tabular*}{0.97\textwidth}{l#{\extracolsep{\fill}}r}
\small#1 & #2 \\
\end{tabular*}\vspace{-7pt}
}
\renewcommand{\ULdepth}{3pt}
\contourlength{0.8pt}
\newcommand{\myuline}[1]{%
\uline{\phantom{#1}}%
\llap{\contour{white}{#1}}%
}
\newcommand{\resumeSubItem}[1]{\resumeItem{#1}\vspace{-4pt}}
\renewcommand\labelitemii{$\vcenter{\hbox{\tiny$\bullet$}}$}
\newcommand{\resumeSubHeadingListStart}{\begin{itemize}[leftmargin=0.15in, label={}]}
\newcommand{\resumeSubHeadingListEnd}{\end{itemize}}
\newcommand{\resumeItemListStart}{\begin{itemize}}
\newcommand{\resumeItemListEnd}{\end{itemize}\vspace{-5pt}}
%-------------------------------------------
%%%%%% RESUME STARTS HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%-----------EDUCATION-----------
\section{Education}
\resumeSubHeadingListStart
\resumeSubheading
{The University of Sussex}{Brighton, UK}
{Bachelor of Science in Economics - First Class Honours}{September 2018 -- June 2021}
\begin{itemize}
\item podcast
\end{itemize}
\resumeSubheading
{Surbiton High School}{London, UK}
{A-level Qualifications in Economics A, Mathematics A, Physics C}{September 2014 -- June 2016}
\resumeSubHeadingListEnd
Leave an empty line to start a new paragraph and then add whatever text you want (and \end{document} is missing again ...):
%-------------------------
% Resume in Latex
% Author : Jake Gutierrez
% Based off of: https://github.com/sb2nov/resume
% License : MIT
%------------------------
\documentclass[letterpaper,11pt]{article}
\usepackage{latexsym}
\usepackage[empty]{fullpage}
\usepackage{titlesec}
\usepackage{marvosym}
\usepackage[usenames,dvipsnames]{color}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage[hidelinks]{hyperref}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{contour}
\usepackage{ulem}
\input{glyphtounicode}
%----------FONT OPTIONS----------
% sans-serif
% \usepackage[sfdefault]{FiraSans}
% \usepackage[sfdefault]{roboto}
% \usepackage[sfdefault]{noto-sans}
% \usepackage[default]{sourcesanspro}
% serif
% \usepackage{CormorantGaramond}
% \usepackage{charter}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
% Adjust margins
\addtolength{\oddsidemargin}{-0.5in}
\addtolength{\evensidemargin}{-0.5in}
\addtolength{\textwidth}{1in}
\addtolength{\topmargin}{-.5in}
\addtolength{\textheight}{1.0in}
\urlstyle{same}
\raggedbottom
\raggedright
\setlength{\tabcolsep}{0in}
% Sections formatting
\titleformat{\section}{
\vspace{-4pt}\scshape\raggedright\large
}{}{0em}{}[\color{black}\titlerule \vspace{-5pt}]
% Ensure that generate pdf is machine readable/ATS parsable
\pdfgentounicode=1
%-------------------------
% Custom commands
\newcommand{\resumeItem}[1]{
\item\small{
{#1 \vspace{-2pt}}
}
}
\newcommand{\resumeSubheading}[4]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\textbf{#1} & #2 \\
\textit{\small#3} & \textit{\small #4} \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeSubSubheading}[2]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\text{#1} & #2 \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeProjectHeading}[2]{
\item
\begin{tabular*}{0.97\textwidth}{l#{\extracolsep{\fill}}r}
\small#1 & #2 \\
\end{tabular*}\vspace{-7pt}
}
\renewcommand{\ULdepth}{3pt}
\contourlength{0.8pt}
\newcommand{\myuline}[1]{%
\uline{\phantom{#1}}%
\llap{\contour{white}{#1}}%
}
\newcommand{\resumeSubItem}[1]{\resumeItem{#1}\vspace{-4pt}}
\renewcommand\labelitemii{$\vcenter{\hbox{\tiny$\bullet$}}$}
\newcommand{\resumeSubHeadingListStart}{\begin{itemize}[leftmargin=0.15in, label={}]}
\newcommand{\resumeSubHeadingListEnd}{\end{itemize}}
\newcommand{\resumeItemListStart}{\begin{itemize}}
\newcommand{\resumeItemListEnd}{\end{itemize}\vspace{-5pt}}
%-------------------------------------------
%%%%%% RESUME STARTS HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%-----------EDUCATION-----------
\section{Education}
\resumeSubHeadingListStart
\resumeSubheading
{The University of Sussex}{Brighton, UK}
{Bachelor of Science in Economics - First Class Honours}{September 2018 -- June 2021}
\begin{itemize}
\item podcast
\end{itemize}
\resumeSubheading
{Surbiton High School}{London, UK}
{A-level Qualifications in Economics A, Mathematics A, Physics C}{September 2014 -- June 2016}
\textit{a new line}
\resumeSubHeadingListEnd
\end{document}

how to display \thesubsection by a letter

I want to have in each frame a title like this : 1 - "section name" : a) "subsection name"
I have done something like that : \thesection \, - \secname \,: \thesubsection ) \subsecname
but it displays 1 - "section name" : 1) "subsection name"
How can I do ?
my code :
%...
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents
\end{frame}
\section{Analyse de l'article}
\subsection{Principes fondamentales}
\begin{frame}{\thesection \, - \secname \,: • \subsecname}
blabla
\end{frame}
\section{Création de modèles prédictifs}
\subsection{Mise en forme des données}
\begin{frame}{\thesection \, - \secname \,: • \subsecname}
\end{frame}
%---------------------------------------------------------
\end{document}
You can use \alph{<counter name>} to show the value of the counter as lowercase letters:
\documentclass{beamer}
\newcommand{\mytitle}{
\thesection \, - \secname \,:
\alph{subsection}) \subsecname
}
\begin{document}
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents
\end{frame}
\section{Analyse de l'article}
\subsection{Principes fondamentales}
\begin{frame}
\frametitle{\mytitle}
blabla
\end{frame}
%\section{Création de modèles prédictifs}
\subsection{Mise en forme des données}
\begin{frame}
\frametitle{\mytitle}
blabla
\end{frame}
\end{document}

Losing typical Computer Modern typical curved x glyphe

How to avoid losing typical Computer Modern typical curved "x" glyphe in math modes, when switching for \sfdefault for the whole document ?
%%% not canonical minimal.tex sample %%%
\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage{ucs}
%\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
\usepackage[french]{babel}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[italic]{mathastext}
\usepackage{siunitx}
\sisetup{output-decimal-marker = {,}}
\begin{document}
Je compose avec Babel pour la langue française, avec deux contraintes: police sans empattement, et véritable virgule française conforme aux usages pour les nombres à virgule.
Voici un document minimal, où je perds le $x$ arrondi habituel en Computer Modern. Je vérifie ce que donne la macro \verb+\num{}+ avec \num{5.2} et $\num{5.2}$ et \SI{5.2}{\kilo\metre\squared}.
$$
\int_{a}^{b} f\!\left( x \right) dx = \num{5.2} \quad \text{où} \quad AB = 5.2
$$
Le $x$ ne me convient pas (confusion pour certains élèves).
\end{document}
Based on #UlrikeFischer's solution at https://chat.stackexchange.com/transcript/message/57560730#57560730 you can use the following code to get the curly x back:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{siunitx}
\sisetup{output-decimal-marker = {,}}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[italic]{mathastext}
%
\DeclareSymbolFont{myletters}{T1}{cmr}{m}{it}
\AtBeginDocument{\DeclareMathSymbol{x}\mathalpha{myletters}{"78}}
\MTmathstandardletters
\begin{document}
Je compose avec Babel pour la langue française, avec deux contraintes: police sans empattement, et véritable virgule française conforme aux usages pour les nombres à virgule.
Voici un document minimal, où je perds le $x$ arrondi habituel en Computer Modern. Je vérifie ce que donne la macro \verb+\num{}+ avec \num{5.2} et $\num{5.2}$ et \SI{5.2}{\kilo\metre\squared}.
$$
\int_{a}^{b} f\!\left( x \right) dx = \num{5.2} \quad \text{où} \quad AB = 5.2
$$
Le $x$ ne me convient pas (confusion pour certains élèves).
\end{document}

How do you remove white space between title and table?

I tried asking this somewhere else as well, but I am having trouble removing the white space between the title of my table and the actual table. This doesn't happen when in my regular rmarkdown article, but when I knit to beamer for my presentation it produces these bizarre white spaces. Anyone know why?
mean.party.class <- dat3 %>%
group_by(party2, class2) %>%
filter (party2 !="Indep" & class != "IDK")%>%
summarise_at(vars(DL, DU, RL, RU, L, U, D, R), funs(mean(., na.rm=TRUE)))
knitr::kable(mean.party.class, col.names=c("Party ID", "Class", "DL", "DU", "RL", "RU", "L", "U", "D" , "R"), digits=2, caption = "Mean Trust Per Group (Party and Social Class Identity)", "latex", booktabs = T) %>%
kable_styling( full_width = F, position = "left", latex_options = "scale_down", bootstrap_options = c("striped", "hover")) %>% footnote(
general = c("1. D= Democrat, R=Republican, L=Lower Class, U = Upper Class; ", "2. Independents dropped")) %>% row_spec(0,bold=TRUE)
Here is an example
---
title: "Example"
author: "Its me"
date: "6/12/2020"
always_allow_html: true
header-includes:
- \usepackage{booktabs}
- \usepackage{longtable}
- \usepackage{tabu}
- \usepackage{threeparttable}
- \usepackage{adjustbox}
- \usepackage{caption} \captionsetup[table]{skip=0pt}
- \usepackage[font=small,skip=0pt]{caption}
- \usepackage{tikz}
- \usepackage{float}
- \usetikzlibrary{arrows,shapes,positioning}
output:
beamer_presentation:
theme: "Berkeley"
colortheme: "dolphin"
fonttheme: "structurebold"
slide_level: 2
#incremental: true
---
```{r}
setwd("~/Google Drive/UC Davis /R stuff")
```
```{r, include=FALSE}
library(rticles)
library(kableExtra)
library(knitr)
library(plyr)
library(dplyr)
library(gdata)
library(ggplot2)
library(MASS)
library(corrplot)
library(haven)
library(factoextra)
library(ggplot2)
library(ggrepel)
library(viridis)
library(lattice)
library(optiscale)
library(acepack)
library(psych)
library(smacof)
library(MCMCpack)
library(basicspace)
library(boot)
library(pscl)
library(wnominate)
library(RColorBrewer)
library(sjPlot)
```
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r, include= FALSE}
#load cars
data("mtcars")
head(mtcars, 2)
```
```{r, include= FALSE}
mean.mpg <- mtcars %>%
summarise_at(vars(mpg), funs(mean(., na.rm=TRUE)))
```
## there it is
```{r}
knitr::kable(mean.mpg, col.names=c("mpg"), digits=2, caption = "This is a table", "latex", booktabs = T, escape=F) %>%
kable_styling(full_width = T, position = "left", latex_options = "scale_down", bootstrap_options = c("striped", "hover")) %>% footnote(
general = c("1. test 1", "2. test 2"))%>%
row_spec(0,bold=TRUE)
```
If you add keep_tex: true to your header you can edit the resulting .tex file to remove the multiple causes of the additional space:
remove the unnecessary and often harmful \resizebox{\linewidth}{!}{...} around the table
remove the caption package (which is unnecessarily loaded multiple times)
remove the parskip package
\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[ignorenonframetext,]{beamer}
\usepackage{pgfpages}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbolsempty
% Prevent slide breaks in the middle of a paragraph:
\widowpenalties 1 10000
\raggedbottom
\setbeamertemplate{part page}{
\centering
\begin{beamercolorbox}[sep=16pt,center]{part title}
\usebeamerfont{part title}\insertpart\par
\end{beamercolorbox}
}
\setbeamertemplate{section page}{
\centering
\begin{beamercolorbox}[sep=12pt,center]{part title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}
\setbeamertemplate{subsection page}{
\centering
\begin{beamercolorbox}[sep=8pt,center]{part title}
\usebeamerfont{subsection title}\insertsubsection\par
\end{beamercolorbox}
}
\AtBeginPart{
\frame{\partpage}
}
\AtBeginSection{
\ifbibliography
\else
\frame{\sectionpage}
\fi
}
\AtBeginSubsection{
\frame{\subsectionpage}
}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provides euro and other symbols
\else % if luatex or xelatex
\usepackage{unicode-math}
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
\usetheme[]{Berkeley}
\usecolortheme{dolphin}
\usefonttheme{structurebold}
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\IfFileExists{parskip.sty}{%
%\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\usepackage{hyperref}
\hypersetup{
pdftitle={Example},
pdfauthor={Its me},
pdfborder={0 0 0},
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
\newif\ifbibliography
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% set default figure placement to htbp
\makeatletter
\def\fps#figure{htbp}
\makeatother
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{adjustbox}
%\usepackage{caption}
%\captionsetup[table]{skip=0pt}
%\usepackage[font=small,skip=0pt]{caption}
\usepackage{tikz}
\usepackage{float}
\usetikzlibrary{arrows,shapes,positioning}
\title{Example}
\author{Its me}
\date{6/12/2020}
\begin{document}
\frame{\titlepage}
\begin{frame}{there it is}
\protect\hypertarget{there-it-is}{}
\begin{table}
\caption{\label{tab:unnamed-chunk-4}This is a table}
%\resizebox{\linewidth}{!}{
\begin{tabu} to \linewidth {>{\raggedleft}X}
\toprule
\textbf{mpg}\\
\midrule
20.09\\
\bottomrule
\multicolumn{1}{l}{\textit{Note: }}\\
\multicolumn{1}{l}{1. test 1}\\
\multicolumn{1}{l}{2. test 2}\\
\end{tabu}
%}
\end{table}
\end{frame}
\end{document}
(I would stay away from tabu and use a normal table instead)

how to put the chapter name on the top of each pages?

I begin with latex and I have this .tex document and I'd like to put on the top of each future pages the number and name of what chapter I am into.
\documentclass[a4paper]{report}
% Options possibles : 10pt, 11pt, 12pt (taille de la fonte)
% oneside, twoside (recto simple, recto-verso)
% draft, final (stade de développement)
\usepackage[utf8]{inputenc} % LaTeX, comprends les accents !
\usepackage[T1]{fontenc} % Police contenant les caractères français
\usepackage[francais]{babel} % Placez ici une liste de langues, la
% dernière étant la langue principale
\usepackage{amsthm} %Pour faire des remarques sur des théorème en mathématique
\usepackage[lenny]{fncychap}
\usepackage[a4paper]{geometry}% Réduire les marges
\usepackage{hyperref}
\usepackage{array,multirow,makecell}
\usepackage{diagbox}
\usepackage{pict2e}
\setcellgapes{1pt}
\makegapedcells
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash }b{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash }b{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash }b{#1}}
% \pagestyle{headings} % Pour mettre des entêtes avec les titres
% des sections en haut de page
\title{\underline{\textbf{Rapport TER}}} % Les paramètres du titre : titre, auteur, date
\title{%
{\textbf{Rapport TER}} \\
\large Chip-firing games}
\bigbreak
\bigbreak
\author{Sébastien Gouverneur}
% \date{} % La date n'est pas requise (la date du
% jour de compilation est utilisée en son
% absence)
\sloppy % Ne pas faire déborder les lignes dans la marge
\begin{document}
\maketitle % Faire un titre utilisant les données
% passées à \title, \author et \date
\newpage
% \renewcommand{\contentsname}{Sommaire} %Modifie le nom par default de la table des matières
\tableofcontents % Table des matières
\newpage
\chapter{Introduction}
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\newpage
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
% \subsubsection{Titre} % Encore plus petite
% \paragraph{Titre} % Toutes petites sections (le nom \paragraph
% n'est pas très bien choisi)
% \subparagraph{Titre} % La dernière
% \appendix % Commençons les annexes
% \section{Titre} % Annexe A
% \section{Titre} % Annexe B
% \listoffigures % Table des figures
% \listoftables % Liste des tableaux
\end{document}
For exemple the page 4/4 should begin with something like
"Chapter 1. Introduction"
and for each next pages I'll add to my report, this notation will appear until I add another chapter and after that It will be for each next pages
"Chapter2. blabla"
Is it possible to do something like that and what package / commande should I use to do It? Thanks by advance.
Considering that you are using documentclass report, which is oneside by default, you may add \usepackage{fancyhdr} in your preamble and then, just after \begin{document}, you may add:
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{#1}}
\fancyhead[R]{}
\fancyhead[L]{\chaptername\ \thechapter\ --\ \leftmark}
This is only a rough sketch, not including page numbering (that may stay in the header too) and fine styling of the header itself.

Resources