2

If I have a dollar each time I find a conflict between Latex packages I would be a rich man.

I added \usepackage[low-sup]{subdepth} and now I am starting to get errors from matlab-prettifier when reading some Matlab code.

If I remove subdepth the error goes away. If I keep subdepth but remove breqn the error goes away also. But I'd like to use both these three packages in the same Latex file.

Here is a MWE

\documentclass[11pt]{article}%
\usepackage{matlab-prettifier}
\usepackage{breqn}   %do not use this with tex4ht.  added 4/2/16
\usepackage[low-sup]{subdepth} %added 4/29/16 to lower subscript
\begin{document}
\begin{lstlisting}
J = 8*u1-4
\end{lstlisting}
\end{document}

The error is pdflatex foo.tex

(/usr/local/texlive/2015/texmf-dist/tex/latex/subdepth/subdepth.sty) (./foo.aux
) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
! Missing { inserted.
<to be read again> 
                   \global 
l.10 J = 8*u1-4

? 

I can fix this by changing my Matlab code, from J = 8*u1-4 to J = 8*u1+4 but this will make my Matlab code produce wrong results, and I'd like to keep Matlab code as is, but still load it in Latex.

File list

*File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size11.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
matlab-prettifier.sty    2014/06/19 v0.3 A package for prettyprinting Matlab so
urce code
textcomp.sty    2005/09/27 v1.99g Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
listings.sty    2015/06/04 1.6 (Carsten Heinz)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
 lstmisc.sty    2015/06/04 1.6 (Carsten Heinz)
listings.cfg    2015/06/04 1.6 listings configuration
   breqn.sty    2015/08/11 v0.98d Breaking equations
   expl3.sty    2015/12/20 v6326 L3 programming layer (loader) 
expl3-code.tex    2015/12/20 v6326 L3 programming layer 
l3pdfmode.def    2015/11/11 v6250 L3 Experimental driver: PDF mode
flexisym.sty    2015/08/11 v0.98d Make math characters macros
  cmbase.sym    2007/12/19 v0.92
mathstyle.sty    2015/08/11 v0.98d Tracking mathstyle implicitly
    calc.sty    2014/10/28 v4.3 Infix arithmetic (KKT,FJ)
subdepth.sty    2007/09/02 v0.1 Unify subscript depths
  ts1cmr.fd    2014/09/29 v2.5h Standard LaTeX font definitions
supp-pdf.mkii
 ***********

TL 2015

2
  • Well, you're loading the mother of all package conflicts, that is, breqn. ;-)
    – egreg
    Commented May 18, 2016 at 6:25
  • @egreg Sure, but I am not doing any math! I am just reading Matlab code, so why would breqn conflict with subdepth with lstlisting? But I admit I have no idea what these packages do under the cover.
    – Nasser
    Commented May 18, 2016 at 6:38

1 Answer 1

3

The subdepth package changes some \fontdimen parameters for the math fonts and it has to do it when those fonts are first loaded. In your case, the first loading happens during initialization of lstlisting and the combination between this step, the needed setup for subdepth and the presence of breqn that changes the meaning of all characters in math, breaks.

If you have a formula before lstlisting, this doesn't happen, because subdepth does its work at font initialization. So adding

\sbox0{$$}

just after \begin{document} will help.

Be careful that you need to load math fonts in advance also when doing font size changes such as \footnotesize (if you have lstlisting in that context, of course).

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .