9

PdfLateX hangs on a single-line unnumbered equation,

here is a (possibly) minimal example:

\documentclass[english,pointlessnumbers, abstracton, headsepline, open=any]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3cm,headsep=3cm}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{babel}
\usepackage{prettyref}
\usepackage{refstyle}
\usepackage{float}
\usepackage{units}
\usepackage{textcomp}
\usepackage{url}
\usepackage{amsmath}
\usepackage{makeidx}
\makeindex
\usepackage{graphicx}
\usepackage{esint}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\usepackage{nomencl}
% the following is useful when we have the old nomencl.sty package
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature
\usepackage[unicode=true,
 bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=4,
 breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]
 {hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.

\let\pr@chap=\pr@cha
\AtBeginDocument{\providecommand\figref[1]{\ref{fig:#1}}}
\AtBeginDocument{\providecommand\secref[1]{\ref{sec:#1}}}
\AtBeginDocument{\providecommand\eqref[1]{\ref{eq:#1}}}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
\RS@ifundefined{subref}
  {\def\RSsubtxt{section~}\newref{sub}{name = \RSsubtxt}}
  {}
\RS@ifundefined{thmref}
  {\def\RSthmtxt{theorem~}\newref{thm}{name = \RSthmtxt}}
  {}
\RS@ifundefined{lemref}
  {\def\RSlemtxt{lemma~}\newref{lem}{name = \RSlemtxt}}
  {}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
% Special symbols as (c), �
\usepackage{textcomp}

% Custom enumeration lists
\usepackage{enumerate}

% Line spacing
% \usepackage{setspace}
% \usepackage[onehalfspacing]{setspace}
\usepackage[doublespacing]{setspace}

\usepackage{        %a4wide,
            ellipsis, fixltx2e, mparhack,       % correct errors with margins
            booktabs, longtable                 % better tables
}  

\usepackage[automark]{scrpage2}     % Page number at bottom right
\automark[chapter]{chapter}
\clearscrheadfoot
\ohead{\\\headmark}     % Paragraph heading
\ofoot[\pagemark]{\pagemark}
\setheadsepline{1pt}    % Header bottom line
\setfootsepline{0pt}    % Footnote top line
\setfootbotline{0pt}    % Footnote bottom line

% Better justify
\usepackage{microtype}

\usepackage{ifpdf}  % part of the hyperref bundle
\ifpdf      % if pdflatex is used

% Set fonts for nicer pdf view
 \IfFileExists{lmodern.sty}{\usepackage{lmodern}}
  {\usepackage[scaled=0.92]{helvet}
    \usepackage{mathptmx}
    \usepackage{courier} }
\fi

% Increase distance between the caption table and the table 
\newcommand{\@ldtable}{}
\let\@ldtable\table
\renewcommand{\table}{ %
                 \setlength{\@tempdima}{\abovecaptionskip} %
                 \setlength{\abovecaptionskip}{\belowcaptionskip} %
                 \setlength{\belowcaptionskip}{\@tempdima} %
                 \@ldtable}

% Table column height
\renewcommand{\arraystretch}{1.5}


\begin{document}

\tracingall

\[
m=m_{0}+\delta_{M}M_{s},                    % INFINITE LOOP
\]

\end{document}

Gives:

\[  ->\x@protect \[\protect \[  

\x@protect #1->\ifx \protect \@typeset@protect \else \@x@protect #1\fi 
#1<-\[
{\ifx}
{true}
{\else}
{\relax}

\[  ->\x@protect \[\protect \[  

\x@protect #1->\ifx \protect \@typeset@protect \else \@x@protect #1\fi 
#1<-\[
{\ifx}
{true}
{\else}
{\relax} ...
6
  • 1
    Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Commented Jun 19, 2013 at 16:01
  • 1
    "Hanging" without errors can be caused by an indefinite loop. With a working minimal example it can be analyzed (e.g. \tracingall and friends). Thus it helps, if you can generate a MWE. Remove sections, chapters, pages, packages, ..., which are not involved or are causing the hanging. Commented Jun 19, 2013 at 16:06
  • 1
    Once again, a very warm welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. Commented Jun 19, 2013 at 16:19
  • Well, I'll try to figure this out. A noob question: should I put \tracing all anywhere after \begin{document} or where?
    – Rubi Shnol
    Commented Jun 19, 2013 at 16:56
  • @ValerySaharov -- you say that if you have only about ten formulae it works, but if you add one more, it hangs. i'd start by putting the \tracing command just before the addition. with luck, something will happen to make the job crash instead of hang, and then you'd have the benefit of a log to check. if not, and it does hang, figure out how to interrupt the job and x out of it to preserve the log. a likely problem is a redefined command that references its own name in a definition (or a chain of definitions). good luck. Commented Jun 19, 2013 at 17:50

1 Answer 1

13

A minimal example would have been:

\documentclass{article}
\usepackage{amsmath}
\usepackage{ulem}
\usepackage{fixltx2e}

\begin{document}
\[\]
\end{document}

The tracing shows that \[ is broken. If LaTeX makes a command robust (\DeclareRobustCommand), it uses two definitions for the macro, the original macro and a macro, whose name is appended by a space that contains the real definition of the macro, e.g.:

\DeclareRobustCommand{\.}{bar}
\typeout{[\string\.->\meaning\.]}
\typeout{[\string\.\space->\expandafter\meaning\csname . \endcsname]}

prints the following on the console/.log file:

[\.->macro:->\x@protect \.\protect \.  ]
[\. ->\long macro:->bar]

That gives a little background for analyzing the minimal example:

\documentclass{article}
\newcommand*{\debug}[1]{%
  \typeout{[#1: \string\[->\meaning\[]}%
  \typeout{[#1: \string\[ ->\expandafter\meaning\csname [ \endcsname]}%
}
\debug{initial}
\usepackage{amsmath}
\debug{amsmath}
\usepackage{ulem}
\debug{ulem}
\usepackage{fixltx2e}
\debug{fixltx2e}

\begin{document}
\end{document}

Discussion of the output of \debug:

Initially \[ is not robust:

[initial: \[->macro:->\relax \ifmmode \@badmath \else \ifvmode \nointerlineskip \makebox [.6\linewidth ]{}\fi $$\fi ]

Package amsmath changes the implementation of \[ to use environment equation*. It also defines it using \DeclareRobustCommand:

[amsmath: \[->macro:->\x@protect \[\protect \[  ]
[amsmath: \[ ->\long macro:->\begin {equation*}]

Package ulem does not touch \[, but it defines \MakeRobust:

\def\MakeRobust#1{\expandafter\let
  \csname \expandafter\@gobble\string#1 \endcsname= #1%
 \edef#1{\noexpand\protect \expandafter\noexpand
  \csname\expandafter\@gobble\string#1 \endcsname}
}

It adds the protection layer of \DeclareRobustCommand to add robustness to a fragile macro.

Package fixltx2e also defines \MakeRobust:

\providecommand*\MakeRobust[1]{%
  \@ifundefined{\expandafter\@gobble\string#1}{%
    \@latex@error{The control sequence `\string#1' is undefined!%
      \MessageBreak There is nothing here to make robust}%
    \@eha
  }%
  {%
    \@ifundefined{\expandafter\@gobble\string#1\space}%
    {%
      \expandafter\let\csname
      \expandafter\@gobble\string#1\space\endcsname=#1%
      \edef\reserved@a{\string#1}%
      \def\reserved@b{#1}%
      \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
      \edef#1{%
        \ifx\reserved@a\reserved@b
          \noexpand\x@protect\noexpand#1%
        \fi
        \noexpand\protect\expandafter\noexpand
        \csname\expandafter\@gobble\string#1\space\endcsname}%
    }%
    {\@latex@info{The control sequence `\string#1' is already robust}}%
   }%
}

And makes \[ robust:

\MakeRobust\[

Package fixltx2e uses \providecommand, but \MakeRobust is already defined. But the simpler version of package ulem has a serious shortcoming, it does not check, if the command is already made robust. Then following happens. The top macro calls the macro with space and the macro with space contains the original definition. Doing it twice creates a loop, if the macro is called.

[fixltx2e: \[->macro:->\protect \[  ]
[fixltx2e: \[ ->macro:->\x@protect \[\protect \[  ]

The \[␣ calls itself instead of the original macro.

Workaround:

\usepackage{ulem}
\let\MakeRobust\relax % undefine this insufficient version
\usepackage{fixltx2e}

Then the more elaborate version of \MakeRobust of package fixltx2e is used that checks, whether the command is already robust. That avoids the redefinition with the loop.

1
  • It works well. The question is solved
    – Rubi Shnol
    Commented Jun 20, 2013 at 8:34

You must log in to answer this question.

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