Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted
\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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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