4

I need to

  1. align all four tables on their top (currently it looks like they are all aligned by center).
  2. have the vertical line separating "funct" in each table not to be interrupted.
\documentclass[10pt]{article}
\textwidth= 5.00in
\textheight= 7.4in
\topmargin = 30pt
\evensidemargin=0pt
\oddsidemargin=55pt
\headsep=17pt
\parskip=.8pt
\parindent=12pt
\font\smallit=cmti10
\font\smalltt=cmtt10
\font\smallrm=cmr9

\usepackage{tabularx}
\usepackage{amssymb,amsmath,amsthm,enumitem} 
\usepackage{subcaption,booktabs}

\begin{document}

\begin{table}[h] 
\setlength\tabcolsep{0pt}
\small 
\caption{Examples} 
\label{tab:4subt_2}
\begin{subtable}{0.35\textwidth}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}ccccc|c}
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
\hline
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
\bottomrule
\end{tabular*}
\end{subtable}
\hfill
\begin{subtable}{0.22\textwidth}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}ccccc|c}
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
\hline
1 &2 &3 &4 &5  & 1, 2, 3\\
\hline
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
\hline
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
\bottomrule
\end{tabular*}
\end{subtable}
\hfill
\begin{subtable}{0.2\textwidth}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}ccccc|c}
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1 &2 &3 &4 &5  & 1, 2\\
1 &2 &3 &4 &5  & 1, 2\\
1 &2 &3 &4 &5  & 1, 2\\
\hline
1 &2 &3 &4 &5  & 1, 2\\
\bottomrule
\end{tabular*}
\end{subtable}
\hfill
\begin{subtable}{0.18\textwidth}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}ccccc|c} 
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1 &2 &3 &4 &5  & 1\\
1 &2 &3 &4 &5  & 1\\
\bottomrule
\end{tabular*}
\end{subtable}
\hfill
\end{table}
\end{document}

1
  • 2
    never use a primitive font assignment such as \font\smallit in latex!!! but \begin{tabular*}[t] will make the tables align on their first row Nov 26, 2023 at 21:18

2 Answers 2

3

As @DavidCarlisle has already suggested in a comment, just change all four instances of

\begin{tabular*}{\linewidth}

to

\begin{tabular*}{\linewidth}[t]

The t alignment specifier tells LaTeX that the four tabular* environments should be aligned along their top lines.

Incidentally, it's not a good idea at all to employ vertical rules in tabular* environments with \tabcolsep set to zero.

enter image description here

\documentclass[10pt]{article}
\textwidth= 5.00in
\textheight= 7.4in
\topmargin = 30pt
\evensidemargin=0pt
\oddsidemargin=55pt
\headsep=17pt
\parskip=.8pt
\parindent=12pt
%\font\smallit=cmti10
%\font\smalltt=cmtt10
%\font\smallrm=cmr9

\usepackage{tabularx}
\usepackage{amssymb,amsmath,amsthm,enumitem} 
\usepackage{subcaption,booktabs}

\begin{document}

\begin{table}[h] 
\setlength\tabcolsep{0pt}
\small 
\caption{Examples} 
\label{tab:4subt_2}
\begin{subtable}{0.35\textwidth}
\begin{tabular*}{\linewidth}[t]{@{\extracolsep{\fill}}ccccc|c}
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
\hline
1& 2& 3& 4& 5& $1,2,3,4 = [5] \setminus \{6\}$\\
\bottomrule
\end{tabular*}
\end{subtable}%
\hfill
\begin{subtable}{0.22\textwidth}
\begin{tabular*}{\linewidth}[t]{@{\extracolsep{\fill}}ccccc|c}
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
\hline
1 &2 &3 &4 &5  & 1, 2, 3\\
\hline
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
\hline
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
\bottomrule
\end{tabular*}
\end{subtable}%
\hfill
\begin{subtable}{0.2\textwidth}
\begin{tabular*}{\linewidth}[t]{@{\extracolsep{\fill}}ccccc|c}
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1 &2 &3 &4 &5  & 1, 2\\
1 &2 &3 &4 &5  & 1, 2\\
1 &2 &3 &4 &5  & 1, 2\\
\hline
1 &2 &3 &4 &5  & 1, 2\\
\bottomrule
\end{tabular*}
\end{subtable}%
\hfill
\begin{subtable}{0.18\textwidth}
\begin{tabular*}{\linewidth}[t]{@{\extracolsep{\fill}}ccccc|c} 
\toprule
$aa$ & $bb$ & $cc$ & $dd$  & $ee$ & fu\\
\midrule
1 &2 &3 &4 &5  & 1\\
1 &2 &3 &4 &5  & 1\\
\bottomrule
\end{tabular*}
\end{subtable}%
\hfill
\end{table}
\end{document}
2
  • is there a way to make the separating line before "funct" to go without interruption?
    – Vika
    Nov 26, 2023 at 21:33
  • @Vika - Since your initial code makes use of the booktabs package and its line-drawing macros, I assumed you knew what you're doing. In particular, that you were aware of following rule posited by the package's author: "Never, ever use vertical rules". You should look into it.
    – Mico
    Nov 26, 2023 at 23:20
2
  • Rules defined in the booktabs package are not intendent to be use in tables with vertical lines.
  • For removing this gaps, you have several possibilities. For example redefine rules and add add vertical spaces by use of the cellspace package, ... or use tabularray package is is shown below:
\documentclass{article}
\textwidth= 5.00in
\textheight= 7.4in
\topmargin = 30pt
\evensidemargin=0pt
\oddsidemargin=55pt
\headsep=17pt
\parskip=.8pt
\parindent=12pt

\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs}
\usepackage{amssymb,amsthm,enumitem}
\usepackage{subcaption}

\begin{document}

\begin{table}[ht]
\setlength\tabcolsep{0pt}
\small
\caption{Examples}
\label{tab:4subt_2}
\begin{subtable}{0.36\textwidth}
\begin{tblr}[t]{colsep= 2pt,
             colspec = {@{} *{5}{X[c]}|Q[c,mode=math] @{}},
             row{1}  = {mode=math}
             }
    \toprule
aa & bb & cc & dd  & ee & \text{fu}\\
    \midrule
1   & 2 & 3 & 4 & 5 & 1,2,3,4 = [5] \setminus \{6\}    \\
1   & 2 & 3 & 4 & 5 & 1,2,3,4 = [5] \setminus \{6\}    \\
1   & 2 & 3 & 4 & 5 & 1,2,3,4 = [5] \setminus \{6\}    \\
1   & 2 & 3 & 4 & 5 & 1,2,3,4 = [5] \setminus \{6\}    \\
1   & 2 & 3 & 4 & 5 & 1,2,3,4 = [5] \setminus \{6\}    \\
    \hline
1   & 2 & 3 & 4 & 5 & 1,2,3,4 = [5] \setminus \{6\}     \\
    \bottomrule
\end{tblr}
\end{subtable}%
\hfill
\begin{subtable}{0.23\textwidth}
\begin{tblr}[t]{colsep= 2pt,
             colspec = {@{} *{5}{X[c]}|c @{}},
             row{1}  = {mode=math}
             }
    \toprule
aa & bb & cc & dd  & ee & \text{fu} \\
    \midrule
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
    \hline
1 &2 &3 &4 &5  & 1, 2, 3\\
\hline
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
    \hline
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
1 &2 &3 &4 &5  & 1, 2, 3\\
    \bottomrule
\end{tblr}
\end{subtable}%
\hfill
\begin{subtable}{0.20\textwidth}
\begin{tblr}[t]{colsep= 2pt,
             colspec = {@{} *{5}{X[c]}|c @{}},
             row{1}  = {mode=math}
             }
    \toprule
aa & bb & cc & dd  & ee & \text{fu}   \\
    \midrule
1 &2 &3 &4 &5  & 1, 2\\
1 &2 &3 &4 &5  & 1, 2\\
1 &2 &3 &4 &5  & 1, 2\\
    \hline
1 &2 &3 &4 &5  & 1, 2\\
    \bottomrule
\end{tblr}
\end{subtable}%
\hfill
\begin{subtable}{0.18\textwidth}
\begin{tblr}[t]{colsep= 2pt,
             colspec = {@{} *{5}{X[c]}|c @{}},
             row{1}  = {mode=math}
             }
    \toprule
aa & bb & cc & dd  & ee & \text{fu}\\
    \midrule
1 &2 &3 &4 &5  & 1\\
1 &2 &3 &4 &5  & 1\\
    \bottomrule
\end{tblr}
\end{subtable}
    \end{table}
\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 .