TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the inline math mode ($...$), if the formula is too long, LaTeX will try to break it on operators, e.g.

very long text followed by a very long equation like $a+b+c+d+e+f+g+h+i+j+k+l$ etc

may be rendered as

very long text followed
by a very long equation
like a+b+c+d+e+f+g+h+i+
j+k+l etc

However, the break won't happen if they are separated by commas, e.g.

very long text followed by a very long equation like $a,b,c,d,e,f,g,h,i,j,k,l$ etc

will overflow the page like

very long text followed
by a very long equation
like a,b,c,d,e,f,g,h,i,j,k,l

How to make LaTeX able to insert line breaks after a comma too?

share|improve this question
I tried breqn but it uses "expl3.sty" which can not be found by Latex ALTHOUGH I downloaded it and put in the same folder where breqn.sty exists! – Ahmad Jan 8 '11 at 22:09
@Ahmad: If you've got a question, then you should ask it in a new post. Please do this with the "Ask Question" link. In your new question you could link to this one. – Hendrik Vogt Jan 8 '11 at 22:09
@Ahmad: Just a note to confirm Hendrik's comment, this ought to be reposted as a question for you to get the best chance of it being answered. – Loop Space Jan 8 '11 at 22:09
up vote 64 down vote accepted

If the expression contains many commas then consider to break it into several math expressions, separated by commas. It reads like a list of math expressions. This way TeX can break the line.

To achieve line breaks after a comma, you could insert \allowbreak after the comma and before the next math symbol. If necessary, leave a blank after \allowbreak.

If you would like to have a document wide solution, you could redefine the comma. One solution, following the tip here would be:

share|improve this answer
Thanks. My expression is actually a set with 48 elements, so splitting them into several expressions may not sound mathematically logical. I will try \allowbreak. – kennytm Aug 18 '10 at 15:50
+1, excellent answer! However, there's a complication: Please see tex.stackexchange.com/q/19094/1347. – M.S. Dousti May 26 '11 at 9:51
Note that the \allowbreak solution does not work if you have \left...\right delimiters that span the break in your equation – Mosby Jan 7 at 15:45

You could take a look at the breqn package, which is aimed at solving this problem in a general sense.

share|improve this answer
Wow, breqn allows \left and \right to work across line breaks! – Mark Meckes Aug 18 '10 at 17:13
Indeed, amongst other things. The late Michael Downes was a very clever guy! – Joseph Wright Aug 18 '10 at 18:02
For commas, this does not work with all types of atoms. See the discussion here. – Ruben Verborgh Apr 26 '15 at 12:47

Here is a solution that doesn't make the comma globally active:


  \begingroup\lccode`~=`, \lowercase{\endgroup
    \edef~{\mathchar\the\mathcode`, \penalty0 \noexpand\hspace{0pt plus 1em}}%
  }\mathcode`,="8000 #1%


\setlength{\lineskiplimit}{2pt}\setlength{\lineskip}{3pt} % for this particular case



The setting of \lineskiplimit and \lineskip are for the particular case where fractions are needed in the argument.

enter image description here

share|improve this answer
@Nasser With breqn this is guaranteed not to work. Probably something can be done, I'll work on your problem later. – egreg May 14 at 16:59
Did you manage to find the workaround for breqn? – azetina Jul 13 at 13:51
@azetina I don't consider breqn a usable piece of software. – egreg Jul 13 at 14:15

If you can split the equation into several sub equation using $, and if you are using braces use \left. and \right. (with dot) to balance the braces.


 $X = \left\{\right.a$, $b$, $c$, $d\left.\right\}$

X = { a, b, c, d }

This should allow line breaks behind the commas.

share|improve this answer
You might as well just omit \left and \right. Putting the matching brace directly adjacent obviates any point to having scaling braces at all. – Kundor Mar 15 '14 at 18:36
disregarding the pointless \left and \right commands, ;) it is a quick workaround. – loved.by.Jesus Jun 6 at 10:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.