I am trying to use a nice solution for one problem I have which is to break long math sequence with commas in them as given here allowing-line-break-at-in-inline-math-mode only to to find I get tex capacity exceeded when I put it in my main code which happens to also need the breqn package. There seems to be a conflict which is beyond my understanding to resolve. The solution works when I do not use the breqn package, but I need this package.

here is MWE

\usepackage{breqn}   %do not use this with tex4ht. 

%code from https://tex.stackexchange.com/questions/1959/allowing-line-break-at-in-inline-math-mode/309558#309558


pdflatex foo.tex

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2015/10/01> patch level 2
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/calc.sty)) (./foo.aux)
! TeX capacity exceeded, sorry [input stack size=5000].
,->\ifmmode \old@comma 
                       \discretionary {}{}{}\else \old@comma \fi 
l.18 $\frac{1}{2},
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on foo.log.

log file

Here is how much of TeX's memory you used:
 7740 strings out of 493054
 142814 string characters out of 8884759
 167252 words of memory out of 8000000
 11311 multiletter control sequences out of 15000+600000
 6379 words of font info for 23 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 5000i,3n,40p,10354b,275s stack positions out of 5000i,500n,10000p,30000000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!

Question is: What do I need to change to make the above macro works and still use breqn package?

  • 2
    Making the comma globally active is not really a great idea. – egreg May 14 '16 at 16:56

With breqn all characters are math active, so the solution is not going to work; but we can exploit the features of breqn:


  \begingroup\lccode`~=`, \lowercase{\endgroup
    \expandafter\def\expandafter~\expandafter{~\penalty0 \hspace{0pt plus 1em}}%


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



enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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