2

I am getting this on beamer using tabular:

enter image description here

As you can see, the matrices are too close to the middle line, and I would like to separate these matrices a little from it. Adding \\ \\ \hline \\ between the last cell of the first row and the first cell of the second row yields

enter image description here

I do consider this to be be too much space between the rows and the middle line. If I try to add \renewcommand{\arraystretch}{1.5} before the tabular environment (as it is recommended here), it yields

enter image description here

and suddenly all matrices stretch big as well. I think this happens because the variable \arraystretch applies globally to both tabular and pmatrix. With the \renewcommand{\arraystretch}{1.5} before the \begin{tabular}, I tried to reredefine this variable back to 1 before each \begin{pmatrix} and it neither worked.

Here's a MWE, with the \renewcommand{\arraystretch}{1.5} before the tabular environment, which gives the last image:

\documentclass[spanish]{beamer}
\usepackage[utf8]{inputenc}
\usetheme{Copenhagen}
\usecolortheme{default}
\usepackage[spanish]{babel}
\setbeamertemplate{headline}{} % This deletes the index on top of each slide
\usefonttheme{default}

\newcommand\wider[2][3em]{% \makebox[\linewidth][c]{% \begin{minipage}{\dimexpr\textwidth+#1\relax} \raggedright#2 \end{minipage}% }% }

\begin{document}

\begin{frame} \wider[3em]{\small \bgroup\setlength{\tabcolsep}{5pt} \renewcommand{\arraystretch}{2} \begin{tabular}{c|lll} \begin{minipage}{35pt} \centering base de $\mathsf{su}(2)$ \end{minipage} & $E_{1}=\frac{1}{2}\begin{pmatrix} i & 0 \ 0 & -i \end{pmatrix}$ , & $E_{2}=\frac{1}{2}\begin{pmatrix} 0 & i \ i & 0 \end{pmatrix}$ , & $E_{3}=\frac{1}{2}\begin{pmatrix} 0 & -1 \ 1 & 0 \end{pmatrix}.$ \\hline \begin{minipage}{35pt} \centering base de $\mathsf{so}(3)$ \end{minipage} & $F_1=\begin{pmatrix} 0&0&0\ 0&0&-1\ 0&1&0 \end{pmatrix},$ & $F_2=\begin{pmatrix} 0&0&1\ 0&0&0\ -1&0&0 \end{pmatrix},$ & $F_3=\begin{pmatrix} 0&-1&0\ 1&0&0\ 0&0&0 \end{pmatrix}.$ \end{tabular} \egroup } \end{frame}

\end{document}

where I am using the \wider macro defined here to decrease lateral margins on the slide.

I would like to get then something like in the second image but with less space between the rows and the middle line. Any help will be appreciated :)

3 Answers3

2

You may liked:

enter image description here

It is produced with MWE, which use the tabularray package and \small font size in matrices. Code is simple and quite short:

\documentclass[spanish]{beamer}
\usetheme{Copenhagen}
\usepackage[spanish]{babel}
\usepackage{array,tabularray}
\NewColumnType{C}{>{\small $}X<{$}}

\begin{document}

\begin{frame} \setlength\arraycolsep{2pt} \begin{tblr}{colspec={Q[c,m,4em] | C C C }, colsep=3pt, rowsep=3pt, } base de $su(2)$ & E_{1}=\frac{1}{2} \begin{pmatrix} i & 0 \ 0 & -i \end{pmatrix}, & E_{2}=\frac{1}{2} \begin{pmatrix} 0 & i \ i & 0 \end{pmatrix}, & E_{3}=\frac{1}{2} \begin{pmatrix} 0 & -1 \ 1 & 0 \end{pmatrix}. \
\hline base de $so(3)$ & F_1=\begin{pmatrix} 0&0&0\ 0&0&-1\ 0&1&0 \end{pmatrix}, & F_2=\begin{pmatrix} 0&0&1\ 0&0&0\ -1&0&0 \end{pmatrix}, & F_3=\begin{pmatrix} 0&-1&0\ 1&0&0\ 0&0&0 \end{pmatrix}. \end{tblr} \end{frame}

\end{document}

Zarko
  • 296,517
1

With {NiceTabular} of nicematrix and its key cell-space-limits.

\documentclass[spanish]{beamer}
\usetheme{Copenhagen}
\usecolortheme{default}
\usepackage[spanish]{babel}
\setbeamertemplate{headline}{}
\usefonttheme{default}
\usepackage{nicematrix}

\newcommand\wider[2][3em]{% \makebox[\linewidth][c]{% \begin{minipage}{\dimexpr\textwidth+#1\relax} \raggedright#2 \end{minipage}% }% }

\begin{document}

\begin{frame} \wider[3em]{\small \bgroup\setlength{\tabcolsep}{5pt} \renewcommand{\arraystretch}{2} \begin{NiceTabular}{c|lll}[cell-space-limits=5pt] \begin{minipage}{35pt} \centering base de $\mathsf{su}(2)$ \end{minipage} & $E_{1}=\frac{1}{2}\begin{pmatrix} i & 0 \ 0 & -i \end{pmatrix}$ , & $E_{2}=\frac{1}{2}\begin{pmatrix} 0 & i \ i & 0 \end{pmatrix}$ , & $E_{3}=\frac{1}{2}\begin{pmatrix} 0 & -1 \ 1 & 0 \end{pmatrix}.$ \\hline \begin{minipage}{35pt} \centering base de $\mathsf{so}(3)$ \end{minipage} & $F_1=\begin{pmatrix} 0&0&0\ 0&0&-1\ 0&1&0 \end{pmatrix},$ & $F_2=\begin{pmatrix} 0&0&1\ 0&0&0\ -1&0&0 \end{pmatrix},$ & $F_3=\begin{pmatrix} 0&-1&0\ 1&0&0\ 0&0&0 \end{pmatrix}.$ \end{NiceTabular} \egroup } \end{frame}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

F. Pantigny
  • 40,250
0

Okey, I have just found a solution with the package cellspace. Since I cannot find an analogous solution on other questions here on TSE, I am posting the answer.

To add space between a the content of a cell and a \hline, the cellspace package requires you to add S before the c, l or c position parameter of tabular (as it is explained on its documentation), so for instance

\begin{tabular}{l l l p{3cm}}

has to be changed into

\begin{tabular}{Sl Sl Sl Sp{3cm}}

For extra space in the cells, the parameters \cellspacetoplimit and \cellspacebottomlimit may be modified with \setlength. In my particular case, I get enter image description here with the code

\documentclass[spanish]{beamer}
\usepackage[utf8]{inputenc}
\usetheme{Copenhagen}
\usecolortheme{default}
\usepackage[spanish]{babel}
\setbeamertemplate{headline}{} % This deletes the index on top of each slide
\usefonttheme{default}
\usepackage{cellspace}

\newcommand\wider[2][3em]{% \makebox[\linewidth][c]{% \begin{minipage}{\dimexpr\textwidth+#1\relax} \raggedright#2 \end{minipage}% }% }

\begin{document}

\begin{frame} \wider[3em]{\small \bgroup\setlength{\tabcolsep}{5pt} \setlength{\cellspacebottomlimit}{5pt} \setlength{\cellspacetoplimit}{5pt} \begin{tabular}{Sc | Sl Sl Sl} \begin{minipage}{35pt} \centering base de $\mathsf{su}(2)$ \end{minipage} & $E_{1}=\frac{1}{2}\begin{pmatrix} i & 0 \ 0 & -i \end{pmatrix}$ , & $E_{2}=\frac{1}{2}\begin{pmatrix} 0 & i \ i & 0 \end{pmatrix}$ , & $E_{3}=\frac{1}{2}\begin{pmatrix} 0 & -1 \ 1 & 0 \end{pmatrix}.$ \\hline \begin{minipage}{35pt} \centering base de $\mathsf{so}(3)$ \end{minipage} & $F_1=\begin{pmatrix} 0&0&0\ 0&0&-1\ 0&1&0 \end{pmatrix},$ & $F_2=\begin{pmatrix} 0&0&1\ 0&0&0\ -1&0&0 \end{pmatrix},$ & $F_3=\begin{pmatrix} 0&-1&0\ 1&0&0\ 0&0&0 \end{pmatrix}.$ \end{tabular} \egroup } \end{frame}

\end{document}