14

I have followed Japanese Problem using MacTeX 2011 to set up Ruby Furigana with TeX.

I'm wondering if it is possible to set up Furigana both above and below the original character?

5
  • Welcome to TeX.sx! Jan 28, 2013 at 18:09
  • Thanks, I'm a total newbie in TeX, but furigana support totally sucks everywhere else, apparently... Jan 28, 2013 at 18:38
  • Are Furigana really used both above and below?
    – egreg
    Jan 28, 2013 at 18:40
  • W3C guidelines for Ruby text do suggest the ability for simultaneous usage, and wikipedia article on the subject also seem to have it in some way... But I want it to help with my studies, not for publishing purposes. Jan 28, 2013 at 18:43
  • @egreg It is more common for furigana to be above Kanji when written left-to-right or to the right of Kanji when written top-to-bottom. However, sometimes both are used to add different information such as the on-yomi and the kun-yomi readings for Educational texts (or romanji and translations in the example below).
    – Tom Kelly
    Nov 17, 2017 at 6:41

3 Answers 3

15

It seems that you can set the \rubysep parameter to a negative value to get the effect you want.

%!TEX TS-program = xelatex
\documentclass[12pt]{article}

\usepackage{xeCJK}
\usepackage{ruby}
\setCJKmainfont{Hiragino Mincho Pro}
\renewcommand{\rubysep}{-4ex}
\pagestyle{empty}
\begin{document}

On this line \ruby{学}{がく}\ruby{生}{せい}

\end{document}

enter image description here

Here's a solution which seems to allow simultaneous top and bottom furigana

