3

How do I automatically break the line before mathematical expression without using \\

Minimal example:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}

\begin{document}

text text text text text text text text text text text text text $f:A \to B; f(x) = 
x^2 + x + 1$ text text text text text text text text text $p(x) = \{ a_0  + a_1 x +
a_2 x^2  + a_3 x^3  +  \ldots  + a_n x^n \}$ text text text text text text text text
text text

\end{document}

Result:

Output of code

But, I need:

Desired output

Remember: I need automatically, without \\.

8

put it into braces and use sloppypar.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{sloppypar}
text text text text text text text text text text text text 
text ${f:A \to B; f(x) = x^2 + x + 1}$ text text text text 
text text text text text 
${p(x) = \{ a_0  + a_1 x + a_2 x^2  + a_3 x^3  +  \ldots  + a_n x^n \}}$ text 
text text text text text text text text text
\end{sloppypar}

\end{document}

If you want it document wide, than write into the preamble relpenalty=9999 binoppenalty=9999. Then you do not need the braces. However, than it will never be broken, which is not a good idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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