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,

2) consectetur adipisicing elit,

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
    Commented Jan 23, 2014 at 19:28

2 Answers 2


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

Here is an example:



\justifytwo{Lorem ipsum dolor sit amet et amet et amet,}
           {consectetur adipisicing elit,}



Without explicit measuring it can be done in a tabular:

    Lorem ipsum dolor sit amet,\hfilneg\null\\
    consectetur adipisicing elit,\hfilneg\null\\



  • \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:

  Lorem ipsum dolor sit amet,\cr
  consectetur adipisicing elit,\cr


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

You must log in to answer this question.

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