3

I currently have a table which has 2 columns: the left one is right-justified and the right one is left-justified. I'd like to center the table relative to between the two columns: that is, have the divider between the 2 columns in the center of the page. How would I do this?

1
  • Can you post an example of the table and the current column specifications you use?
    – Werner
    Commented May 26, 2012 at 1:48

1 Answer 1

2

Here's one way of doing it if you know the widths of the columns (via a paragraph style):

enter image description here

\documentclass{article}
\usepackage{showframe}% http://ctan.org/pkg/shoframe
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\noindent
\makebox[\linewidth][c]{%
\hspace*{5cm}%
\begin{tabular}{p{4cm}|p{5cm}}
  \raggedleft\lipsum[2] & \raggedright\lipsum[3]
\end{tabular}%
\hspace*{4cm}%
}
\end{document}

The idea is that you place everything in a centred box with column-equivalent spaces around it. In the above example, showframe was used to identify the text block boundaries and highlight the tabular alignment.

The above would also hold without problem if you currently have an r|l column specification. In that instance, rather use

\usepackage{array}% http://ctan.org/pkg/array
%...
\noindent
\begin{tabular}
  {>{\raggedleft\arraybackslash}p{\dimexpr.5\linewidth-2\tabcolsep-.5\arrayrulewidth}|
   >{\raggedright\arraybackslash}p{\dimexpr.5\linewidth-2\tabcolsep-.5\arrayrulewidth}}
  % <tabular content>
\end{tabular}

The additional \arraybackslash corrects the usage of \\, redefined by formatting commands like \raggedleft and \raggedright (amongst others).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .