4

This is the smallest example I can come up which shows this problem. Latex complain about missing $ and the error is pointing to a line in code listing !

This problem can be resolved by doing 3 things: remove breqn package, or change the section title and remove the $ in it. or remove few lines from listing or verbatim to make the code smallers.

Because of the above, this problem seems related to tex-capacity-exceeded-compiling-only-50-lines-latex-file-pdftex-seg-fault-l but for some reason, the magic code I am using from the above is not making an effect on this case. So it might be a new issue.

MWE (smallest I could make it)

\documentclass[11pt]{book}%ext
\usepackage[T1]{fontenc}

\usepackage{amsmath,mathtools}
\usepackage[utf8]{inputenc} %DO NOT USE WIT LUALATEX, only with pdflatex
\usepackage{listings}
\usepackage{upquote} %to fix string quotes
\usepackage{breqn}   %do not use this with tex4ht.  added 4/2/16
                     %removing this package also fixes the problem

%see
%https://tex.stackexchange.com/questions/310625/tex-capacity-exceeded-compiling-only-50-lines-latex-file-pdftex-seg-fault-l
\makeatletter
\def\do@noligs#1{%
    \catcode`#1\active
    \begingroup\lccode`\~`#1\relax
    \lowercase{\endgroup
        \ifdefined~%
        \expandafter\def\expandafter~\expandafter{%
            \expandafter\relax
            \expandafter\ifmmode
            ~% in math mode use the meaning given by breqn
            \else
            \leavevmode\kern\z@\char`#1\relax
            \fi
        }%
        \else
        \def~{\leavevmode\kern\z@\char`#1}%
        \fi
    }%
}
\makeatother

\begin{document}
\section{$H(s)$} %remove $$ fixes the problem

\begin{lstlisting}
maxSimulationTime = 10;
samplePeriod      = 0.5;
tf = TransferFunctionModel[z/(z^2-1.4 z+0.5),
          z,
          SamplingPeriod->samplePeriod];

(*Find its impulse response*)
discreteResponse=First@OutputResponse[tf,DiscreteDelta[k],{k,0,maxSimulationTime}]
\end{lstlisting}

\begin{verbatim}
{0.,1.,1.4,1.46,1.344,1.1516,0.94024,0.740536,
0.56663,0.423015,0.308905,0.22096,0.154891,
0.106368,0.0714694,0.0468732,0.0298878,
0.0184063,0.0108249,0.00595175,0.00291999}
\end{verbatim}

approximate to continuous time, use ZeroOrderHold

\begin{lstlisting}
ctf = ToContinuousTimeModel[tf, s, Method -> "ZeroOrderHold"]
\end{lstlisting}

\begin{verbatim}
TransferFunctionModel[{
 {{5.6099211033954965 + 1.255589621432896*s}}, 
 0.5609921103395501 +1.3862943611198901*s +s^2}, 
 s,SamplingPeriod -> None,
 SystemsModelLabels -> None]
\end{verbatim}

Find the impulse response of the continuous time system

\begin{lstlisting}
continouseTimeResponse=Chop@First@OutputResponse[ctf,DiracDelta[t],
                                         {t,0,maxSimulationTime}]
\end{lstlisting}

\begin{verbatim}
(19.767574172152145*HeavisideTheta[t]*
  Sin[0.2837941092083292*t])/E^(0.6931471805599452*t) + 
  (1.255589621432896*(0.9999999999999996*Cos[0.2837941092083292*t]*
   HeavisideTheta[t] - 2.4424297688685117*HeavisideTheta[t]*
  Sin[0.2837941092083292*t]))/E^(0.6931471805599452*t)
\end{verbatim}

Plot the impulse response of the discrete system

\begin{lstlisting}
ListPlot[
discreteResponse,
DataRange->{0,maxSimulationTime},
Filling->Axis,
FillingStyle->{Red,
  PlotMarkers->Graphics[{PointSize[0.03],
  Point[{0,0}]}]},PlotRange->All,
  ImageSize->300,ImagePadding->{{45,10},{35,10}},
  AspectRatio->0.9,AxesOrigin->{0,0},Frame->True,Axes->None,ImageSize->300,
  Frame->True
  ]
\end{lstlisting}

\end{document}

Error is

pdflatex foo2.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./foo2.tex
LaTeX2e <2015/10/01> patch level 2
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/book.cls
Document Class: book 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/bk11.clo))
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/mathtools/mathtools.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/calc.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/mathtools/mhsetup.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.dfu)
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ot1enc.dfu)
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omsenc.dfu)))
(/usr/local/texlive/2015/texmf-dist/tex/latex/listings/listings.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/listings/lstmisc.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/listings/listings.cfg))
(/usr/local/texlive/2015/texmf-dist/tex/latex/upquote/upquote.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/textcomp.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.def
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.dfu))))
(/usr/local/texlive/2015/texmf-dist/tex/latex/breqn/breqn.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2015/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/breqn/flexisym.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/breqn/cmbase.sym)
(/usr/local/texlive/2015/texmf-dist/tex/latex/breqn/mathstyle.sty)))
(./foo2.aux) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
))) (/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)))
Overfull \hbox (175.68887pt too wide) in paragraph at lines 45--46
[][][][][][][][][][][][][][][][] 
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1cmtt.fd)
Overfull \hbox (38.50026pt too wide) in paragraph at lines 59--60
[][][][][][][][][][][][][][][][][][][][][] 

Overfull \hbox (77.697pt too wide) in paragraph at lines 73--74
[][][][][][][][][][][][] 

Overfull \hbox (64.63142pt too wide) in paragraph at lines 74--75
[][][][][][][][] 

Overfull \hbox (19.11086pt too wide) in paragraph at lines 83--83
[]  \T1/cmtt/m/n/10.95 (1.255589621432896*(0.9999999999999996*Cos[0.28379410920
83292*t]*[] 
! Missing $ inserted.
<inserted text> 
                $
l.91 Filling-
             >Axis,
? 
Here is how much of TeX's memory you used:
 12377 strings out of 493054
 208082 string characters out of 8884759
 241996 words of memory out of 8000000
 15806 multiletter control sequences out of 15000+600000
 12210 words of font info for 37 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 51i,6n,40p,10355b,1641s stack positions out of 5000i,500n,10000p,30000000b,80000s
No pages of output.
PDF statistics:
 0 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

closed as off-topic by siracusa, Troy, Stefan Pinnow, TeXnician, dexteritas Aug 30 '18 at 11:22

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Have you tried to \protect your $H(s)$ inside \section? – Marcelo Ventura May 30 '16 at 8:40
  • 2
    @MarceloVentura , yes \protect removed the error. I think this is similar as removing $$ directly which also removes the error. Also removing few lines of code removes the error. Also removing breqn package removes the error. Thank you. – Nasser May 30 '16 at 8:48
  • 1
    It looks like you want to show Mathematica code. You might want to have a look at mmacells. – Henri Menke May 30 '16 at 9:23
  • 1
    Do you need breqn? Without it the code compiles fine… – clemens Feb 7 '17 at 13:52
  • 4
    I'm voting to close this question as off-topic because the problem was solved in the comments. – siracusa Aug 29 '18 at 23:39

Browse other questions tagged or ask your own question.