I want to have inline math text like
Figure \ref{figure:example graph} shows an example of a graph $G = (\{v_{1}, \dots, v_{5}\}, \{(v_{1}, v_{2}), (v_{2}, v_{3}), (v_{1}, v_{3}), (v_{2}, v_{5}), (v_{3}, v_{4}), (v_{4}, v_{5})\})$ with $|V| = n = 5$ vertices and $|E| = m = 6$ edges.
but then, LaTeX messes with the linebreak and the rendered text looks like in the attached screenshot.
Is there any way, I can tell LaTeX to break the formula within simple $'s?
Best Answer
The simplest way to cope with this is to define a new command for a breakable comma:
I'd prefer not to use
\bcomma
after the list of vertices and before the last edge, but in an emergency you can change also those.A more complex solution can be written with LaTeX3 facilities:
The
\mathlist
command has an optional argument (the item separator, default a comma); the first mandatory argument tells what to put in place of the separator, the second argument is the list.The first usage of
\mathlist
in the example is of course redundant; the second one isn't: since the comma is used in the ordered pairs, I choose a semicolon as separator and it's substituted after processing by,\allowbreak
as in the simpler definition above.If the list of edges is stored in a macro, the method above doesn't work. But the definition can be extended to cope with this case: