4

How can I make these three tables the same width and height and the width of the first column of each table the same?

Also, how do I display the "Product" table just to the right of the "Sum" table? The minipage environment doesn't seem to work for me!

enter image description here

MWE :

\documentclass[10pt,a4paper]{article}
\pagestyle{empty}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsfonts,amsmath,amssymb,array,cellspace,tabularray,tabularx,tabvar,tikz,xcolor}
\UseTblrLibrary{varwidth}

\begin{document}

\begin{tblr}{ column{1}=36pt, rows = {abovesep=4.5pt,belowsep=4.5pt}, columns = {leftsep=9pt,rightsep=9pt}, colspec={lcccccc}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {green!30}, stretch=-1, measure=vbox} \SetCell[r=1,c=1]{c} Somme \ $\lim_{} f$ & $\ell$ & $\ell$ & $\ell$ & + $\infty$ & - $\infty$ & + $\infty$ \ $\lim_{} g$ & $\ell '$ & + $\infty$ & - $\infty$ & + $\infty$ & - $\infty$ & - $\infty$ \ $\lim_{} f + g$ & $\ell + \ell '$ & + $\infty$ & - $\infty$ & + $\infty$ & - $\infty$ & $?$ \ \end{tblr}

\vspace{.3cm}

\begin{tblr}{ column{1}=36pt, rows = {abovesep=4.5pt,belowsep=4.5pt}, columns = {leftsep=9pt,rightsep=9pt}, colspec={lcccc}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {blue!30}, stretch=-1, measure=vbox} \SetCell[r=1,c=1]{c} Produit \ $\lim_{} f$ & $\ell$ & $\ell \neq 0 $ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell '$ & $\infty$ & $\infty$ & $\infty$ \ $\lim_{} f \times g$ & $\ell \times \ell '$ & $\infty$ & $\infty$ & $?$ \ \end{tblr}

\vspace{.3cm}

\begin{tblr}{ column{1}=36pt, rows = {abovesep=4.5pt,belowsep=4.5pt}, columns = {leftsep=9pt,rightsep=9pt}, colspec={lcccccc}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {purple!30}, stretch=-1, measure=vbox} \SetCell[r=1,c=1]{c} Quotient \ $\lim_{} f$ & $\ell$ & $\ell \neq 0$ & $\ell$ & $\infty$ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell ' \neq 0$ & $0$ & $\infty$ & $\ell$ & $\infty$ & $0$\ $\lim_{} \dfrac{f}{g}$ & $\dfrac{\ell}{\ell '}$ & $\infty$ & $0$ & $\infty$ & ? & ? \ \end{tblr}

\end{document}

Mix of proposed solutions, thanks guys!

\noindent\begin{tblr}{
        rows = {abovesep=4.5pt, belowsep=4.5pt},
        rowspec={m{4mm} | t{10mm}  | t{10mm}  | t{10mm} },
        columns = {leftsep=4pt, rightsep=4pt,26pt},
        column{1}=1.5cm,
        colspec={lcccccc},
        cell{1}{1}={c},
        hline{2,3,4} = {1-7}{black},
        vline{2} = {black},
        cell{1}{1} = {green!30},
        stretch=-1,
    %   measure=\vbox
    }
    \SetCell[r=1,c=1]{c} Somme \\
    $\lim_{} f$ & $\ell$ & $\ell$ & $\ell$ & $+\infty$ & $-\infty$ & $+\infty$ \\
    $\lim_{} g$ & $\ell '$ & $+\infty$ & $-\infty$ & $+\infty$ & $-\infty$ & $-\infty$ \\
    $\lim_{} f + g$ & $\ell + \ell '$ & $+\infty$ & $-\infty$ & $+\infty$ & $-\infty$ & $?$ \\
\end{tblr}

\vspace{.3cm}

