# Creating a Japanese (Hiragana) alphabet

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

name={\cjkname{\ruby{足}{た}す}},%sort using たす

\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}

\printglossaries
\end{document}

• 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 at 11:36

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.

• 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 6 '18 at 11:08
• 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 6 '18 at 16:24
• @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 7 '18 at 15:40
• 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 7 '18 at 15:42
• 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 7:19