reddit / emacs

Creating a LaTeX document with furigana

Hiorig · 2022-09-10 20:59
I'm creating a latex document in japanese with lots of furigana and some footnotes. The command to create the kanji with footnote is `\edtext{\ruby{kanji}{reading}}{\Afootnote{meaning}`, where kanji, reading and meaning are my inputs. ​ Is there any way to quickly create them? Yasnippets doesn't seem to work well since I use three different input-modes, japanese for the kanji, japanese-hiragana for the reading and nil for the meaning. ​ I created the following function: (defun jane/latex-footnote () (interactive) (let ((my-input current-input-method)) (set-input-method 'japanese) (let ((kanji (read-string "What's the kanji: " nil nil nil t))) (set-input-method 'japanese-hiragana) (let ((reading (read-string "What's the reading: " nil nil nil t)) (footnote (read-string "What's the footnote: "))) (insert (concat "\\edtext\{\\ruby\{" kanji "\}\{" reading "\}\}\{\\Afootnote\{" footnote "\}")))) (set-input-method my-input))) It does work, but I do need to type the kanji twice. Once for the kanji, and twice for it's reading. Is there any way to improve my function?
thevoidzero · 2022-09-10 22:43
You'd have to type it twice anyway. unless you make something that tracks what hiragana you input separately to later put as reading there isn't a way to know kanji from reading or reading from kanji.
akirakom · 2022-09-11 08:38
I am developing [a Japanese input method](https://github.com/akirak/emacs-dumb-japanese) that tracks input characters in text properties. In theory, it is possible to extract romaji/hiragana from kanji transliterated with it, but the project has a lower priority for me.