Text Formattingnew line with math symbol

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
elkon
Posts: 1
Joined: Sun Dec 27, 2009 3:26 pm

new line with math symbol

Post by elkon »

Hi,
I am a newbie with latex so this may be a trivial question, but one I haven't found an answer for online.

I have a document with a macro:
\newcommand{\myVar}{hello\ensuremath{\wedge}goodbye}
When I use this macro, if \myVar is near the end of the line, the text (hello^goodbye) goes beyond the normal length of the line.
I would like this macro to automatically "jump" to a new line and not go beyond normal line length.
However, I do not want to change my macro because it is used in other places.

Thank you,
Eyal

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

new line with math symbol

Post by kaiserkarl13 »

The problem here is one of where to put line breaks. TeX typically prefers to have text overrun the right margin (as you're observing) rather than leave vast gaps between words (which is what Word and WordPerfect typically do). This is no different than doing something like,

Code: Select all

\mbox{here's my really long sentence that has no chance of not breaking it over a line yet it's forced to because of the mbox around it.}
If you don't like the line break, you'll be forced to re-write the sentence. You can tell it to break the line (if necessary) after the symbol, viz.

Code: Select all

\newcommand{\myVar}{hello\ensuremath{\wedge}\allowbreak{}goodbye}
Post Reply