\noindent\begin{tblr}{ rows = {abovesep=4.5pt,belowsep=4.5pt}, rowspec={m{4mm} | t{10mm} | t{10mm} | t{10mm} }, columns = {leftsep=4pt, rightsep=4pt,26pt}, column{1}=1.5cm, colspec={lcccccc}, cell{1}{1}={c}, hline{2,3,4} = {1-6}{black}, vline{2} = {black}, cell{1}{1} = {purple!30}, stretch=-1, % measure=\vbox } \SetCell[r=1,c=1]{c} Quotient \ $\lim_{} f$ & $\ell$ & $\ell \neq 0$ & $\ell$ & $\infty$ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell ' \neq 0$ & $0$ & $\infty$ & $\ell$ & $\infty$ & $0$\ $\lim_{} \dfrac{f}{g}$ & $\dfrac{\ell}{\ell '}$ & $\infty$ & $0$ & $\infty$ & $?$ & $?$ \ \end{tblr} \hspace{.3cm} \begin{tblr}{ rows = {abovesep=4.5pt,belowsep=4.5pt}, rowspec={m{4mm} | t{10mm} | t{10mm} | t{10mm} }, columns = {leftsep=4pt, rightsep=4pt,26pt}, column{1}=1.5cm, colspec={lcccc}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {blue!30}, stretch=-1, % measure=\vbox } \SetCell[r=1,c=1]{c} Produit \ $\lim_{} f$ & $\ell$ & $\ell \neq 0 $ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell '$ & $\infty$ & $\infty$ & $\infty$ \ $\lim_{} f \times g$ & $\ell \times \ell '$ & $\infty$ & $\infty$ & $?$ \ \end{tblr}

Sacha
  • 65
  • For the second question, you need to delete (or comment out) the empty lines around \vspace{.3cm}. LaTeX is interpreting that as a command to start a new paragraph. – Sandy G Dec 04 '22 at 17:05

4 Answers4

3

I'm not sure if this is what you want:

enter image description here

You need to delete the empty lines between the tables (which cause a new paragraph to start).

After that, columns = {leftsep=4pt, rightsep=4pt, 9mm} will fix all columns at 9mm. To make the first column special, place column{1}=36pt after the columns command.

\documentclass[10pt,a4paper]{article}
\pagestyle{empty}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsfonts,amsmath,amssymb,array,cellspace,tabularray,tabularx,tabvar,tikz,xcolor}
\UseTblrLibrary{varwidth}

\begin{document}

\noindent\begin{tblr}{ rows = {abovesep=4.5pt, belowsep=4.5pt}, columns = {leftsep=4pt, rightsep=4pt, 9mm}, column{1}=36pt, colspec={lcccccc}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {green!30}, stretch=-1, measure=vbox} \SetCell[r=1,c=1]{c} Somme \ $\lim_{} f$ & $\ell$ & $\ell$ & $\ell$ & + $\infty$ & $-\infty$ & $+\infty$ \ $\lim_{} g$ & $\ell '$ & $+\infty$ & $-\infty$ & $+\infty$ & $-\infty$ & $-\infty$ \ $\lim_{} f + g$ & $\ell + \ell '$ & $+\infty$ & $-\infty$ & $+\infty$ & $-\infty$ & $?$ \ \end{tblr} \quad \begin{tblr}{ rows = {abovesep=4.5pt,belowsep=4.5pt}, columns = {leftsep=4pt, rightsep=4pt, 9mm}, column{1}=36pt, colspec={lcccc}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {blue!30}, stretch=-1, measure=vbox} \SetCell[r=1,c=1]{c} Produit \ $\lim_{} f$ & $\ell$ & $\ell \neq 0 $ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell '$ & $\infty$ & $\infty$ & $\infty$ \ $\lim_{} f \times g$ & $\ell \times \ell '$ & $\infty$ & $\infty$ & $?$ \ \end{tblr}

\vspace{4mm} \noindent\begin{tblr}{ rows = {abovesep=4.5pt,belowsep=4.5pt}, columns = {leftsep=4pt, rightsep=4pt, 9mm}, column{1}=36pt, colspec={lcccccc}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {purple!30}, stretch=-1, measure=vbox} \SetCell[r=1,c=1]{c} Quotient \ $\lim_{} f$ & $\ell$ & $\ell \neq 0$ & $\ell$ & $\infty$ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell ' \neq 0$ & $0$ & $\infty$ & $\ell$ & $\infty$ & $0$\ $\lim_{} \dfrac{f}{g}$ & $\dfrac{\ell}{\ell '}$ & $\infty$ & $0$ & $\infty$ & ? & ? \ \end{tblr}

\end{document}