%!TEX TS-program = xelatex
\documentclass[24pt]{letter}
\usepackage{xeCJK}
\usepackage{ruby}
\setCJKmainfont{Hiragino Kaku Gothic ProN}
\usepackage{setspace}
\usepackage[margin=0.2in]{geometry}
%%
\makeatletter
\newcommand{\defaultrubysep}{0.25ex}
\renewcommand{\rubysep}{\defaultrubysep}
\newcommand{\english}{}
\renewcommand{\english}{-3.2ex}
\newlength{\kanji@kana@no@nagasa}
\newcommand{\eruby}[3]{%
    %% save the current baselinestretch
    %% and reset value to "1"
    \let\oldbaselinestretch=\baselinestretch%
    \renewcommand{\baselinestretch}{1}%
    \large\normalsize%
    \ruby{#1}{#2}%
    %% reassign \rubysep to allow furigana below
    \renewcommand{\rubysep}{\english}%
    %% measure the width of the first argument
    %% move to the left by that distance
    \settowidth{\kanji@kana@no@nagasa}{#1}%
    \hspace*{\dimexpr-\kanji@kana@no@nagasa\relax}%
    \ruby{\phantom{#1}}{#3}%
    %% restore the original \rubysep and \ baselinestretch
    \renewcommand{\rubysep}{\defaultrubysep}%
    \renewcommand{\baselinestretch}{\oldbaselinestretch}
    \large\normalsize%
}
\makeatother
%%
\pagestyle{empty}
\begin{document}
%% implement double spacing
\renewcommand{\baselinestretch}{2}\large\normalsize

たんぼの \eruby{畦道}{あぜみち}{footpath}に、\eruby{タンポポ}{tanpopo}{dandelion}が 
さいて いました。あまい においの する まっき
いろな 花です。そこへ ひらひらと 白い \eruby{チョウチョ}{chocho}{butterfly}が 
あそびに きて、「タンポポさん、あなたは はろの
 ブローチね。」 と いいました。白い チョウに そう いわれると、 「ほん
とうに そう 見えて。」 と、 タンポポも うれしく なりました。今度は、ヒ
バリが あそびに きて、「タンポポさん、 あなたは のはらの おほしさまみた
い。」 といいました。ヒバリに こう いわれると、 「まあ、 おほしさまだな
んで。」 と うれしく なりました。

\begin{tabular}{rl}
    \eruby{畦道}{あぜみち}{footpath}に                    & along side a path  \\
    \eruby{タンポポ}{tanpopo}{dandelion}が さいて いました & a dandelion bloomed. 
\end{tabular}
\end{document}

This produces:

enter image description here

The idea is two first save the current \baselinestretch and then reset to 1. Then I call \ruby{...} twice, the second time using a \phantom argument and adding a negative width between the two calls to \ruby to give the appearance of two furiganas for one block of kanji or other kana.

Since ruby is scaling things vertically based upon baseline values, I think all your vertical scaling should do the same thing.

5
  • But is it possible to have them both simultaneously? I'm trying to have the kana above and the english version below the kanji characters, for my studies. Jan 28, 2013 at 18:40
  • I've tried it out, but there are still some issues (possibly due to my misunderstanding of the TeX inner works). Could you take a look at gist.github.com/4662109? If I use the double spacing - it gets all screwed up. Which could be fixed by playing with the offsets, I guess. But it also pushes the following character to the right. Also, how would one change the type for the english portion? Japanese types have monospaced font for english letters. Thanks. Jan 29, 2013 at 5:46
  • Cute story. I'll have to think about this one. I might not have an answer until later tomorrow.
    – A.Ellett
    Jan 29, 2013 at 5:52
  • Just FYU, putting it into a tabular context screws up vertical offsets as well. Jan 30, 2013 at 11:02
  • 1
    I've posted a more update version. It seems to work for me in a tabular environment.
    – A.Ellett
    Jan 30, 2013 at 18:43
5

Here's a quick example which only requires mathtools and CJK fonts:

\documentclass[a4paper,10pt]{letter}
\usepackage[utf8]{inputenc}

\usepackage{CJKutf8}
\usepackage{mathtools}

\begin{document}
\begin{letter}

Show readings for each Kanji:

\begin{CJK}{UTF8}{goth} $\stackrel{\text{タ}}{\text{田}}$     
$\stackrel{\text{ナカ}}{\text{中}}$\ \ $\stackrel{\text{ハ}}{\text{一}}$         
$\stackrel{\text{ナ}}{\text{愛}}$ \end{CJK}  \\

Show readings for each word:

\begin{CJK}{UTF8}{goth} $\stackrel{\text{タナカ}}{\text{田中}}$\ \                 
$\stackrel{\text{ハナ}}{\text{一愛}}$ \end{CJK}  \\

Show readings under each word:

\begin{CJK}{UTF8}{goth} $\underset{\text{タナカ}}{\text{田中}}$\ \             
$\underset{\text{ハナ}}{\text{一愛}}$ \end{CJK}  \\

Show kuny\={o}mi above and ony\={o}mi below:

\Big

\begin{CJK}{UTF8}{goth} $\stackrel{\text{なか}}{\underset{\text{チュウ}}{\text{中}}}$ \end{CJK}  \\


Show furigana above and translation below:

\begin{CJK}{UTF8}{goth} $\stackrel{\text{ちゅうごく}}{\underset{\text{China}}{\text{中国}}}$ \end{CJK}  \\

Show romanji above and translation below:

\begin{CJK}{UTF8}{goth} $\stackrel{\text{Konbini}}{\underset{\text{Convenience Store}}{\text{コンビニ}}}$ \end{CJK}  \\

\end{letter}
\end{document}
2

I use TikZ to set Furigana. This command can easily be extended to set them above and below:

% !TeX program = xelatex
\documentclass{article}

\usepackage[AutoFallBack=true]{xeCJK}
% Hanazono is a free font downloaded from https://osdn.jp/projects/hanazono-font/ [02.02.2016]
\setCJKmainfont{HanaMinA}
\setCJKfallbackfamilyfont{rm}{HanaMinB}

\usepackage{tikz}

% characters with big height and depth
% to give different boxes the same vertical size
\newcommand{\vsizecorrectorhira}{\vphantom{もりぼゃ}}% epkyouka, HanaMinA
\newcommand{\vsizecorrectorkanji}{\vphantom{$\vert$}}

% commands for setting furigana below kanji
\newcommand{\furigana}[2]{% #1: kanji, #2: furigana
    %\unskip
    \begin{tikzpicture}[baseline=(kanji.base)]
        \node(kanji)[
            inner sep=0,
        ] {
            \vsizecorrectorkanji%
            #1%
        };
        \node(furigana)[
            below of=kanji,
            node distance=1em-2pt,
            inner sep=0,
        ] {%
            \tiny%
            \vsizecorrectorhira%
            #2%
        };
    \end{tikzpicture}%
    %\ignorespaces
}

\newcommand{\furiganaAboveBelow}[3]{% #1: kanji, #2: furigana above, #3: furigana below
    %\unskip
    \begin{tikzpicture}[baseline=(kanji.base)]
        \node(kanji)[
            inner sep=0,
        ] {
            \vsizecorrectorkanji%
            #1%
        };
        \node(furigana-above)[
            above of=kanji,
            node distance=1em,
            inner sep=0,
        ] {%
            \tiny%
            \vsizecorrectorhira%
            #2%
        };
        \node(furigana-below)[
            below of=kanji,
            node distance=1em-2pt,
            inner sep=0,
        ] {%
            \tiny%
            \vsizecorrectorhira%
            #3%
        };
    \end{tikzpicture}%
    %\ignorespaces
}

\begin{document}
Japanese uses different alphabets, one of those is \furigana{漢字}{かんじ} (Kanji).

Kanji can have different readings: \furiganaAboveBelow{日}{にち}{ひ}.
\end{document}

enter image description here

You must log in to answer this question.

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