2

I'm having difficulty displaying CJK fonts in a glossary with bib2gls. I'm using MikTeX, which I think may produce different results to TeXLive. Here's a MWE:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{CJKutf8}
\usepackage[record,style=indexgroup,nomain]{glossaries-extra}

\newglossary*{japanese}{Japanese to English}
\newglossary*{english}{English to Japanese}

\newrobustcmd{\cjkname}[1]{\begin{CJK}{UTF8}{ipxm}#1\end{CJK}}
\glsnoexpandfields

\newcommand*{\englishlettergroup}[1]{#1}
\newcommand*{\japaneselettergroup}[1]{\cjkname{#1}}
\newcommand*{\bibglslettergrouptitle}[4]{\unexpanded{\csuse{#4lettergroup}{#1}}}

\GlsXtrLoadResources[
  src=testcjk2,% bib file
  sort={ja-JP},% locale used to sort primary entries
  dual-sort={en-GB},% locale used to sort secondary entries
  type=japanese,% put the primary entries in the 'japanese' glossary
  dual-type=english% put the dual entries in the 'english' glossary
]

\begin{document}

\begin{CJK}{UTF8}{ipxm}日本語はだいじょうぶ\end{CJK}

Japanese: \gls{squareroot}

English: \gls{dual.squareroot}

\printunsrtglossaries
\end{document}

Where the file testcjk2.bib is

@dualentry{squareroot,
  name={\cjkname{ルート}},
  description={square root}
}

The MWE comes from an answer here. The resulting document looks as shown below. The Japanese text from \begin{CJK}{UTF8}{ipxm}日本語はだいじょうぶ\end{CJK} displays fine, but that from the .bib file does not. Thanks in advance.

enter image description here

James
  • 165
  • @gusbrs It's a good guess, I also had the same idea, but it appears not to change anything. – James Apr 26 '18 at 00:09
  • James, yes, I tried it here without it, and I can't reproduce the issue (it works as expected here). Sorry I deleted the original comment, leaving yours hanging, but it was a bad guess. Anyway, I'm using TeXLive, so if you are assuming there might be a difference with MikTeX, it may well be. So I can't really be of much help. – gusbrs Apr 26 '18 at 00:16
  • Indeed, CJKuft8 does already load [uft8]{inputenc}. – gusbrs Apr 26 '18 at 00:21
  • Try adding % Encoding: UTF-8 at the start of the .bib file. – Nicola Talbot Apr 26 '18 at 10:19
  • I updated MikTek and everything seems to work fine now. It appears that the version of MikTek I had was missing something necessary. – James Apr 26 '18 at 11:02
  • 4
    I'm voting to close this question as off-topic because the issue was solved by an update of MikTeX. – gusbrs Apr 30 '18 at 02:15
  • unfortunately I am facing similar errors with TexLive and apparently there's no way to fix it, which is quite a bummer, as the example from the original question would be a perfect solution for me if it just worked :( – user168390 Feb 16 '19 at 17:55

0 Answers0