Sandy G
  • 42,558
  • Thank you!

    I changed the settings slightly and got something almost compliant, but there is still a space difference (updated post).

    Do you know how to solve it?

    – Sacha Dec 04 '22 at 17:26
  • @Sacha: I cannot duplicate your result. There is no space difference when I compile the code. Replace \quad with \hspace{-3mm} to test. Checked with magnification at 10000%. Maybe this is just an issue with your pdf viewer. – Sandy G Dec 04 '22 at 17:44
  • Whatever else you do, there should be no space between the + and - symbols and the associated \infty symbol. Also, I wouldn't use a text-mode "dash" symbol instead of a math-mode "minus" symbol to denote negative values. – Mico Dec 04 '22 at 20:03
  • 1
    @Mico: Fixed. Didn't notice that in the original code. – Sandy G Dec 04 '22 at 20:31
  • Thank you for your help! I finally got the result I wanted. Code updated above. – Sacha Dec 04 '22 at 21:22
3

You asked,

how do I display the "Product" table just to the right of the "Sum" table?

I can't see a good use case for tblr environments here. I'd use three array environments instead -- with the big advantage of not having to provide so many $ symbols. Also, don't be afraid to use inline fraction notation when doing so is eminently called for.

enter image description here

\documentclass[a4paper]{article}

\usepackage[margin=2.5cm]{geometry} % set page parameters suitably %% \usepackage[utf8]{inputenc} % that's the default nowadays \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{amssymb,amsmath} \usepackage{array} % for 'w' column type \usepackage{xcolor} % color support \usepackage{colortbl} % for '\cellcolor' macro % Determine widths of (a) header column and (b) data columns: \newlength\lenA \settowidth\lenA{\textsf{Quotient}} \newlength\lenB \settowidth\lenB{$\ell'\ne0$}

\begin{document}

\begin{table}[ht] \renewcommand\arraystretch{1.5} $\begin{array}{wl{\lenA} | {6}{wc{\lenB}} @{}} \cellcolor{green!30} \textsf{Somme} & \ \hline \lim f & \ell & \ell & \ell & +\infty & -\infty & +\infty \ \hline \lim g & \ell' & +\infty & -\infty & +\infty & -\infty & -\infty \ \hline \lim f{+}g& \ell+\ell' & +\infty & +\infty & +\infty & +\infty & \text{?} \end{array}$ \hfill % maximize the horizontal separation $\begin{array}{wl{\lenA} | {4}{wc{\lenB}} @{}} \cellcolor{blue!30} \textsf{Produit} & \ \hline \lim f & \ell & \ell\ne0 & \infty & 0 \ \hline \lim g & \ell' & \infty & \infty & \infty \ \hline \lim f{\times}g& \ell\times\ell' & \infty & \infty & \text{?} \end{array}$

\bigskip $\begin{array}{wl{\lenA} | *{6}{wc{\lenB}} @{}} \cellcolor{purple!30} \textsf{Quotient} & \ \hline \lim f & \ell & \ell\ne0 & \ell & \infty & \infty & 0 \ \hline \lim g & \ell'\ne0 & 0 & \infty & \ell & \infty & 0 \ \hline \lim f{/}g& \ell/\ell' & \infty & 0 & \infty & \text{?} & \text{?} \end{array}$ \end{table}

\end{document}

Mico
  • 506,678
2

something like this??

enter image description here

\documentclass{article}
\usepackage{tabularray,xcolor,mathtools}
\begin{document}

\noindent\begin{tblr}{ rows = {abovesep=4.5pt, belowsep=4.5pt}, rowspec={m{4mm} | t{10mm} | t{10mm} | t{10mm} }, columns = {leftsep=4pt, rightsep=4pt,25pt}, column{1}=1.5cm, colspec={XXXXXX}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {green!30}, stretch=-1, % measure=\vbox } \SetCell[r=1,c=1]{c} Somme \ $\lim_{} f$ & $\ell$ & $\ell$ & $\ell$ & + $\infty$ & - $\infty$ & + $\infty$ \ $\lim_{} g$ & $\ell '$ & + $\infty$ & - $\infty$ & + $\infty$ & - $\infty$ & - $\infty$ \ $\lim_{} f + g$ & $\ell + \ell '$ & + $\infty$ & - $\infty$ & + $\infty$ & - $\infty$ & $?$ \ \end{tblr}

\noindent \begin{tblr}{ rows = {abovesep=4.5pt,belowsep=4.5pt}, rowspec={m{4mm} | t{10mm} | t{10mm} | t{10mm} }, columns = {leftsep=4pt, rightsep=4pt,25pt}, column{1}=1.5cm, colspec={XXXX}, cell{1}{1}={c}, hline{2,3,4} = {1-7}{black}, vline{2} = {black}, cell{1}{1} = {blue!30}, stretch=-1, % measure=\vbox } \SetCell[r=1,c=1]{c} Produit \ $\lim_{} f$ & $\ell$ & $\ell \neq 0 $ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell '$ & $\infty$ & $\infty$ & $\infty$ \ $\lim_{} f \times g$ & $\ell \times \ell '$ & $\infty$ & $\infty$ & $?$ \ \end{tblr}

\noindent\begin{tblr}{ rows = {abovesep=4.5pt,belowsep=4.5pt}, rowspec={m{4mm} | t{10mm} | t{10mm} | t{10mm} }, columns = {leftsep=4pt, rightsep=4pt,25pt}, column{1}=1.5cm, colspec={XXXXXX}, cell{1}{1}={c}, hline{2,3,4} = {1-6}{black}, vline{2} = {black}, cell{1}{1} = {purple!30}, stretch=-1, % measure=vbox } \SetCell[r=1,c=1]{c} Quotient \ $\lim_{} f$ & $\ell$ & $\ell \neq 0$ & $\ell$ & $\infty$ & $\infty$ & $0$ \ $\lim_{} g$ & $\ell ' \neq 0$ & $0$ & $\infty$ & $\ell$ & $\infty$ & $0$\ $\lim_{} \dfrac{f}{g}$ & $\dfrac{\ell}{\ell '}$ & $\infty$ & $0$ & $\infty$ & ? & ? \ \end{tblr}

\end{document}

user187802
  • 16,850
  • I think the OP wants the second table to be next to, rather than below, the first one. Also, I'm pretty sure that (a) one should avoid a line break in the $\ell' \neq 0$ cell in the third table and (b) the contents of the dsta columns should be centered rather than left-aligned. – Mico Dec 04 '22 at 20:47
1

I propose a command with 3 parameters

    % #1--> color of the title (option)
    % #2 --> number of columns 6 par défaut
    % #3 --> the table

With mode=math the $ are not necessary

EDIT2: To solve the overfull problem, I changed the width of the first column and I propose to take a measure in em

    \documentclass[10pt]{article}
\usepackage[margin=0.5cm]{geometry}
\usepackage{amsmath}
\usepackage{tabularray}
%\UseTblrLibrary{varwidth}
\usepackage{xcolor}
\ExplSyntaxOn
\NewDocumentCommand \sacha { O{} O{6} +m }
  {     % #1--> couleur (option)
        % #2 --> nombre de colonnes 6 par défaut
        % #3 --> le tableau
    \begin{tblr}{
      rows = {abovesep=4.5pt,belowsep=4.5pt,ht=1.5\baselineskip},
      columns = {leftsep=9pt,rightsep=9pt},
      colspec = {
        Q[l,wd=4em,mode=math]
        *{#2}{Q[c,wd=2.6em,mode=math]}
    },
      cell{1}{1}={c,mode=text,bg=#1},
      hline{2-4} = {1-Z}{black},
      vline{2} = {black},
      %stretch=-1,
      %measure=vbox
      }
      #3
      \end{tblr}
  }
\ExplSyntaxOff

\begin{document}

\sacha[green!30]{ \SetCell[r=1,c=1]{c} Somme \ \lim_{} f & \ell & \ell & \ell & + \infty & - \infty & + \infty \ \lim_{} g & \ell ' & + \infty & - \infty & + \infty & - \infty & - \infty \ \lim_{} f + g & \ell + \ell ' & + \infty & - \infty & + \infty & - \infty & ? } \quad\sacha[blue!30][4]{ \SetCell[r=1,c=1]{c} Produit \ \lim_{} f & \ell & \ell \neq 0 & \infty & 0 \ \lim_{} g & \ell ' & \infty & \infty & \infty \ \lim_{} f \times g & \ell \times \ell ' & \infty & \infty & ? }

\smallskip \sacha[purple!30]{ \SetCell[r=1,c=1]{c} Quotient \ \lim_{} f & \ell & \ell \neq 0 & \ell & \infty & \infty & 0 \ \lim_{} g & \ell ' \neq 0 & 0 & \infty & \ell & \infty & 0 \ \lim_{} \dfrac{f}{g} & \dfrac{\ell}{\ell '} & \infty & 0 & \infty & ? & ?} \end{document}

enter image description here

pascal974
  • 4,652