\title{}
在micro中添加unicode字符后:
\title{标题}
make all-pdf
运行文件时出现以下错误.tex
:
Writing index file mybook.idx
No file mybook.aux.
(/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf-dist/tex/latex/psnfss/t1ptm.fd)
(/usr/share/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texmf-dist/tex/latex/oberdiek/grfext.sty)
(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/share/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.bdg)
(/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.enc)
(/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.chr)
! Extra \else.
\CJK@XXX ...\number `#1\endcsname {`#2}{`#3}\else
\csname u8:\string #1\stri...
l.124 \tableofcontents
?
我已将以下设置添加到.tex
文件中:
\hypersetup{unicode=true}
\usepackage{CJKutf8}
\AtBeginDocument{\begin{CJK}{UTF8}{gbsn}}
\AtEndDocument{\end{CJK}}
如果我删除 unicode 字符,并用 acsii 字符替换它们,效果会很好。我是否忘记添加任何内容来.tex
实现这一点?
.tex
重现错误的最小文件:
% Generated by Sphinx.
\def\sphinxdocclass{report}
\documentclass[letterpaper,10pt,english]{sphinxmanual}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{00A0}{\nobreakspace}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{times}
\usepackage[Bjarne]{fncychap}
\usepackage{longtable}
\usepackage{sphinx}
\usepackage{multirow}
\usepackage{CJKutf8}
\AtBeginDocument{\begin{CJK}{UTF8}{gbsn}}
\AtEndDocument{\end{CJK}}
\title{title 中文}
\date{June 21, 2013}
\release{1.0.0}
\author{author}
\newcommand{\sphinxlogo}{}
\renewcommand{\releasename}{Release}
\makeindex
\makeatletter
\begin{document}
\maketitle
\tableofcontents
\printindex
\end{document}
具体错误信息:
(/usr/share/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texmf-dist/tex/latex/oberdiek/grfext.sty)
(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/share/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./mybook.out) (./mybook.out)
(/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.bdg)
(/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.enc)
(/usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.chr)
! Extra \else.
\CJK@XXX ...\number `#1\endcsname {`#2}{`#3}\else
\csname u8:\string #1\stri...
l.32 \tableofcontents
?
\title{title 中文}
如果我从中删除unicode字符\title{title}
,它可以正常工作。
答案1
快速解决:
\title{title \unexpanded{中文}}
\maketitle
您的问题是由课堂上的不寻常的定义引起的sphinxmanual
。
\maketitle
在的定义中sphinxmanual.cls
,有
\pdfinfo{
/Author (\@author)
/Title (\@title)
}
这非常危险,因为 CJK 字符实际上是宏,不应该直接放入 pdf 流中。所以我们可以使用 eTeX 的原语\unexpanded
来防止这个问题。
有关中文排版的更多信息,请参阅如何在 LaTeX 中输入中文?XeLaTeX 也可以解决这个问题。