7

I'm creating a Japanese to English dictionary, using the glossaries package with xindy. Thanks to the answer here, I am able to put Japanese text in the name field of a glossary entry; eg. \newglossaryentry{a}{name={\cjkname{あ}},description={a}}. However, as xindy doesn't have Japanese in its list of languages, I've had to use Korean as a substitute. This in turn means that the entries won't be automatically sorted.

I can work around this by assigning each character in the Japanese phonetic alphabet (Hiragana) with a Latin script entry, then using the sort={} field to sort entries. However it's far from ideal.

Hence, I wish to create a Japanese phonetic alphabet (just using Hiragana is fine) that xindy can use to sort words. Other alphabets have been created, see International Phonetic Alphabet and Vietnamese. However, they have used Latin script. I'm not sure if I can simply replace those alphabets with Hiragana, or if I need to edit the Korean language files in xindy (utf8.xdy and utf8-lang.xdy), which look completely different from those in previously answered questions.

I believe the correct sort order is as follows (see here); however this may not be correct, which is largely why I wish to create an alphabet, for which the sort order can be changed/corrected as necessary.

あ ぁ
い ぃ
う ぅ
う゛
え ぇ
お ぉ
か
が
き
ぎ
く
ぐ
け
げ
こ
ご
さ
ざ
し
じ
す
ず
せ
ぜ
そ
ぞ
た
だ
ち
ぢ
つ っ
づ
て
で
と
ど
な
に
ぬ
ね
の
は
ば
ぱ
ひ
び
ぴ
ふ
ぶ
ぷ
へ
べ
ぺ
ほ
ぼ
ぽ
ま
み
む
め
も
や ゃ
ゆ ゅ
よ ょ
ら
り
る
れ
ろ
わ
を
ん

Below is a minimal example of some entries to be sorted. It can be compiled using xindy with korean, but of course it won't be sorted.

\documentclass{article}

\usepackage{CJKutf8}
\usepackage[overlap, CJK]{ruby}
\renewcommand{\rubysep}{0.01ex}
\usepackage[xindy={language={korean},glsnumbers=false},nopostdot,nonumberlist]{glossaries}
\usepackage{glossary-mcols}
\setglossarystyle{mcolindex}

\makeglossaries

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

\newglossaryentry{add}{
name={\cjkname{\ruby{足}{た}す}},%sort using たす
description={plus / add}}

\newglossaryentry{subtract}{
name={\cjkname{\ruby{引}{ひ}く}},%sort using   ひく
description={minus / subtract}}

\newglossaryentry{multiply}{
name={\cjkname{かける}},%sort using かける
description={times / multiply}}

\newglossaryentry{divide}{
name={\cjkname{\ruby{割}{わ}る}},%sort using わる
description={divide}}

\begin{document}

\glsaddall

\printglossaries
\end{document} 
James
  • 165
  • Not dived too much into it, but there is a LuaTeX package called kanaparser (I have no idea how to use it). You could use it to translate the kana into romaji and sort using the romaji transcript, no idea how to implement that though. – Skillmon May 22 '19 at 11:36

1 Answers1

1

If you want to display Japanese characters on LaTeX, simply use package bxcjkjatype. It works very well for me. The good news is, the package does not only work on Hiragana, but Katakana and Kanji as well. This is the example of simple code I created, containing all three kinds of Japanese letters, using package bxcjkjatype. I set my compiler to pdfLaTeX.

\documentclass{article}
\usepackage[whole]{bxcjkjatype}

\begin{document}
日本語が面白いです。コンピューターでもタイプされますよ。\\
Japanese is interesting. You can even type it in computer.
\end{document}

