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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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: 10348
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