2

I'm trying to include Japanese and English text in the bibliography of LaTeX document while also using the package gb4eand no matter what Japanese text I input it comes out in the pdf as "0123456789abcdef0123456789abcdef0123456789abcdef01234". I'm using CJKutf8 with pdflatex (texlive2014) and have wadalab and CJK and the necessary fonts installed. I would use XeLaTeX but I would have to change too much of the earlier code to make it work properly. Any suggestions of why it is not working properly and why gb4e causes these problems? I need to keep the gb4e package for linguistic inter-linear glossing in the document.

Here is my sample code:

%!TeX encoding = UTF-8
%!TeX program = pdflatex
\documentclass{article}
\usepackage{CJKutf8}
\usepackage[TS3,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{gb4e}

\begin{document}

\begin{exe}
\ex Make sure that ^{super}_{sub}scripts in \texttt{gb4e} work fine.
\end{exe}

\begin{thebibliography}{99}
\bibitem{1} Inui, Hideyuki. 2005.
  \begin{CJK}{UTF8}{min} バスケト語の文法概観 \end{CJK}
  [A grammatical survey of the Basketo language]. \emph{Cushitic-Omotic Studies} 2004, 1--40.
\end{thebibliography}
\end{document}

Here is a brief selection of the error text:

! Use of ^ doesn't match its definition.
<argument> ^^c
              0
l.16 ...ui, Hideyuki. 2005. \begin{CJK}{UTF8}{min}
                                                   バスケト語の文法�...

?
  • 1
    I had to move \begin{center}...\end{center} before \begin{thebibliography} but, other than that, your code compiles fine here (TL 2014 updated yesterday or the day before). Are you sure that your file is actually saved in UTF8 encoding? – cfr Nov 6 '14 at 2:22
  • 1
    Then all I can say is that I cannot reproduce the errors with the code you posted. The only issues are caused by the stuff \begin{center}...\end{center} being inside thebibliography environment. Once I correct that, it works fine. – cfr Nov 6 '14 at 3:24
  • 1
    Have you actually tested the code you posted? The line numbers in the errors you posted do not exist in that code so must be from a different document. Test the code you posted and see if you can reproduce the issue. If not, you need a different example to illustrate the problem. – cfr Nov 6 '14 at 3:26
  • 5
    This question appears to be off-topic because it is about some issue which is not shown in the MWE. – LaRiFaRi Nov 6 '14 at 9:23
  • 2
    The new MWE reproduce the problem. The problem is caused by gb4e package, which changes the catcodes of _ and ^. Note that CJK(CJKutf8) package heavily use catecode tricks to typesetting Japanese, the problem came as no surprise. – Leo Liu Nov 7 '14 at 16:30
3

As I explained in the comment, gb4e changes the category codes of character ^ and _, which makes CJK fail to decode Japanese characters.

As is suggested in the gb4e doc, you can use \noautomath where you want to disable the special effects of _ and ^. Here is the solution.

%!TeX encoding = UTF-8
%!TeX program = pdflatex
\documentclass{article}
\usepackage{CJKutf8}
\usepackage[TS3,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{gb4e}

\begin{document}

\begin{exe}
\ex Make sure that ^{super}_{sub}scripts in \texttt{gb4e} works fine.
\end{exe}

\noautomath % disable catcode changes from gb4e
\begin{thebibliography}{99}
\bibitem{1} Inui, Hideyuki. 2005.
  \begin{CJK}{UTF8}{min} バスケト語の文法概観 \end{CJK}
  [A grammatical survey of the Basketo language]. \emph{Cushitic-Omotic Studies} 2004, 1--40.
\end{thebibliography}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.