0

I would like to avoid that ANY inline equation starts on left the margin.

The solution I have for that right now is to compile the document, check where this happened and add a ~ in front of the inline equation and then recompile. But this is quite annoying.

This

\documentclass{minimal}
\begin{document}
iada iada iada iada iada iada iada iada iada iada iada iada iada iada 
iada iada iada iada iada iada $2+2=4$ iada iada iada
\end{document}

would produce a break as

iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada 
2+2=4 iada iada iada

But I rather a similar effect as here (only without having to include the ~ everytime!)

\documentclass{minimal}
\begin{document}
iada iada iada iada iada iada iada iada iada iada iada iada iada iada 
iada iada iada iada iada iada~$2+2=4$ iada iada iada
\end{document}

which would give

iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada iada  
iada 2+2=4 iada iada iada
  • 3
    What is the problem with equations touching the left margin? – kiss my armpit Oct 30 '13 at 17:33
  • Inline equations often break the flow of the text. Avoiding this can thus make the text easier to read. – andrecb Oct 31 '13 at 14:32
3

Provided that I agree with Marienplatz's comment, this is a simple attempt to achieve what you want, but you have to use a new command \inline{...} instead of $...$:

\documentclass{minimal}

\newcommand{\inline}[1]{%
\nolinebreak$#1$%
}

\begin{document}
iada iada iada iada iada iada iada iada iada iada iada iada iada iada
iada iada iada iada iada iada \inline{2+2=4} iada iada iada

iada iada iada iada iada iada iada iada iada iada iada iada iada iada
iada iada iada iada iada \inline{2+2=4} iada iada iada
\end{document} 

Output:

enter image description here


EDIT

I don't think that redefining $...$ is a good practice.

Anyway, you can do that by adding the following lines to your preamble (DISCLAIMER: I don't know if this can cause any other problem... Surely you don't have to use $$...$$ but \[...\] instead):

\makeatletter
\let\inline=$
\catcode`\$=\active
\protected\def$#1${%
  \nolinebreak\inline#1\inline%
}
\makeatother

so that the MWE

\documentclass{minimal}

\makeatletter
\let\inline=$
\catcode`\$=\active
\protected\def$#1${%
  \nolinebreak\inline#1\inline%
}
\makeatother

\begin{document}
iada iada iada iada iada iada iada iada iada iada iada iada iada iada
iada iada iada iada iada iada $2+2=4$ iada iada iada

iada iada iada iada iada iada iada iada iada iada iada iada iada iada
iada iada iada iada iada $2+2=4$ iada iada iada
\end{document} 

produces the same result as the above image.

  • Thanks for the answer. Do you think it is possible to redefine the standard $...$ to do just that? I would like to avoid changing to inline{...}in already existing documents. – andrecb Oct 31 '13 at 14:35
  • @andrecb I won't do that... but see the edited answer. – karlkoeller Oct 31 '13 at 15:49
  • @andrecb Does my answer is what you were looking for? If yes, please consider accepting the answer (see How do you accept an answer?). – karlkoeller Oct 31 '13 at 17:58
  • sorry karlkoeller, I am just too much of a noob on this thing. your answer was just what I needed! thanks! – andrecb Nov 5 '13 at 12:28

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.