views:

342

answers:

3

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".

+2  A: 

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).

liori
I was going to suggest xelatex or xetex as well. you need this in your preamble: % !TEX TS-program = xelatex% !TEX encoding = UTF-8\usepackage{fontspec} % Font selection for XeLaTeX; see fontspec.pdf for documentation\defaultfontfeatures{Mapping=tex-text} % to support TeX conventions like ``---''\usepackage{xunicode} % Unicode support for LaTeX character names (accents, European chars, etc)\usepackage{xltxtra} % Extra customizations for XeLaTeX\setmainfont{Charis SIL} %\setsansfont{Deja Vu Sans}%\setmonofont{Deja Vu Mono}
Mica
+1  A: 

I have managed to get this working now!

Using Latex and CJK as before.

\section{[Japanese Text]}

was replaced with

\section{\texorpdfstring{[Japanese Text]}{}}

Now the contents pages and section titles work and update fine.

Tom
+3  A: 

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

\section{[Japanese Text]}

with

\section{\texorpdfstring{[Japanese Text]}{}}

suggests that you're using the hyperref package. When you use the hyperref 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 write

\section{Calculation of \texorpdfstring{$H_2(\mathcal{X})$}{H\_2(X)}}

if 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)".

Anton Geraschenko
This is more appropriate as an answer, don't be sorry!
Will Robertson