Graphics, Figures & TablesPutting wide Table in Center of Page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
isharp2
Posts: 23
Joined: Fri Feb 11, 2011 2:06 am

Putting wide Table in Center of Page

Post by isharp2 »

Hi, I'm trying to put a table in the center of the page so that both sides of the table are equidistant to the side borders of the paper.

I tried both \centering and \begin{center}, but the table just trails off to the right.

Code: Select all

\documentclass{article}
\usepackage{tabularx}
\usepackage{multirow}

\begin{document}

\begin{center}
\begin{table}[h!]
\centering

\begin{tabularx}{6in}{ |   X |  X |  X |  X |  }
  \hline

  \multicolumn{4}{|l|}{Topic} \\ \hline
  \multicolumn{2}{|c|}{plan 1}  & \multicolumn{2}{c|}{plan 2}  \\ \hline

  \multicolumn{2}{|p{3in}|}{Do this} & \multicolumn{2}{ p{3in}|}{Do that.} \\ \hline
-
  Pros & Cons & Pros & Cons \\ \hline
  \begin{minipage}{1.5in}
    \vskip 4pt
    \begin{itemize}
   \item A
   \item B
   \end{itemize}
   \vskip 4pt
 \end{minipage}

  & 
  \begin{minipage}{1.5in}
    \vskip 4pt
    \begin{itemize}
   \item This is item 1
   \item This is item 2
   \end{itemize}
   \vskip 4pt
 \end{minipage}

  &

\begin{minipage}{1.5in}
    \vskip 4pt
    \begin{itemize}
   \item ctrl+alt+delete
   \item ctrl+v
   \end{itemize}
   \vskip 4pt
 \end{minipage}

  & 
  \begin{minipage}{1.5in}
    \vskip 4pt
    \begin{itemize}
   \item C
   \end{itemize}
   \vskip 4pt
 \end{minipage}

 \\
  \hline

\end{tabularx}

\end{table}
\end{center}



\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Putting wide Table in Center of Page

Post by localghost »

There's a quite simple trick by the \makebox command.

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[tableposition=top]{caption}
\usepackage{tabularx}

\begin{document}
  \begin{table}[!ht]
    \caption{Table caption}
    \makebox[\linewidth]{
    \begin{tabularx}{6in}{|X|X|X|X|}\hline
      \multicolumn{4}{|l|}{Topic} \\ \hline
      \multicolumn{2}{|c|}{plan 1}  & \multicolumn{2}{c|}{plan 2}  \\ \hline
      \multicolumn{2}{|l|}{Do this} & \multicolumn{2}{l|}{Do that.} \\ \hline
      Pros & Cons & Pros & Cons \\ \hline
      \begin{itemize}
        \item A
        \item B
      \end{itemize}
      &
      \begin{itemize}
        \item This is item 1
        \item This is item 2
      \end{itemize}
      &
      \begin{itemize}
        \item ctrl+alt+delete
        \item ctrl+v
      \end{itemize}
      &
      \begin{itemize}
        \item C
      \end{itemize}
      \\\hline
    \end{tabularx}
    }
  \end{table}
\end{document}
I simplified the code of your table a bit. It gives the same result.


Thorsten
NoobNoob
Posts: 1
Joined: Fri Sep 23, 2022 4:34 am

Putting wide Table in Center of Page

Post by NoobNoob »

10 years later and this answer is still really helpful!
Post Reply