2

This question already has an answer here:

I want to have multiple lines with three sections: a left-justified column, a center-justified middle column, and a right-justified last column. For any line this is mostly done with \hfill. The problem is then center column is not center-justified, and I would like the center column to line up across different instances of these multi-columns lines. Also, there is other text between these lines so I can't use a single table.

The following .tex demonstrates the issue:

\documentclass{article}
\usepackage{tabularx}
\begin{document}


% one line, Column two floats in between one and three
\noindent Column one \hfill Column two \hfill Column three

    %multiple lines
\noindent Column one

    %this line is absolutely centered and is aligned with any other 
{\centering \textbf{Column two} \\}

\hfill Column three

Ea vero quando definiebas vix. Velit facete referrentur sit ei. Cu eam exerci labore expetendis. Vel an pertinax inciderint, at suas volumus scriptorem sea, at sed utroque perfecto consulatu. 

\noindent This column one is a bit longer \hfill Not lined up \hfill Column three changed

\noindent This column one is a bit longer

{\centering \textbf{Is lined up} \\}

\hfill Column three changed

\noindent This column one is a bit  longer \begin{center} no good \end{center} \hfill Column three changed

\noindent This column is a bit longer {\centering Not centered} \hfill Column three changed

% try with tables
\hrulefill

\noindent \begin{tabular*}{\textwidth}{lcr}
Column one & Column two & Column three \\
\hspace{0.30 \textwidth} & \hspace{0.30 \textwidth} & \hspace{0.30 \textwidth} 
\end{tabular*}

Ea everti utamur ullamcorper sed, id duo exerci ceteros apeirian, nam ex oratio prodesset. Cu summo oratio populo eum, in euismod sanctus mel, no accumsan explicari elaboraret his. 

\noindent \begin{tabular*}{\linewidth}{lcr}
This column one is a bit longer & New column two & Column three changed \\
\hspace{0.30 \linewidth} & \hspace{0.30 \linewidth} & \hspace{0.30 \linewidth} 
\end{tabular*}

\end{document}

For the first attempts using \hfill, the center column's are not aligned since the other columns are different. The second instances are lined up right (in bold), but span three lines instead of one. Several attempts to try to make a single line do not work.

I also tried using tables (below the \hrulefill) but it adds an extra vertical space I don't want, and I have to manually tweak the \textwidth multiplier to match the margins. In the worst case I could do this and add negative vspace, but I wonder if there is a better way?

marked as duplicate by Andrew Swann, Adam Liter, Mico, Przemysław Scherwentke, percusse Jun 24 '14 at 19:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

you can do this in three parts:

\noindent\rlap{left-justified text}\hfill
centered text\hfill
\llap{right-justified text}%

finish off with \\ if another line of text follows, or just a blank line for the end of a paragraph.

remember that if there isn't any text on the left, you need to put in a "stopper" so that the initial space doesn't disappear. \mbox{} is always a good stopper.

Not the answer you're looking for? Browse other questions tagged or ask your own question.