3

I have a two-column tabular environment and I'd like for both of these columns to have the text aligned at its middle (both vertically and horizontally), along with increased row height:

But with the following input:

\begin{center}
\begin{tabular}{m{1.8cm}|m{1cm}}
Problem & $\beta$ \\[0.2cm]
\hline
LCR-1 & 0.25 \\ [0.2cm]
\hline
LCR-10 & 0.05 \\ [0.2cm]
\hline
LCR-0.2 & 0.575 \\ [0.2cm]
\hline
Airplane & 0.05 \\ [0.2cm]
\hline
DR & 0.27 \\[0.2cm]
\end{tabular}
\end{center}

Only the first column is as required. The text in the second column is still aligned at top left.

Any hints?

2 Answers 2

2
\documentclass[11pt]{article}
\usepackage{array,ragged2e}
\newcolumntype{C}[1]{>{\Centering}m{#1}}
\begin{document}

{\def\arraystretch{1.5}
\begin{tabular}{ C{1.8cm} | C{1cm} }
Problem & $\beta$ \\\hline
LCR-1 & 0.25      \\\hline
LCR-10 & 0.05     \\\hline
LCR-0.2 & 0.575   \\\hline
Airplane & 0.05   \\\hline
DR & 0.27
\end{tabular}}

\end{document}

enter image description here

4

Those [0.2cm] are responsible for the wrong vertical alignment. You could remove those and use \arraystretch instead, such as

\renewcommand*{\arraystretch}{1.4}

If you do that within the center environment, the effect will be local, i.e. it will not affect the rest of the document. Here, used after \begin{center} its effect ends with the environment by \end{center}.

For horizontal centering you could use >{\centering}m{1cm} or even better, use Herberts suggestion requiring ragged2e.

Further suggestions:

  • Use the booktabs package for better spacing and improved customizable horizontal lines

  • Avoid vertical lines, they make reading harder

  • Align at decimal points instead of centering, for example using siunitx, rccol or dcolumn

0

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.