Latex \section{} 中的日语字符会导致错误
我正在努力获取用乳胶创建的日语文档。 我已经安装了最新版本的 texlive-2008,其中包括 CJK。
在我的文档中,我有以下内容:
\documentclass{class}
\usepackage{CJK}
\begin{document}
\begin{CJK*}{UTF8}{min}
\title{[Japanese Characters here 1]}
\maketitle
\section{[Japanese Characters here 2]}
[Japanese Characters here 3]
\end{CJK*}
\end{document}
在上面的代码中,有 3 个位置使用了日语字符。
1 + 3 工作正常,而 2(在 \section{} 中包含日语字符)失败并出现以下错误。
! Argument of \@sect has an extra }.
经过一些研究后发现,当您将脆弱的命令放入移动参数中时,就会出现此错误。 移动参数是因为例如可以将部分移动到内容页面。
有谁知道如何让它发挥作用以及为什么乳胶认为日语字符是“脆弱的”。
I am working on getting Japanese documents created with latex. I have installed the latest version of texlive-2008 which includes CJK.
In my document I have the following:
\documentclass{class}
\usepackage{CJK}
\begin{document}
\begin{CJK*}{UTF8}{min}
\title{[Japanese Characters here 1]}
\maketitle
\section{[Japanese Characters here 2]}
[Japanese Characters here 3]
\end{CJK*}
\end{document}
In the above code there are 3 locations Japanese characters are used.
1 + 3 work fine whereas 2, which contains Japanese characters in a \section{} fails with the following error.
! Argument of \@sect has an extra }.
After some research it turns out this error manifests when you’ve put a fragile command inside a moving argument. A moving argument because section can be moved to a contents page for example.
Does anyone know how to get this to work and why latex thinks Japanese characters are "fragile".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
很抱歉将此作为答案而不是对您的答案的评论发布; 我还没有足够的代表来发表评论。 (编辑:现在我有足够的代表发表评论,但我不再抱歉了。谢谢威尔。)
您的替换解决方案
表明
您正在使用
hyperref
包。 当您使用hyperref
包时,\section
中任何类型的不完全无聊的文本(例如数学)都会导致问题,因为\section
生成 pdf 书签时遇到问题。\texorpdfstring
允许您指定章节标题在 pdf 书签中的显示方式。 例如,如果我希望部分标题为“$H_2(\mathcal{X})$ 的计算”,但我希望 pdf 书签为“H_2(X) 的计算”,我可能会这样写。
Sorry to post this as an answer rather than a comment to your answer; I don't have enough rep yet to comment. (EDIT: Now I have enough rep to comment, but I'm not sorry anymore. Thanks Will.)
Your solution of replacing
with
suggests that you're using the
hyperref
package. When you use thehyperref
package, any sort of not-totally-boring text (e.g. math) within\section
causes a problem because\section
is having trouble generating pdf bookmarks.\texorpdfstring
allows you to specify how you want the section title to appear in the pdf bookmark. For example, I might writeif I want the section title to be "Calculation of $H_2(\mathcal{X})$" but I want the pdf bookmark to be "Calculation of H_2(X)".
您可能应该使用 xetex/xelatex,因为它是为了支持 unicode 而创建的。 不过,对于现有文档来说,更改有时并不容易。 (xelatex 应该包含在 texlive 中,它只是调用不同的可执行文件——这就是 Debian 中的实现方式)。
You should probably use xetex/xelatex, as it has been created to support unicode. The change is sometimes not easy for already existing documents, though. (xelatex should be included in texlive, it is just different executable to call -- this is how it is done in Debian).
我现在已经设法让它工作了!
像以前一样使用 Latex 和 CJK。
已替换为
现在内容页面和章节标题可以正常工作和更新。
I have managed to get this working now!
Using Latex and CJK as before.
was replaced with
Now the contents pages and section titles work and update fine.