LaTeX forum ⇒ Graphics, Figures & TablesPutting wide Table in Center of Page Topic is solved

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

Putting wide Table in Center of Page

Postby isharp2 » Fri Apr 06, 2012 6:11 pm

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.

\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}


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

Postby localghost » Fri Apr 06, 2012 6:34 pm

There's a quite simple trick by the \makebox command.
\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
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 6 guests