# Two lines ending where the longest one ends

I would like to have two consecutive lines of text where the shortest line is justified so that it ends at the end of the other, i.e. both lines should end at the end of the longest one. How can I do this?

Here is an example of what I would like. Imagine you have these two lines:

1) Lorem ipsum dolor sit amet,

These lines are similar, but they do not end perfectly at the same point. I would like that the shortest line, in this case the second, is justified so that it ends at the same point of the first. I tried something with the environment tabular, but I'm not able to obtain the desired result. :(

• What have you tried? If you're writing a document in LaTeX, this is the default behavior, unless I'm misunderstanding what you're asking ... ? Could you clarify and/or provide a minimal working example (MWE)? Also, welcome to TeX.SX! – Adam Liter Jan 23 '14 at 19:28

You can use \makebox with the optional s parameter (for stretch) to align the two lines.

Here is an example:

\documentclass{article}
\usepackage{calc}

\newcommand{\justifytwo}[2]{
\makebox[\maxof{\widthof{#1}}{\widthof{#2}}][s]{#1}\par
\makebox[\maxof{\widthof{#1}}{\widthof{#2}}][s]{#2}}

\begin{document}
\justifytwo{Lorem ipsum dolor sit amet et amet et amet,}
\end{document}


Without explicit measuring it can be done in a tabular:

\documentclass{article}
\begin{document}
\begin{tabular}{l}
Lorem ipsum dolor sit amet,\hfilneg\null\\
\end{tabular}
\end{document}


Remarks:

• \hfilneg cancels the \hfil that is inserted at the right side of the column with type l.

• \null ensures that \hfilneg survives the internally added \unskip at the end of the cell contents.

## plain TeX

In plain TeX it is even simpler, using \halign directly:

\noindent
\halign{#\cr
Lorem ipsum dolor sit amet,\cr

• I learn't something new today, \hfilneg. Interesting! :-) – azetina Jan 23 '14 at 19:52