2

After discovered how to mix glossary and acronym system (See here), and how to put kana/kanji working with pdfLaTeX (See here), I was trying to mix the both, in order to create kind of dictonnary, with the name of the object, in romanji (with our alphabet), in kana/kanji in parenthesis, and then, a description, with a picture if necessary.

The 2 packages and command work well together, but, if you try to put some kana/kanji in the "name", in the glossary entry (with the related command), it doesn't work. But, if in the description, there's no problem.

Here is an example that goes fine:

\documentclass[12pt,a4paper,oneside]{book}
\usepackage[francais]{babel}
\usepackage[utf8]{inputenc}
\usepackage{CJKutf8,pinyin} % Enables TeX to generate (a) East Asian glyphs and (b) their pronunciations.
\usepackage[overlap,CJK]{ruby} % Simple method for generating sub- and super-textual pronunciation keys (Pīnyīn, kana, etc.)
\usepackage[T1]{fontenc}
\usepackage[svgnames]{xcolor}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{url}
\usepackage[pdftex]{thumbpdf}
\usepackage[pdftex,
    breaklinks = true,
    bookmarksnumbered = true,
    colorlinks = true,
    linkcolor = bleuvert,
    bookmarks = true,
    pdfpagemode = UseOutlines,
    pdfstartview = FitH,
    pdfpagelayout = OneColumn,
    urlcolor = darkpink,
    ]{hyperref}
\usepackage{index}
\usepackage[acronym]{glossaries}
\makeglossaries
%
\author{Julien}
\title{Test8}
\date{Dernière compilation le \today}
%
\newcommand{\kana}[1]{\begin{CJK*}{UTF8}{gbsn}#1\end{CJK*}}
\newcommand{\kanji}[1]{\begin{CJK*}{UTF8}{bkai}#1\end{CJK*}}
%
\definecolor{vertfonce}{cmyk}{0.775,0,0.775,0.35}
\definecolor{red_relevant}{cmyk}{0.0,1.7,3.2,0.55}
\definecolor{bleuvert}{cmyk}{2.875,0.105,0.365,0.2}
\definecolor{darkpink}{cmyk}{0,0.25,0.175,0.45}
%
\newglossaryentry{Test}{name={Obon}, description={\kana{お}\kanji{盆}}}
%
\begin{document}
%
\thispagestyle{empty}
\maketitle
%
\frontmatter
%
\tableofcontents
%
\printglossary[type=acronym]
%
\mainmatter
%
\part{Introduction}
%
\chapter{Test}
%
\gls{Test}
%
\appendix
%
\part{Annexe}
%
\chapter{Les index}
%
\printglossary[style=list]
%
\end{document}

(Sorry if looks so ugly...) Note that, my problem is, rather than having the japanese caracters in the description, I'd like to have them in the name, like this:

\newglossaryentry{Test}{name={Obon (\kana{お}\kanji{盆})}, description={This is ...}}

Any idea?

=> \unexpanded{} was the solution, thanks to egreg for his answer.

1
  • 2
    Can you provide a minimal example that illustrates the problem? Jan 29, 2013 at 19:36

1 Answer 1

4

It's a problem related to the timing of expansions. It seems that making the commands robust solves the issue if the characters are in the description field.

\usepackage{etoolbox}
\newrobustcmd{\kana}[1]{\begin{CJK*}{UTF8}{gbsn}#1\end{CJK*}}
\newrobustcmd{\kanji}[1]{\begin{CJK*}{UTF8}{bkai}#1\end{CJK*}}

However, this doesn't solve it when they are in the name field; in this case this hack works:

\newglossaryentry{Test}{
  name={Obon \unexpanded{\kana{お}\kanji{盆}}},
  description={Something}
}
1
  • Hi, thanks for answer. There were absolutly no problem if in the description field. Indeed, your hack for the 'if in the name field case', does work perfectly ! Thanks a lot. What the \unexpanded{} does ? And why this solved the problem here ?
    – Julien
    Jan 30, 2013 at 20:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .