1

This is such a simple thing and should just work, but I don't understand why it is not. I have a simple table with three columns and two rows. I wanted the text in each cell in the first row to be vertically centered. It does centerenter image description here vertically in the first and second columns, but in the third column, the text remains at the top. My source is as follows:

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{array}
\title{}
\author{}
\pagestyle{empty}
\date{}

\begin{document}
\setlength\extrarowheight{2pt}
\begin{tabular}{|m{1cm}|m{4in}|m{3cm}|}
\hline
\textbf{No.} & \textbf{Particulars} & \textbf{Amount}\\[8pt]
\hline
1. & Blah blah blah &  2,000.00\\[8pt]
\hline
\end{tabular}
\end{document}

I almost feel sorry to have to ask this here, as it is such a simple thing. But, it gives me a less than satisfactory result, and I don't seem to be able to make out what is going wrong.

0

Instead of manually adding vertical space to the rows, I'd suggest using cellspace. You can adjust the spacing to suit your needs, while the contents will be vertically centered.

Personally, I prefer tables with a more open look (no vertical lines and less horizontal lines), so I added an example with booktabs as well. Lastly, you could also use the siunitx package to help with the aligment of number in table cells. If your second column sontains quite some text, I'd go for tabularx in order to make the table as wide as the textwidth while allowing automatical linebreaks in the second column. I have included an example on this as well.

Lastly, and if you'r tired of manually numbering rows, you can take a look at Automatic table row numbers

enter image description here

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{array}


\usepackage[column=0]{cellspace}
\setlength\cellspacetoplimit{6pt}
\setlength\cellspacebottomlimit{\cellspacetoplimit}

\usepackage{booktabs}

\usepackage{siunitx}
\sisetup{input-ignore={,},input-decimal-markers={.}}
\usepackage{tabularx}

\begin{document}

With cellspace:

\begin{tabular}{|0{m{1cm}}|0{m{4in}}|0{m{3cm}}|}
\hline
\textbf{No.} & \textbf{Particulars} & \textbf{Amount}\\
\hline
1. & Blah blah blah &  2,000.00\\
\hline
2. & Blah blah blah &  2,000.00\\
\hline
\end{tabular}

\bigskip

With booktabs:

\begin{tabular}{m{1cm}m{4in}m{3cm}}
\toprule
\textbf{No.} & \textbf{Particulars} & \textbf{Amount}\\
\midrule
1. & Blah blah blah &  2,000.00\\
2. & Blah blah blah &  2,000.00\\
\bottomrule
\end{tabular}

\bigskip

With booktabs, siunitx and tabularx:

\begin{tabularx}{\textwidth}{lXS[table-format=4.2]}
\toprule
{No.} & {Particulars} & {Amount}\\
\midrule
1. & Blah blah blah &  2,000.00\\
2. & Blah blah blah &  2,000.00\\
\bottomrule
\end{tabularx}

\end{document}
| improve this answer | |
0

Change the \arraystretch instead of add some \extrarowheight plus [8pt] to each row:

mwe

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{array}
\begin{document}
\renewcommand\arraystretch{1.6}
\begin{tabular}{|m{1cm}|m{4in}|m{3cm}|}\hline
\textbf{No.} & \textbf{Particulars} & \textbf{Amount}\\\hline
1. & Blah blah blah &  2,000.00\\\hline
\end{tabular}
\end{document}

(... and of course, instead of jailed tables, use booktabs!).

| improve this answer | |
  • Just to confirm that the added space at the end of each row with [8pt] seems to be what caused the problem. It worked fine without that and with \arraystretch added to increase the space. – Sasi Mar 26 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.