2

I am trying to vertical and horizontal align items in a table. I tried to follow what I found on the internet, including on this site, but it seems not to work for the last column. Here is what I have.

\begin{table}[!h]
\begin{center}
\begin{tabular}{|c||c|c|}

\hline
Doping & $\alpha_b$ $\left(\textup{cm}^{-1}\right)$ & $\eta_{ext}$ \\
\hline
\hline 
5 \% & $4 \cdot 10^{-4}$ & 0.995 \\ 
\hline
7.5 \% & $6 \cdot 10^{-4}$ & 0.992 \\  
\hline
10 \% & $8 \cdot 10^{-4}$ & 0.987 \\
\hline
\end{tabular}
\caption{Caption.}
\label{theor_cooling_efficiency_parameters}
\end{center}
\end{table}

Starting table

I want to increase the row height, since it seems too short, especially in the middle column (although it surprises me that LaTeX does not automatically adapt the rows to the math formulas inside)

Anyway, I included the array packages, increased manually the row's heights via [2ex] after the \ and set the vertical alignment with m. Here is the code:

\begin{table}[!h]
\begin{center}
\begin{tabular}{|m{3em}||m{4.8em}|m{3em}|}

\hline
Doping & $\alpha_b$ $\left(\textup{cm}^{-1}\right)$ & $\eta_{ext}$ \\[2ex] 
\hline
\hline 
5 \% & $4 \cdot 10^{-4}$ & 0.995 \\[2ex]  
\hline
7.5 \% & $6 \cdot 10^{-4}$ & 0.992 \\[2ex]  
\hline
10 \% & $8 \cdot 10^{-4}$ & 0.987 \\[2ex]  
\hline
\end{tabular}
\caption{Caption.}
\label{theor_cooling_efficiency_parameters}
\end{center}
\end{table}

And here is the result:

Not exactly what I wanted

As you can see, the first two columns are ok, but not the third, which is not centered at all. How can I fix this?

Thanks in advance for all the answers.

P.S.: I am aware that the columns are not horizontally centered and I know how to fix that, for example, by changing the tabular initialization to

\begin{tabular}{|>{\centering\arraybackslash}m{.1\linewidth}||
>{\centering\arraybackslash}m{.14\linewidth}|>{\centering\arraybackslash}m{.1\linewidth}|}

which centers horizontally the columns but does not fix the third column vertical alignment.

Horizontal center doesn't solve the problem

2

If you wish to stretch out the tabular vertically, use a consistent method like \arraystretch instead:

enter image description here

\documentclass[10pt]{article}
\usepackage{array}% http://ctan.org/pkg/array
\begin{document}
\begin{table}[!h]
  \centering
  \renewcommand{\arraystretch}{1.6}% Stretch tabular vertically
  \begin{tabular}{|m{3em}||m{4.8em}|m{3em}|}
    \hline
    Doping & $\alpha_b$ $\left(\textup{cm}^{-1}\right)$ & $\eta_{ext}$ \\ 
    \hline\hline 
    5 \% & $4 \cdot 10^{-4}$ & 0.995 \\
    \hline
    7.5 \% & $6 \cdot 10^{-4}$ & 0.992 \\
    \hline
    10 \% & $8 \cdot 10^{-4}$ & 0.987 \\
    \hline
  \end{tabular}
  \caption{Caption.}
  \label{theor_cooling_efficiency_parameters}
\end{table}
\end{document}

Alternatively, you can use struts as described in Column and row padding in tables. It's the optional argument of \\ that causes problems here.

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.