142

I have got a simple code to generate table in Latex.

\begin{tabular}{ | c | c | c | }
  \hline
  symbol & value & unit \\ \hline            
  $z Na$ & 11 & - \\ \hline      
  $z F$ & 9 & - \\ \hline      
  $Emax Na$ & 0.545 & $[MeV]$ \\ \hline
\end{tabular}

This code is good, but I would like to add this table to my document in Latex and have this table centered. The point is that table would be in the middle not on the left nor on the right but in the middle. I tried this, but it didn't work:

\{center}
\begin{tabular}{ | c | c | c | }
  \hline
  symbol & value & unit \\ \hline            
  $z Na$ & 11 & - \\ \hline      
  $z F$ & 9 & - \\ \hline      
  $Emax Na$ & 0.545 & $[MeV]$ \\ \hline
\end{tabular}
\{\center}

I appreciate the answer.

1
  • 5
    You need \begin{center} ... \end{center} rather than \{center} .. \{\center}.
    – Aditya
    Jun 11, 2015 at 15:25

2 Answers 2

176

You can just add \centering right after \begin{table} to center the table:

\begin{table}
\centering
\begin{tabular}
...
\end{tabular}
\end{table}

As commented by @PeterGrill, if you are not using floats (i.e., \begin{table}, \end{table}), then you will need to group it:

{
\centering
\begin{tabular} 
... 
\end{tabular}\par
} 

Note that \par and the extra {}.

10
  • Unfortunately it doesn't work: \begin{tabular}{ | c | c | c | } \centering \hline symbol & value & unit \\ \hline $z Na$ & 11 & - \\ \hline $z F$ & 9 & - \\ \hline $Emax Na$ & 0.545 & $[MeV]$ \\ \hline \end{tabular}
    – user1519221
    Feb 25, 2014 at 21:07
  • 8
    The \centering should be outside of \begin{tabular} ... \end{tabular}. If you are not using floats (i.e., \begin{table}, \end{table}), then you will need to group it: {\centering\begin{tabular} ... \end{tabular}} (note the extra {}). Feb 26, 2014 at 9:07
  • 8
    The second option does not appear to work. I would like to include a tabular environment without using floats, but centering it. May 1, 2015 at 19:55
  • 4
    If the second option doesn't work for you, try \begin{center} \end{center} instead of { } as mentioned in @Walton's answer. May 5, 2019 at 10:28
  • 5
    You must use \par before closing the group with }. source So, it'll be {\centering \begin{tabular}...\end{tabular} \par }
    – burny
    Nov 19, 2021 at 21:43
48

You can also use \begin{center} ... \end{center}. This works better with beamer for example because {\centering ... } messes with the size of the table for some reason. The new code would be:

\begin{center}
\begin{tabular}{ | c | c | c | }
  \hline
  symbol & value & unit \\ \hline
  $z Na$ & 11 & - \\ \hline
  $z F$ & 9 & - \\ \hline
  $Emax Na$ & 0.545 & $[MeV]$ \\ \hline
\end{tabular}
\end{center}

More on the difference between \begin{center} and \centering:
When should we use \begin{center} instead of \centering?

3
  • The OP does not mention beamer at all? Why do you think that \begin{center}...\end{center} is better?
    – user31729
    Jun 11, 2015 at 14:39
  • 13
    I brought up beamer as an example of a difference I noticed. I don't necessarily think it's better for this situation, but no one has mentioned it as an option yet.
    – Walton
    Jun 11, 2015 at 14:55
  • 5
    {\centering ... } doesn't center the table for me - and \begin{center}...\end{center} adds a huge margin around the top/bottom of the table.
    – Ela782
    Apr 14, 2021 at 10:27

You must log in to answer this question.