I appear to be having a conflict with font encodings. I am currently using LyX 2.1.1 (under Linux Mint 17). I have Chinese text scattered throughout most chapters, but I receive the following error when exporting to PDF:
Use of \@chapter doesn't match its definition
...ing{latin9}Pottery Production at Huizui I}
To be specific, as you can see, only the chapter title seems to generate this error. When I change the encoding to UTF8 (Document > Settings > Language), I then get an error with the Chinese text:
...in Ancient China'' {[}\begin{CJK}{GB}{}
Ŵչо\end{CJK... The control sequence at the end of the top line of your error message was never \def'ed.
This was not an issue under LyX 2.0.6, though at the time I used a cumbersome ERT inset; under 2.1.1 I just change the Language to "Chinese" and change the input on my computer to Chinese as well.
Clearly, the issue seems to stem from something with \@chapter
, but I don't know why this is suddenly a problem.
Unfortunately, I don't know if I can provide a MWE: this is a multi-chapter dissertation with master and child docs. Still I'm hoping some folks have some ideas that I can try out.
If there are any enterprising folks that want me to send the document to look at, I am happy to do so!
Edit1:
Looking at the source, here is the bit causing trouble:
\usepackage{CJKutf8}
\begin{document} \begin{CJK}{UTF8}{}%
\chapter{\end{CJK}\inputencoding{latin9}Pottery Production at Huizui I}
\inputencoding{latin9}\label{chap:Chapter-4}In this chapter I analyze and discuss the primary data collected from the Huizui site and the
And later, when Chinese is used:
...by Li Wenjie ``A Study of
the Pottery-Making Technology in Ancient China'' \begin{CJK}{GB}{}中国古代制陶工艺研究\end{CJK}\inputencoding{latin9}
using pottery in the National History Museum collection.
As you can see, the encodings seem to switch back and forth correctly, though the bit of code above
\begin{CJK}{UTF8}{}%
\chapter{\end{CJK}
Seems strange to me because \chapter
ends up "as" CJK.
Edit2:
Actually, that last comment (below) is not entirely true; that unusual coding is not present when I change the encoding (Document>Settings>Language) to "Unicode (utf8)" rather than "Unicode (CJK)(utf8)". However, then the CJK text throws errors as "not found", which is still odd because in the preamble it has this code:
\usepackage[utf8]{inputenc}
\usepackage{CJKutf8}
which I would think covers the CJK text. I think LyX adds this line because it detects that I've used "Chinese" in the document.
Edit 3:
I have now tried a work-around based on egreg's answer below, and changed the beginning code to:
\makeatother
\begin{document}
\begin{CJK}{UTF8}{}%
\end{CJK}\inputencoding{latin9}\chapter{Pottery Production at Huizui I}
\label{chap:Chapter-4}In this chapter I analyze and discuss the primary
data collected from the Huizui site and the archaeometric analysis...
Here, \begin{CJK}
is not incorporated into \chapter
, but now I get an error for the Chinese text even though I have the encoding set to "Unicode (CJK)(utf8)"!! Makes me think it is actually a problem with the CJK font family as egreg points out. Not sure why mine is set to {GB} rather than {gbsm} which worked previously.
\@chapter
complains because something is putting the[
at the start of its first argument in braces. You can see such a [ in your second snippet. But it is not possible to see under which circumstances lyx does it and if it is related to the chinese.\begin{CJK}
before\chapter
and end it in the argument of\chapter
: this will leave unbalanced groups.