前几天装好了MiKTeX,配置好了中文,然后开始把之前用Word写的一份文档试着移植过来。其间遇到了不少问题,不过都还好,就是好有一个Mysterios Error,半天搞不定,网上搜索了一下,终于找到根源。
且看TeX User Group上的一份“官方”文档:http://www.tug.org/errors.html
---------------------转贴分割线 begin---------------------
Mysterious TeX Errors
(preface needed! )
Missing title/author in output
You have to specify \maketitle after \begin{document}.
LaTeX error: Bad math environment delimiter
This can be caused by forgetting a closing brace.
Too many }
This can be caused by forgetting the \ on \begin, even though the document has the right number of { and }.
Missing $ inserted from \:
In LaTeX, \: is a math mode operator which inserts a ``medium'' space. So constructs like this:
\LaTeX\: % missing $ error
result in the mysterious Missing $ inserted error. It's advisable to get in the habit of using {} after abbreviations to minimize problems like this, as in:
\LaTeX{}: % ok
Missing number, treated as zero
If [...] follows \\, even with intervening whitespace and newlines, it will be taken as an optional argument, and thus expected to start with a number. (Even if amsmath is loaded, apparently, in contrast to the The LaTeX Companion.) For example, a math alignment like this causes the error:
a^2 & a^3 \\ [b^2] & ...
One remedy is to insert {} before the left bracket.
Misplaced \noalign
Using tabular, this can be caused by an \hline without a preceding \\. Similarly, using booktabs, this is the result of leaving out the \\ in the line before \bottomrule.
Section headings one character in output
Perhaps you left off the braces after \section. It should be used like this:
\section{The section title}
\pdfendlink ended up in different nesting level than \pdfstartlink
This happens when hyperref is used under pdftex and a citation splits across a page boundary. To fix it, note the page number of the error and specify the draft option to hyperref so you get an output PDF. Then you can see the citation in question and rewrite to fix it. (Thanks to James Bednar's posting on the pdftex list about this.)
---------------------转贴分割线 end---------------------
红色粗体那段,就是我遇到的问题。我的文档中有这样一段:
\texttt{[root@host] \# some command\\
[root@host] \# some other command}
结果用xelatex一处理,总是报告在第二行的“[”符号处"Missing number, treated as zero",真是郁闷呀,原来原因在于“\[”这个组合,会让TeX误以为这是一个可选参数输入的开始。正确的写法应该是在“\”之后加上“{}”,也就是应该写成:
\texttt{[root@host] \# some command\\{}
[root@host] \# some other command}
看来不论是什么软件,只要规模大点,错误信息总是那么不中用。