Search code examples
latex

Center table and make one row different


I've got a table like:

\begin{center} 
\begin{table} [h]
\caption{some caption.} 
    \label{tab: 1}
\begin{tabular}{||c | c c c c c||}
 \hline
Team &Goal& SOG& SA& Hits& Possession\\ 
 \hline\hline
 \textbf{Team1} & 54 & 171 &    464 & 941 & 11:46:33
 \\ 
 \hline
 \textbf{Team2} & 89 & 237 & 502 & 861 & 10:28:02 \\ 
\hline \hline
Per cent split\\
 \hline \hline
 \textbf{Team1}&  38\% &    42\% &  48\% &  52\% &  53\%  \\
  \hline
  \end{tabular}
  \end{table}
\end{center}

And I cannot seem to center it. I've wrapped it in a \center but it still pushes to the left of the page. I am also wondering how to alter the row with Per cent split: ideally I'd want the text centered on the row and the row to end in the same manner that the table does, right now it does not do that.

Thanks


Solution

  • You center instructions must be within the table environment. However you shouldn't use the center environment. This will add additional vertical spacing. You should use \centering instead.

    \documentclass{article}
    
    \begin{document}
    
    %\begin{center} 
    \begin{table} [h]
    \caption{some caption.} 
        \label{tab: 1}
        \centering
    \begin{tabular}{||c | c c c c c||}
     \hline
    Team &Goal& SOG& SA& Hits& Possession\\ 
     \hline\hline
     \textbf{Team1} & 54 & 171 &    464 & 941 & 11:46:33
     \\ 
     \hline
     \textbf{Team2} & 89 & 237 & 502 & 861 & 10:28:02 \\ 
    \hline \hline
    \multicolumn{6}{||c||}{Per cent split}\\
     \hline \hline
     \textbf{Team1}&  38\% &    42\% &  48\% &  52\% &  53\%  \\
      \hline
      \end{tabular}
      \end{table}
    %\end{center}
    
    
    \end{document}
    

    enter image description here