3

Why are there extra letters printed in the following title only when adding breqn package and how to get rid of them?

This shows up with texlive 2016 both pdflatex and lualatex

\documentclass[11pt,notitlepage]{article}

\usepackage{amsmath,mathtools}
\usepackage{breqn} %problem goes away when not using this. But I need this.

\usepackage{cprotect}
\begin{document}
\cprotect\title{\verb|1_Linear_products\1.2(a+bx)^m(c+dx)^n|}
\author{me}
\maketitle

test
\end{document}

Output is

Mathematica graphics

I tried the solution posted in why-does-luatex-plus-breqn-quadruple-output-of-text-when-in-display-math-mode But it did not resolve this.

I have to use verbatim in title. It is long story, but there is no other way. This is due to nature of titles being used.

Everythings works OK otherwise, but would like to get rid of those extra characters that show up at the end.

Here is the complete output with the list of files used

title_math>lualatex foo.tex
This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
 restricted system commands enabled.
(./foo.tex
LaTeX2e <2017/01/01> patch level 3
(using write cache: /home/me/.texlive2016/texmf-var/luatex-cache/generic)(using
 read cache: /usr/local/texlive/2016/texmf-var/luatex-cache/generic /home/me/.t
exlive2016/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.148 seconds
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size11.clo(load luc: /home/m
e/.texlive2016/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc))
) (/usr/local/texlive/2016/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2016/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2016/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2016/texmf-dist/tex/latex/mathtools/mathtools.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/tools/calc.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/mathtools/mhsetup.sty))
(/usr/local/texlive/2016/texmf-dist/tex/latex/breqn/breqn.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/local/texlive/2016/texmf-dist/tex/latex/breqn/flexisym.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/breqn/cmbase.sym)
(/usr/local/texlive/2016/texmf-dist/tex/latex/breqn/mathstyle.sty)))
(/usr/local/texlive/2016/texmf-dist/tex/latex/cprotect/cprotect.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/bigfoot/suffix.sty)) (./foo.aux)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-def/luatex.def
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(/usr/local/texlive/2016/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
))))(load luc: /home/me/.texlive2016/texmf-var/luatex-cache/generic/fonts/otl/l
mroman17-regular.luc) (./foo-1.cpt(load luc: /home/me/.texlive2016/texmf-var/lu
atex-cache/generic/fonts/otl/lmmono12-regular.luc))
Overfull \hbox (28.50626pt too wide) in paragraph at lines 1--11
 []\TU/lmtt/m/n/17.28 1_Linear_products\1.2(a+bx)^m(c+dx)^n\TU/lmr/m/n/17.28 ^^
E^^L 
(load luc: /home/me/.texlive2016/texmf-var/luatex-cache/generic/fonts/otl/lmrom
an12-regular.luc) [1{/usr/local/texlive/2016/texmf-var/fonts/map/pdftex/updmap/
pdftex.map}] (./foo.aux)

 *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)
 amsmath.sty    2016/11/05 v2.16a AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
mathtools.sty    2015/11/12 v1.18 mathematical typesetting tools
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
    calc.sty    2014/10/28 v4.3 Infix arithmetic (KKT,FJ)
 mhsetup.sty    2010/01/21 v1.2a programming setup (MH)
   breqn.sty    2017/01/27 v0.98e Breaking equations
   expl3.sty    2017/04/01 L3 programming layer (loader) 
expl3-code.tex    2017/04/01 L3 programming layer 
l3pdfmode.def    2017/03/18 v L3 Experimental driver: PDF mode
flexisym.sty    2017/01/27 v0.98e Make math characters macros
  cmbase.sym    2007/12/19 v0.92
mathstyle.sty    2017/01/27 0.98e Tracking mathstyle implicitly
cprotect.sty    2011/01/27 v1.0e (Bruno Le Floch)
  ifthen.sty    2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
  suffix.sty    2006/07/15 1.5a Variant command support
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2016/10/09 v1.0u Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  luatex.def    2017/01/12 v0.01h Graphics/Color for luaTeX
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
supp-pdf.mkii
 ***********

)
(see the transcript file for additional information)
 646 words of node memory still in use:
   6 hlist, 2 vlist, 2 rule, 21 glue, 1 kern, 16 attribute, 55 glue_spec, 16 at
tribute_list, 1 write nodes
   avail lists: 2:55,3:9,4:3,5:10,6:65,7:63,8:3,9:20,10:2
</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.
otf></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman12-regu
lar.otf></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmroman17-
regular.otf></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/lm/lmmono
12-regular.otf>
Output written on foo.pdf (1 page, 9835 bytes).
Transcript written on foo.log.
title_math>
Nasser
  • 20,220
  • Since you don't have any unbalanced braces of comment signs, this might be easier and doesn't suffer from the bug: \title{\texttt{\detokenize{1_Linear_products\1.2(a+bx)^m(c+dx)^n}}} – Henri Menke Jun 18 '17 at 01:11

1 Answers1

5

The cprotect package assumes that \catcode`^=7 when scanning for the delimiter ^^E^^L (no idea why Bruno chose this). However, breqn changes this to \catcode`^=12. Just restore the default when doing \maketitle and you are fine.

This behaviour is not unexpected. It is properly documented in the manual of both packages.

breqn

enter image description here

cprotect

enter image description here

I wouldn't recommend using breqn at all. It introduces a lot of incompatibilities with other packages and has a lot of special cases to deal with. In an upcoming version ConTeXt MKIV will introduce automatic linebreaking for formulas which will probably be much more robust because parsing is done on the Lua level and thus avoids confusions with catcodes and such.

\documentclass[11pt,notitlepage]{article}

\usepackage{amsmath,mathtools}
\usepackage{breqn} %problem goes away when not using this. But I need this.

\usepackage{cprotect}
\begin{document}
\cprotect\title{\verb|1_Linear_products\1.2(a+bx)^m(c+dx)^n|}
\author{me}
{\catcode`^=7 \maketitle}

test
\end{document}

enter image description here

Henri Menke
  • 109,596