0

Writing a latex document it is possible that a math-text is putted into two different lines but obviously this could be unpleasant so that I thought to confront with this using the following solution.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document} \noindent This is an example of unbroken line.

%\vspace{0.1cm}

\noindent
By the equation above we argue that the following equation (by Euler) $e^{i\pi}+1=0$ which is useful.

\vspace{1cm}

\noindent
This is an example of \textbf{manually} broken line

%\vspace{0.1cm}

\noindent
By the equation above we argue that the following equation (by Euler) 
\linebreak
$e^{i\pi}+1=0$ which is useful.

\end{document}

However I dislike it since it is not just automatic so that if I modify the text then I have to remember I inserted the command \linebreak which shall delete after edits: so this could cause many "errors" in a long document so that I thought to put here a specific question where I ask if there is some command to put into the preamble which do this automatically. So could someone help me, please?

  • you example is rather unnatural as tex can not break ......... it will break at word spaces (which you always have before inline math) or at + or = within the math. – David Carlisle Dec 26 '23 at 19:21
  • If you put the formula into an mbox, then it won't be broken across lines. – Ian Thompson Dec 26 '23 at 19:23
  • What is the actual content of the unbroken long line? A row of periods will never break on its own, so trying to guess how to help you is difficult. If your line really is an unbroken row of periods, have a look at one of these previous questions: Wrapping long lines that contain no spaces or How to get long \texttt sections to break – barbara beeton Dec 26 '23 at 19:24
  • @DavidCarlisle Sorry but I do not understand exactly what you want mean: it seems you are saying to me that there is not a text with so consecutive types, right? So, I can say you that the points I inserted wanted represent a possibile text as "With the equation eq. \eqref{} we saw that but this is not really sure now and so we hat to use the equation $$ which is more usefull", that's all. – Antonio Maria Di Mauro Dec 26 '23 at 19:25
  • 1
    but it is impossible to guess what you want here, you should have a space before inline math and it will linebreak at the space if needed. What is your actual question? A real document should not have \noindent or \vspace or .............. and all the issues with this example are just about those things, not about the math, – David Carlisle Dec 26 '23 at 19:27
  • to get a numbrered equation you can reference use \begin{equation} x=y \label{abc}\end{equation} .... see \eqref{abc} – David Carlisle Dec 26 '23 at 19:29
  • @DavidCarlisle I edit the code putting a more precise example. Anyway you are saying that I can put the command \begin{equation}\end{eqution} without put the equation at the center? – Antonio Maria Di Mauro Dec 26 '23 at 19:31
  • Thank you for the improved example. It seems that you need the spacing controls to be loosened. To do this globally, you can put \sloppy in the preamble. But this may also affect paragraphs that were acceptable before, and make them not as good looking. To limit the effect to just one paragraph, put \begin{sloppypar} at the beginning of the paragraph (before \noindent if that is present), and \end{sloppypar} at the end. Then the line breaking will be automatic. – barbara beeton Dec 26 '23 at 19:56
  • @barbarabeeton Hi, thanks for your suggest. I tried both the solution you proposed but nothing work: I hat to add any package to my code? – Antonio Maria Di Mauro Dec 26 '23 at 20:06
  • This answer: https://tex.stackexchange.com/a/393686 confirms my belief that sloppypar is a feature of basic LaTeX. But the answer also gives some examples that may help you understand it better. – barbara beeton Dec 26 '23 at 20:17

1 Answers1

2

You are probably looking for something like this where the {} prevents line breaking in the math

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{parskip}
\begin{document}
This is an example of unbreaked line.


By the equation above we aruge that the following equiation (by Euler) $e^{i\pi}+1=0$ which is usefull.


This is an example of \textbf{manually} breaked line


By the equation above we argue that the following equation (by Euler)
$e^{i\pi}+1=0$ which is useful.

By the equation above we argue that the following equation (by Euler)
${e^{i\pi}+1=0}$ which is useful.

\end{document}

but see also

Stop LaTeX from breaking an inline math equation

David Carlisle
  • 757,742