PdfLateX 挂在单行未编号的方程式上,
这是一个(可能)最小的例子:
\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}
给出:
\[ ->\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} ...
答案1
一个最小的例子是:
\documentclass{article}
\usepackage{amsmath}
\usepackage{ulem}
\usepackage{fixltx2e}
\begin{document}
\[\]
\end{document}
跟踪显示这\[
是错误的。如果 LaTeX 使命令变得健壮(\DeclareRobustCommand
),它会使用二宏的定义、原始宏和宏的名称后面附加一个空格,其中包含宏的真实定义,例如:
\DeclareRobustCommand{\.}{bar}
\typeout{[\string\.->\meaning\.]}
\typeout{[\string\.\space->\expandafter\meaning\csname . \endcsname]}
在控制台/.log
文件上打印以下内容:
[\.->macro:->\x@protect \.\protect \. ]
[\. ->\long macro:->bar]
这为分析最小示例提供了一些背景信息:
\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}
讨论输出\debug
:
最初\[
并不稳健:
[initial: \[->macro:->\relax \ifmmode \@badmath \else \ifvmode \nointerlineskip \makebox [.6\linewidth ]{}\fi $$\fi ]
包将amsmath
的实现更改为\[
使用环境equation*
。它还使用 来定义它\DeclareRobustCommand
:
[amsmath: \[->macro:->\x@protect \[\protect \[ ]
[amsmath: \[ ->\long macro:->\begin {equation*}]
包ulem
不接触\[
,但它定义了\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}
}
它增加了保护层,\DeclareRobustCommand
为脆弱的宏增加了稳健性。
包fixltx2e
还定义\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}}%
}%
}
并且使其\[
强大:
\MakeRobust\[
包fixltx2e
使用\providecommand
,但\MakeRobust
已经定义。但是,包的简单版本ulem
有一个严重的缺点,它不检查命令是否已经变得健壮。然后发生以下情况。顶部宏调用带有空格的宏,带有空格的宏包含原始定义。如果调用宏,则执行两次会创建一个循环。
[fixltx2e: \[->macro:->\protect \[ ]
[fixltx2e: \[ ->macro:->\x@protect \[\protect \[ ]
调用\[␣
自身而不是原始宏。
解决方法:
\usepackage{ulem}
\let\MakeRobust\relax % undefine this insufficient version
\usepackage{fixltx2e}
\MakeRobust
然后使用更复杂的包版本fixltx2e
来检查命令是否已经很强大。这避免了使用循环进行重新定义。