1

I don't know why I don't have a nice tableau in beamer.

\documentclass[10pt]{beamer}
\usetheme{Boadilla}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,booktabs,counter,diagbox,siunitx,varwidth}
\title{Phénomènes aléatoires}

\begin{document}
\begin{frame}
\begin{exampleblock}{Fréquences conditionnelles en colonne}

La fréquence conditionnelle $f_{R}(P)=0,56$.

Cela signifie que, parmi la sous-population de référence des élèves refusés (R)  (\textbf{c'est la condition}) environ 56 \% viennent des séries professionnelles.

\begin{center}

\begin{tblr}{
colspec={Q[3cm,c] Q[2.5cm,c] },
rowspec={Q[m] Q[m] Q[m] Q[m] },
 cell{1}{2}={gray!10} , cell{5}{1}={red!10}
}
\SetHline{2-2}{black,.5pt}
\SetVline{2-5}{black,.5pt}  
 &  \SetVline{1-5}{black,.5pt} Refusé R  &  \SetVline{1-5}{black,.5pt}  
\\
\SetHline{1-4}{black,.5pt}  

Série générale G & $\dfrac{14741}{65126}=0,23$
\\
\SetHline{1-4}{black,.5pt}  

Série pro P &  $\dfrac{13687}{65126}=0,21$ 
\\
\SetHline{1-4}{black,.5pt}  

Série techno P &  $\dfrac{36698}{65126}=0,56$ 
\\
\SetHline{1-4}{black,.5pt}  

Total & 1 
\\
\SetHline{1-4}{black,.5pt}

\end{tblr}
\end{center}



 
\end{exampleblock}


\end{frame}

\end{document}

The result:

enter image description here

7
  • 3
    Please extend your code fragment to complete small document, which we can compile as it is. So far it contain some errors as undefined \ier command (if I insert it in some fresh beamer fragment. BTW, your table code is a bit strange ...
    – Zarko
    Commented Aug 19, 2023 at 9:38
  • 1
    Showed table image is not close to your code content ... Please show us what you get from compilation of your code.
    – Zarko
    Commented Aug 19, 2023 at 9:56
  • 3
    I’m voting to close this question because code can't compile; see comments
    – MS-SPO
    Commented Aug 19, 2023 at 12:34
  • Dear close voters: the OP has edited their question in the mean time. Now the code is compileable and reproduces the problem shown in image. Commented Aug 19, 2023 at 17:11
  • @samcarter_is_at_topanswers.xyz, yes it is, but after receive my answer and after my deleting his answer ... Before it, he not react to comments nor provide any excuse or thankfulness for it. So for me, his edit is to late ....
    – Zarko
    Commented Aug 19, 2023 at 17:45

3 Answers 3

0

If you use \SetHline{1-4}{black,.5pt} you tell tabularray to draw your lines over four columns, which is wider than the two columns your table uses.

You will get a nice looking table if you use \SetHline{1-2}{black,.5pt}:

\documentclass[10pt]{beamer}
\usetheme{Boadilla}
%\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
%\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,booktabs,counter,diagbox,siunitx,varwidth}
\title{Phénomènes aléatoires}

\begin{document}
\begin{frame}
\begin{exampleblock}{Fréquences conditionnelles en colonne}

La fréquence conditionnelle $f_{R}(P)=0,56$.

Cela signifie que, parmi la sous-population de référence des élèves refusés (R)  (\textbf{c'est la condition}) environ 56 \% viennent des séries professionnelles.

\begin{center}

\begin{tblr}{
colspec={Q[3cm,c] Q[2.5cm,c] },
rowspec={Q[m] Q[m] Q[m] Q[m] },
 cell{1}{2}={gray!10} , cell{5}{1}={red!10}
}
\SetHline{2-2}{black,.5pt}
\SetVline{2-5}{black,.5pt}  
 &  \SetVline{1-5}{black,.5pt} Refusé R  &  \SetVline{1-5}{black,.5pt}  
\\
\SetHline{1-2}{black,.5pt}  

Série générale G & $\dfrac{14741}{65126}=0,23$
\\
\SetHline{1-2}{black,.5pt}  

Série pro P &  $\dfrac{13687}{65126}=0,21$ 
\\
\SetHline{1-2}{black,.5pt}  

Série techno P &  $\dfrac{36698}{65126}=0,56$ 
\\
\SetHline{1-2}{black,.5pt}  

Total & 1 
\\
\SetHline{1-2}{black,.5pt}

\end{tblr}
\end{center}
\end{exampleblock}
\end{frame}

\end{document}

enter image description here

Unrelated to your question: You don't need to load all the ams* packages, beamer already loads them for you.

2
1

For information, here is a way (rather easy) to create that tabular with {NiceTabular} of nicematrix. You need several compilations.

\documentclass[10pt]{beamer}
\usetheme{Boadilla}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[locale=FR]{siunitx}

\usepackage{nicematrix}

\title{Phénomènes aléatoires}

\begin{document}
\begin{frame}
\begin{exampleblock}{Fréquences conditionnelles en colonne}

La fréquence conditionnelle $f_{R}(P)=\num{0,56}$.

Cela signifie que, parmi la sous-population de référence des élèves refusés (R)  (\textbf{c'est la condition}) environ 56 \% viennent des séries professionnelles.

\begin{center}

\begin{NiceTabular}{cc}[hvlines,corners,cell-space-limits=3pt]
\CodeBefore
  \cellcolor{red!10}{5-1}
  \cellcolor{gray!10}{1-2}
\Body
                   &  Refusé R \\
  Série générale G & $\dfrac{14741}{65126}=\num{0,23}$ \\
  Série pro P      & $\dfrac{13687}{65126}=\num{0,21}$ \\
  Série techno P   & $\dfrac{36698}{65126}=\num{0,56}$ \\
  Total            & 1 
\end{NiceTabular}

\end{center}
 
\end{exampleblock}

\end{frame}

\end{document}

You need several compilations.

Output of the above code

3
  • In order to have correct spaces around the comma used as decimal separator (as done in France), I have use num of siunitx with the key locale = FR. Commented Aug 19, 2023 at 15:11
  • 1
    As an alternative to get correct spacing around the comma, one could also use the icomma package Commented Aug 19, 2023 at 15:17
  • thx a lot :) again :) Commented Aug 19, 2023 at 15:17
0

Showed fragment od code and image of table are not related, so it is unclear what is your problem:

  • Are you after for code which produce showed image, or
  • you looking for fix of provided code. So far I focused on code fragment. -
  • Unfortunately it contains undefined commands \ier{} and \ieme so I not used them in MWEs' below:
\documentclass{beamer}
\usepackage{tabularray}
%   \UseTblrLibrary{amsmath,booktabs,counter,diagbox,siunitx,varwidth} % not used in this MWE

\begin{document}
\begin{frame}
\footnotesize
\frametitle{Example of \texttt{tabularray} table}
    \begin{tblr}{hline{1} = {2-Z}{solid}, hline{2-Z}={1-Z}{solid},
                 vline{1}   = {2-Z}{solid}, vline{2-Z}={1-Z}{solid},
                 colspec = {X[3,l] * {5}{X[c]} },
                 colsep  = {4pt},
                 rows    = {m}
                 }
    &   \SetCell[c=5]{c}    Participation aux législatives
        &   &   &   &   \\
Participation aux législatives
    &   A tous les tours
        &   Au 1  tour
            &   Au 2 tour
                &   Aucun
                    &   Total               \\
A tous les tours
    & 0,65  & 2,84  &       & 3,10  &       \\
Au 1{} tour
    &  0,13 & 0,29  & 0,26  & 0,08  &       \\
Au 2 tour
    &       & 1,13  & 1,25  & 0,60  & 0,36  \\
Total
    &       & 4,26  &       & 3,78  & 1,90  \\
    \end{tblr}
\end{frame}
\end{document}

enter image description here

  • Is this close what you after?

  • If not, please, consider my comments below your question and provide MWE (Minimal Working Example), a small but complete document (similar to my above MWE) with correct code of the desired table.

Addendum 1:
With use of the diagbox library as is seems in the code fragment but by far shorter and correct code:

\documentclass{beamer}
\usepackage{tabularray}
\UseTblrLibrary{diagbox} 

\begin{document}
\begin{frame}
\frametitle{Example of \texttt{tabularray} table}
\footnotesize

    \begin{tblr}{hlines, vlines,
                 colspec = {Q[l, wd=33mm] * {5}{X[c]} },
                 colsep  = {4pt},
                 cell{1}{1} = {font=\tiny},
                 rows    = {m}
                 }
\diagbox{\parbox{15mm}{\raggedright Participation aux législatives}}
        {\parbox{15mm}{\raggedright Participation aux législatives}}
    &   A tous les tours
        &   Au 1  tour
            &   Au 2 tour
                &   Aucun
                    &   Total               \\
A tous les tours
    & 0,65  & 2,84  &       & 3,10  &       \\
Au 1{} tour
    &  0,13 & 0,29  & 0,26  & 0,08  &       \\
Au 2 tour
    &       & 1,13  & 1,25  & 0,60  & 0,36  \\
Total
    &       & 4,26  &       & 3,78  & 1,90  \\
    \end{tblr}
\end{frame}
\end{document}

enter image description here

Addendum 2:

  • Apparently the first version of your question was (a big confusion and consequently misleading what you after (therefore -1 for it from me) and my effort to help you was just waste of my time.

  • Anyway both first two examples shows how can be with correctly and more concise way by strict dividing formatting of table from its contents, avoided your problems (whatever they are).

  • Your new table's code can be written on much more concise and correctly way. Based on codes from my previous examples, it can be:

\documentclass[10pt]{beamer}
\usetheme{Boadilla}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}

\usepackage{tabularray}
\UseTblrLibrary{amsmath}


\begin{document}
\begin{frame}
\frametitle{Phénomènes aléatoires}
    \begin{exampleblock}{Fréquences conditionnelles en colonne}
La fréquence conditionnelle $f_{R}(P)=0,56$.

Cela signifie que, parmi la sous-population de référence des élèves refusés (R)  (\textbf{c'est la condition}) environ 56 \% viennent des séries professionnelles.

\begin{center}
    \begin{tblr}{hline{1} = {2}{solid},     hline{2-Z}={1-Z}{solid},
                 vline{1} = {2-Z}{solid},   vline{2-Z}={1-Z}{solid},
                 colspec={Q[3cm,c] Q[2.5cm,c, mode=dmath] },
                 cell{1}{2}={bg=gray!10},
                 cell{Z}{1}={bg=red!10},
                 row{1} = {mode=text}
                }
% table body
                    &   Refusé R        \\
Série générale G    &   \dfrac{14741}{65126}=0,23   \\
Série pro P         &   \dfrac{13687}{65126}=0,21   \\
Série techno P      &   \dfrac{36698}{65126}=0,56   \\
Total               & 1                             \\
    \end{tblr}
\end{center}
\end{exampleblock}
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .