How to center p column values in a LaTex table?

First we need to use the array package and define a new command P

\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
Afterwards, we can use the command P instead of p as follows when we define column type in the LaTex table

\begin{table}
  \centering
  \begin{tabular}{|P{2.5cm}|P{2.5cm}|P{2.5cm}|}
    \hline
    Reconstruction strategy & aa          & bb( \%) \\ \hline
    Classic                 & 3342 voxels & 68 \%   \\ \hline
    VC                      & 4296 voxels & 87 \%   \\ \hline
    V m=7                   & 4745 voxels & 96 \%   \\ \hline
  \end{tabular}
  \newline\newline
  \caption{title}\label{tab1}
\end{table}

This will give you the following output:


 

[Source]: https://tex.stackexchange.com/questions/157389/how-to-center-column-values-in-a-table

No comments:

Post a Comment