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.

  1. \documentclass{article}
  2. \usepackage{tabularx}
  3. \usepackage{multirow}
  4.  
  5. \begin{document}
  6.  
  7. \begin{center}
  8. \begin{table}[h!]
  9. \centering
  10.  
  11. \begin{tabularx}{6in}{ | X | X | X | X | }
  12. \hline
  13.  
  14. \multicolumn{4}{|l|}{Topic} \\ \hline
  15. \multicolumn{2}{|c|}{plan 1} & \multicolumn{2}{c|}{plan 2} \\ \hline
  16.  
  17. \multicolumn{2}{|p{3in}|}{Do this} & \multicolumn{2}{ p{3in}|}{Do that.} \\ \hline
  18. -
  19. Pros & Cons & Pros & Cons \\ \hline
  20. \begin{minipage}{1.5in}
  21. \vskip 4pt
  22. \begin{itemize}
  23. \item A
  24. \item B
  25. \end{itemize}
  26. \vskip 4pt
  27. \end{minipage}
  28.  
  29. &
  30. \begin{minipage}{1.5in}
  31. \vskip 4pt
  32. \begin{itemize}
  33. \item This is item 1
  34. \item This is item 2
  35. \end{itemize}
  36. \vskip 4pt
  37. \end{minipage}
  38.  
  39. &
  40.  
  41. \begin{minipage}{1.5in}
  42. \vskip 4pt
  43. \begin{itemize}
  44. \item ctrl+alt+delete
  45. \item ctrl+v
  46. \end{itemize}
  47. \vskip 4pt
  48. \end{minipage}
  49.  
  50. &
  51. \begin{minipage}{1.5in}
  52. \vskip 4pt
  53. \begin{itemize}
  54. \item C
  55. \end{itemize}
  56. \vskip 4pt
  57. \end{minipage}
  58.  
  59. \\
  60. \hline
  61.  
  62. \end{tabularx}
  63.  
  64. \end{table}
  65. \end{center}
  66.  
  67.  
  68.  
  69. \end{document}
  70.  

User avatar
localghost
Site Moderator
Posts: 9204
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.
  1. \documentclass{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[tableposition=top]{caption}
  4. \usepackage{tabularx}
  5.  
  6. \begin{document}
  7. \begin{table}[!ht]
  8. \caption{Table caption}
  9. \makebox[\linewidth]{
  10. \begin{tabularx}{6in}{|X|X|X|X|}\hline
  11. \multicolumn{4}{|l|}{Topic} \\ \hline
  12. \multicolumn{2}{|c|}{plan 1} & \multicolumn{2}{c|}{plan 2} \\ \hline
  13. \multicolumn{2}{|l|}{Do this} & \multicolumn{2}{l|}{Do that.} \\ \hline
  14. Pros & Cons & Pros & Cons \\ \hline
  15. \begin{itemize}
  16. \item A
  17. \item B
  18. \end{itemize}
  19. &
  20. \begin{itemize}
  21. \item This is item 1
  22. \item This is item 2
  23. \end{itemize}
  24. &
  25. \begin{itemize}
  26. \item ctrl+alt+delete
  27. \item ctrl+v
  28. \end{itemize}
  29. &
  30. \begin{itemize}
  31. \item C
  32. \end{itemize}
  33. \\\hline
  34. \end{tabularx}
  35. }
  36. \end{table}
  37. \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: Google [Bot] and 6 guests