2

I read hundreds of threads now, but I don't get the point. Why isn't the text in the left column of the following table vertically centered?

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{longtable, array}
\usepackage{lipsum}

\begin{document}

\begin{landscape}
  \begin{longtable}{ m{0.1\linewidth} p{.35\linewidth}p{.55\linewidth} }
  \endfirsthead
  \endhead
  \toprule
  \textbf{Enum} & \textbf{Example} & \textbf{Description} \\
  \midrule
  1 & test & \lipsum[50]\\
  \midrule
  2a & test & \lipsum[50]\\
  2b & test & \lipsum[50]\\
  \bottomrule
  \end{longtable}
\end{landscape}

\end{document}

My local compiler as well as overleaf produce the following output enter image description here

Can anybody help? If possible I would also like to have the text in the left column centered horizontally, but I think this will be done quickly then.

3
  • 2
    you must center the last column relative to the baseline:, \begin{longtable}{p{0.1\linewidth} p{.35\linewidth}m{.55\linewidth} } Dec 30, 2021 at 20:56
  • That totally did the trick, thanks. But can you explain why Latex behaves like this? It sounds counterintuitive to me. Dec 30, 2021 at 21:05
  • 2
    see tex.stackexchange.com/a/594620/2388 Dec 30, 2021 at 21:11

2 Answers 2

2

https://github.com/AnMnv/eBook (example 4.11)

enter image description here

\documentclass{article}
\usepackage[left=1.5cm,right=1.5cm,
    top=1.5cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage{float}
\usepackage{array, makecell}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{booktabs}

\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{longtable, array}


\begin{document}

\begin{landscape}
\begin{longtable}{@{} *{2}{m{.\paperwidth}} *{1}{m{.40\paperwidth}} @{}}
\endfirsthead
\endhead
\toprule
\textbf{Enum} & \textbf{Example} & \textbf{Description} \\
\midrule
1 & test & \lipsum[50]\\
\midrule
2a & test & \lipsum[50]\\
2b & test & \lipsum[50]\\
\bottomrule
\end{longtable}
\end{landscape}

\end{document}
4

With tabularray is simple:

\documentclass{article}
\usepackage{pdflscape}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\usepackage{lipsum}

\begin{document}

\begin{landscape}
  \begin{longtblr}[
caption = {caption text},
  label = {tab:longtblr}
                    ]{
  colspec = {Q[c] X[l] X[1.6,m,j]},
   row{1} = {font=\bfseries},
  rowhead = 1
                     }
  \toprule
Enum    &   Example &   Description \\
  \midrule
  1     &   test    &   \lipsum[50] \\
  \midrule
  2a    & test      &   \lipsum[50] \\
  \addlinespace
  2b    & test      &   \lipsum[50] \\
  \bottomrule
  \end{longtblr}
\end{landscape}

\end{document}

Where meaning of the used column specifications are:

  • Q[c] (or shorter c) define columns with horizontal centered contents
  • X[l] define X column (similar as at tabularx package) where option l define that column contents is left aligned
  • X[1.6,m,j is define X similar as above, however options 1.6 make it wide for 1.6 time, m vertical center cells contents, and j that cells content is justified.

enter image description here

1
  • thanks a lot, that works, however, I am restricted to longtable. Jan 3, 2022 at 11:51

You must log in to answer this question.

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