3

I've got a regular table in the first line of an enumitem list. The label is vertically centered on the side of the list. Is there a way to have the list label top-aligned - still on the left of the table? I couldn't find anything online because I can't think of a way to form a question suitable for google search.

a table with two columns, four rows with a list label to the left that is vertically centered

This is my code:

\begin{enumerate}[label=\alph*)]
    \item \begin{tabular}{|l|l|} \hline
    cell 1 & cell 2\\\hline
    cell 3 & cell 4\\\hline
    cell 5 & cell 6\\\hline
    cell 7 & cell 8\\\hline
    \end{tabular}
    
    \blindtext
\end{enumerate}
1

2 Answers 2

2

Adding positional argument [t] aligns the topmost elements' baseline with baseline of the label text. If you had not have a rule above the first row, that would be enough (the first part of the code below). Otherwise, latex takes the baseline of the topmost rule.

If you shift the baseline of the table, manually, or by a package, you get thetable aligned with the label. The distance between top edge of a cell and a baseline of text is 0.7\baselineskip. Raising a table by this amount lines it up with the label.

enter image description here

\documentclass{article}
\usepackage{mwe}
\usepackage{enumitem}

\begin{document}
\begin{enumerate}[label=\alph*)]
\item
  \begin{tabular}[t]{ll}
    cell 1 & cell 2\\
    cell 3 & cell 4\\
    cell 5 & cell 6\\
  \end{tabular}
  
  \blindtext
\item
  \raisebox{0.7\baselineskip}{%
    \begin{tabular}[t]{ll}
      \hline
      cell 1 & cell 2\\\hline
      cell 3 & cell 4\\\hline
      cell 5 & cell 6\\\hline
    \end{tabular}}
  
  \blindtext[1]
\end{enumerate}
\end{document}
3

With an up-to-date distribution, you can use baseline=T from tabularray package.

\documentclass{article}
\usepackage{mwe}
\usepackage{enumitem}
\usepackage{tabularray}
\begin{document}
    \begin{enumerate}[label=\alph*)]
        \item \begin{tblr}[T]{|l|l|} \hline
            cell 1 & cell 2\\\hline
            cell 3 & cell 4\\\hline
            cell 5 & cell 6\\\hline
            cell 7 & cell 8\\\hline
        \end{tblr}
        
        \blindtext
    \end{enumerate}
\end{document}

enter image description here

What Pieter van Oostrum suggested, \begin{tabular}[t], aligns the label at the first \hline of the table, not at the first line of text of the table.

You must log in to answer this question.

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