Graphics, Figures & TablesVertical Alignment for Table Cell Content

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
drmath
Posts: 2
Joined: Wed Jun 08, 2011 3:58 am

Vertical Alignment for Table Cell Content

Post by drmath »

Hi,

I want to align tabular cells vertically. But third column is not aligned.

Code: Select all

\begin{tabular}{|m{5cm}|m{5cm}|m{5cm}|}\hline
a & b & c \\[2cm] \hline
d & e & f \\[2cm] \hline
\end{tabular}
Please help.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertical Alignment for Table Cell Content

Post by localghost »

For an adequate problem description kindly prepare (again) a self-contained and minimal example.


Thorsten
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Vertical Alignment for Table Cell Content

Post by Stefan Kottwitz »

All cells in a row are still vertically aligned. In each column, the \\[2cm] made the last cell larger, while the content of this cell remains on top of its cell. Inner alignment in cells is top, outer aligment (between cells) is middle, that's what m means.

You could fix it by adding an empty invisible column:

Code: Select all

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|m{5cm}|m{5cm}|m{5cm}|@{}m{0cm}@{}}\hline
  a & b & c & \\[2cm] \hline
  d & e & f & \\[2cm] \hline
\end{tabular}
\end{document}
Next time, in case of problems, it would be good to provide a Infominimal working example which shows the problem. Such a small but complete code which I posted here. It's not always so easy for a reader to complete it himself. Note, a poster might save time to not post a complete example, but all readers then have to invest to do that themselves, if the code requires a test.

Stefan
LaTeX.org admin
Post Reply