4

I have some text outside of a tabular environment, and also some text inside a tabular environment. I would like the text outside the tabular environment to be aligned with the text residing in the first row of the tabular environment.

Currently, the text outside the tabular environment is too low relative to the text inside the tabular environment.

MWE:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{float}
\usepackage{enumitem}
\usepackage[left=3mm, right=3mm,top=30mm,bottom=5mm,includehead=true,headsep=3pt]{geometry}





\begin{document}
In the context of using the itemize environment...
\begin{itemize}
\item  I would like to have the text outside my table \quad \begin{tabular}{| b{26mm} | b{26mm}|} be in line with &  the text inside  \\ \hline blah blah blah & blah \end{tabular} the table.
\item but the word ``table'' (outside the tabular) is too high relative to the word ``be'' (inside the tabular).  
\item Any thoughts?

\end{itemize}


\end{document}

And a screenshot of my output:

enter image description here

2
  • 3
    The [t] or [b] options for tabular. They align the first or last baseline relative the outside text. Commented Sep 23, 2021 at 22:20
  • @JohnKormylo This worked great for me. If you want, you can copy this as an answer and I will accept it...
    – Sam
    Commented Sep 24, 2021 at 15:11

2 Answers 2

3

In memorium: Henry Thumpman, king of the one line patch.

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{float}
\usepackage{enumitem}
\usepackage[left=3mm, right=3mm,top=30mm,bottom=5mm,includehead=true,headsep=3pt]{geometry}

\begin{document}
In the context of using the itemize environment...
\begin{itemize}
\item  I would like to have the text outside my table \quad \begin{tabular}[t]{| b{26mm} | b{26mm}|} be in line with &  the text inside  \\ \hline blah blah blah & blah \end{tabular} the table.
\item but the word ``table'' (outside the tabular) is too high relative to the word ``be'' (inside the tabular).  
\item Any thoughts?

\end{itemize}

\end{document}
4

For information, with {NiceTabular} of nicematrix, you have more options for the vertical alignment of a tabular.

\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}
\usepackage{geometry}

\begin{document}

\begin{itemize}
\item \verb|[t]|: Aligned with the first row (even with a \verb|\hline| on top)
\begin{NiceTabular}[t]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline
fourth row \\
\hline
\end{NiceTabular}

\item \verb|[b]|: Aligned with the last row (even with a \verb|\hline| on bottom)
\begin{NiceTabular}[b]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline
fourth row \\
\hline
\end{NiceTabular}

\item \verb|[baseline=3]|: Aligned with a row given by its number 
\begin{NiceTabular}[baseline=3]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline 
fourth row \\
\hline
\end{NiceTabular}

\item \verb|[baseline=line-3]|: Aligned with an horizontal rule given by its number
\begin{NiceTabular}[baseline=line-3]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline 
fourth row \\
\hline
\end{NiceTabular}

\end{itemize}

\end{document}

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

Output of the above code

You must log in to answer this question.

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