# Changing the Ruby Font (for Pīnyīn)

Using ruby package to generate both furigana for Japanese and Pīnyīn for Chinese. I use individual \sf calls to individually switch each Pīnyīn from the Japanese font back to the default sans font. Is there an easier way?

(I should clarify that I understand each CJK font has roman glyphs for Pīnyīn, but I prefer the Biolinum.)

Please see MWE...its output makes my question more clear, I think:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}

% PACKAGES

\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Linux Libertine O}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Linux Biolinum O}
\setmonofont[Scale=MatchLowercase]{Linux Libertine Mono O}
\usepackage{ruby}
\usepackage{setspace}

\begin{document} % ==============================================================

\newfontfamily{\J}[Scale=0.85]{Hiragino Kaku Gothic Pro}
\newfontfamily{\C}{STKaiti}

\doublespace
\Large


\end{document}

-
While I RTFM on that, would you mind quickly answering: is there a way to permit an arbitrary number of (paired) arguments, so that my command might look like \HanZi{同}{tóng}{治}{zhì}{中}{zhōng}{興}{xīng}...? (Though it occurs to me that if such a thing were possible, ruby's authors would have implemented it.) (Also, I'm avoiding the pinyin package for the moment, since my Chinese text will be minimal, and I intend to exert positive control over each Pīnyīn anyway.) –  commonhare Jan 10 '13 at 8:31
Sorry, but I don't know any way to handle an arbitrary number of arguments, let alone forcing an even number of them. That's unfortunate, because I like your idea a lot. –  guillem Jan 10 '13 at 8:53

I haven't tested this to see if it breaks anything, but it seems creating some new commands that pass their arguments to \ruby{}{} might work. This allows you to renew the \rubysep every time as well as apply \textsf only to the Pīnyīn. The example should make things clear.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}

% PACKAGES

\usepackage{fontspec}
\usepackage{xltxtra}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Linux Libertine O}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Linux Biolinum O}
\setmonofont[Scale=MatchLowercase]{Linux Libertine Mono O}
\usepackage{ruby}
\usepackage{setspace}

\begin{document} % ==============================================================

\newfontfamily{\jpn}[Scale=0.85]{Hiragino Kaku Gothic Pro}

\newfontfamily{\chn}{STKaiti}

\doublespace
\Large

I'd like to include both Chinese (e.g. \C{内}{nèi}\C{忧}{yōu}\C{外}{wǎi}\C{患}{huàn}) and Japanese (e.g. \J{内}{ない}\J{憂}{ゆう}\J{外}{がい}\J{患}{かん}) text, \textit{inline} with English text, and with ruby text (pronunciation), as shown here.  Does there exist a convenient method for distributing the \texttt{\textbackslash sf} (or preferably \texttt{\textbackslash textsf\{\}}), across all the \texttt{\textbackslash ruby} calls to generate the Pīnyīn (the text below the Chinese)?

\end{document}


Note: I removed xunicode from the header because it's automatically loaded by fontspec.

-