[Tex/LaTex] Typesetting furigana above and below original text

cjkpositioningxecjk

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?

Best Answer

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.