TransWikia.com

How do I make a line stretch before line break?

TeX - LaTeX Asked on July 23, 2021

I want to break before the equation to ensure it doesn’t end up on two lines:

Words words words words words words words words words words words words words words
words words words words words words words words $equation = equation$.

However, I don’t want the resulting "right-indent" on the second line:

enter image description here

How do I make the line stretch?

2 Answers

You want to use =nolinebreak.

documentclass{article}
usepackage{indentfirst}

begin{document}

subsubsection*{Bad, with texttt{string}}

Words words words words words words words words words words words words words words
words words words words words words words words $equation = equation$.

subsubsection*{Slightly better, with texttt{stringlinebreak}}

Words words words words words words words words words words words words words words
words words words words words words words words linebreak $equation = equation$.

subsubsection*{Even better, with texttt{stringnolinebreak}}

Words words words words words words words words words words words words words words
words words words words words words words words $equation =nolinebreak equation$.

subsubsection*{Even better, with texttt{stringnolinebreak}}

begin{sloppypar}
Words words words words words words words words words words words words words words
words words words words words words words words $equation =nolinebreak equation$.
end{sloppypar}

end{document}

enter image description here

You might object that =nolinebreak doesn't achieve the result. Actually it does! You may sometimes get an overfull line and in this case you can exercise your judgment in order to fix the typesetting:

  1. change wording,
  2. display the equation,
  3. accept the line break after =, or
  4. use sloppypar as a last resort as in the fourth example.

Can you see a difference between the second and fourth examples? Not in this case, actually, but changing the class might show one.

This is the output with amsart, for instance.

enter image description here

Can you spot the difference now?

I'm not saying you must use sloppypar. It should be the last resort; rewording is usually the best strategy and chances are that no action is required if the equation is not too wide and the paragraph is long enough.

Correct answer by egreg on July 23, 2021

If you really want that then use linebreak not

Answered by David Carlisle on July 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP