Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Welcome to TeX.sx! –  Peter Jansson Jan 28 '13 at 18:09
    
Thanks, I'm a total newbie in TeX, but furigana support totally sucks everywhere else, apparently... –  Vasili Sviridov Jan 28 '13 at 18:38
    
Are Furigana really used both above and below? –  egreg Jan 28 '13 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. –  Vasili Sviridov Jan 28 '13 at 18:43

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
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. –  Vasili Sviridov Jan 28 '13 at 18:40
    
Thank you so much! –  Vasili Sviridov Jan 29 '13 at 5:02
    
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. –  Vasili Sviridov Jan 29 '13 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 '13 at 5:52
    
Thank you again, you are very helpful. –  Vasili Sviridov Jan 29 '13 at 5:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.