1

I wanted to make a table with the text centered in every box of the table, both horizontally and vertically. This is my code:

\renewcommand{\arraystretch}{1.5}
\begin{center} 
\begin{tabular}{ |>{\centering}p{0.5cm}|>{\centering}p{0.5cm}|>{\centering}p{0.5cm}|p{0.5cm}| }
\hline
A & B & C & $\varphi$ \\
\hline
\end{tabular}
\end{center}

and this is the result:

(I removed the other 8 lines of the code, because they were basically the same)

enter image description here

And now the thing is, the fourth column isn't centered and when I put >{\centering} before p{0.5cm}, exactly how I did on the first 3 columns, Tex would give me

enter image description here

Any ideas how to fix this?

Thanks.

VesDyl
  • 13
  • Welcome to TeX.SX! You need >{\centering\arraybackslash}p{0.5cm}. – Torbjørn T. Nov 19 '16 at 15:17
  • 4
    Essentially same thing as http://tex.stackexchange.com/questions/177333/array-package-problem-with-declarations-in-preamble-extra-alignment-tab-has/177335#177335 or http://tex.stackexchange.com/questions/7208/how-to-vertically-center-the-text-of-the-cells/7318#7318 – Torbjørn T. Nov 19 '16 at 15:20
  • @TorbjørnT. thank you so much! And thank you for not judging me for not knowing this, I just started using Latex and I'm eager to learn! Have a great day! – VesDyl Nov 19 '16 at 15:20

0 Answers0