The code above gave me result like this. bxcjkjatype package result display

  • 2
    Welcome to TeX.SE. Thanking for answering, but I think the question was actually asking about providing a way to automatically sort Japanese (using an external tool) rather than the actual typesetting. – Nicola Talbot Jul 06 '18 at 11:08
  • 1
    Thank you for your comment. In my opinion, the easiest way to sort Japanese in TeX is by using the package I mentioned above. To get the character on your computer, you can use any Japanese IME (Input Method Editor) available in your OS. Sorry if it doesn't answer the question, but I recently can't think any other better options. – Ahmad Fauzan Bagaskoro Jul 06 '18 at 16:24
  • 2
    @AhmadFauzanBagaskoro I guess “sort” in the question here should mean ordering glossaries in the dictionary order. Similar for alphabets A->B->...->Z, for Japanese あ->い->...->ん. – Hironobu YAMASHITA Jul 07 '18 at 15:40
  • 2
    Though “xindy” does not support Japanese character ordering, “mendex” and “upmendex” (both are developed by Japanese members inside TeX Live) support it. They are modified version of “makeindex” with extension for Japanese character ordering using dictionary. See mendex.man1.pdf (should be available as part of “ptex” package in TL) for detail. – Hironobu YAMASHITA Jul 07 '18 at 15:42
  • 2
    As others have mentioned displaying Japanese text isn't the problem, it's sorting words in a specified order (using the phonetic alphabet). @HironobuYAMASHITA Are "mendex" and "upmendex" usable outside of ptex? I don't wish to use ptex, for other reasons. – James Jul 19 '18 at 07:19
  • 1
    @James Yes, of course you can use "mendex" and "upmendex" outside of ptex. For example, "mendex" (with -U option) and "upmendex" are commonly used with Lua(La)TeX here in Japan. – Hironobu YAMASHITA Jul 20 '18 at 12:06
  • @HironobuYAMASHITA would that include Kanji as well? I am unfortunately facing some issues concerning the glossaries-extra package (which doesnt work for me), see https://tex.stackexchange.com/questions/474227/define-special-sorting-for-lualatex-glossaries-in-japanese - I need a glossary with japanese sorting. (if dual-sorting was possible as in glossaries-extra, that would be great) :) – user168390 Feb 19 '19 at 12:32
  • 1
    @user168390 mendex and upmendex can handle Kanji characters too, when you give their readings in your (La)TeX source. Here is a simple example of making Japanese index using LuaLaTeX (package "luatexja") and Mendex (= Japanese index processor): https://gist.github.com/aminophen/72ec44c3593fbc30b2c0c6526deb8189 – Hironobu YAMASHITA Feb 20 '19 at 13:29
  • @HironobuYAMASHITA awesome, thank you very much! Unfortunately I didn't get it to show hiragana headings, although I used your jgind.ist file :/ I had to change your MWE just a little bit (had to use scrreprt instead) \documentclass{scrreprt} \usepackage[match]{luatexja-preset} \setmainjfont{IPAexMincho} \usepackage{makeidx} \makeindex copy-pasted the whole begin - end document thing, so I don't add it here. Do you know why this might've happened? https://i.imgur.com/CzehaX7.png – user168390 Feb 21 '19 at 20:37
  • @user168390 The difference of class file does not matter; it should be an issue related to mendex. Using mendex, both your modified MWE and my original MWE should produce the same .ind file like this: https://gist.github.com/aminophen/72ec44c3593fbc30b2c0c6526deb8189#gistcomment-2844736 - What is written in your .ind? – Hironobu YAMASHITA Feb 22 '19 at 10:47
  • I checked both "mendex version 2.6f [14-Aug-2009]" from TeX Live 2018, and "mendex version 3.1 [17-Feb-2019]" from TeX Live 2019 (under development), and got the same result. – Hironobu YAMASHITA Feb 22 '19 at 10:51
  • @HironobuYAMASHITA thank you very much for the quick reply. My ind file didn't compile correctly as it seems to have ignored the jgind.ist file amendments apparently `\begin{theindex}

    \item 抗原, 1

    \indexspace

    \item 生体防御機構, 1

    \indexspace

    \item 非自己, 1

    \indexspace

    \item 免疫, 1

    \end{theindex} `

    – user168390 Feb 22 '19 at 19:32
  • @user168390 Hmm, what version of mendex and TeX Live are you using? – Hironobu YAMASHITA Feb 23 '19 at 01:12
  • I have updated from 2.6f to 3.1 now (to test whether the version is an issue), but it gives me the exact same result :/ thank you for taking the time! @HironobuYAMASHITA – user168390 Feb 23 '19 at 11:26
  • @HironobuYAMASHITA I was able to fix it - one of my arguments were wrong. thank you so much! – user168390 Feb 23 '19 at 21:21