Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 \\.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
    
Thanks Herbert! –  Regis da Silva Aug 21 '11 at 20:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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