[Tex/LaTex] how to write more words on the same line


Is there any way to write the number 37 from the below image on the same line with equal sign?

enter image description here

\textbf{3.} Afla\c ti de\^ imp\u ar\c titul \c stiind c\u a \^ intre \^ imp\u ar\c titor, c\^ at \c si rest avem rela\c tia $i^2+c^2+r^2=37$.


Best Answer

Rather than enclosing the math formula inside \mbox, as John Kormylo suggests, I’d define a command that prohibits line breaks inside a math formula. Indeed, this allows the glue inside the formula to stretch and shrink together with other glue on the same line, whereas John’s solution does not.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.


    \binoppenalty \@M
    \relpenalty \@M

\hyphenpenalty = \@M % ONLY for this example: DO NOT INCLUDE IN YOUR DOCUMENTS!



Some meaningless text, inserted just to get near\ldots\ the end of the line.
\( x+y=a+b\prohibitmathbreaks \).
And some more random text that adds other lines, which~contain~an unbreakable
sequence of words, to show that the spaces inside the formula \emph{are} allowed
to shrink.

On the other hand, if one uses the \verb|\mbox| solution, this does not happen:
\mbox{\( x+y=a+b \).}
And: some more random text that adds other lines, which~contain 

Another paragraph, containing another formula, in order to show that the effect
of our \verb|\prohibitmathbreaks| command is kept local:
\( a+b+c+d+e = x+y+z \).



Output of the code

Related Question