# Typesetting bopomofo (zhuyinfuhao) on right side of Chinese characters with ruby

I am writing a document mostly in English with a few Chinese examples. I would like to be able to typeset the Chinese characters with bopomofo (zhuyinfuhao) annotations to the right side of the character, e.g., sample image of bopomofo to right, rather than the top/bottom, which I can already do using the ruby package. Is there a way to do this? I'm currently using LaTeX, but would be open to XeTeX, etc., if necessary.

Here's a MWE I can compile using pdflatex, which gets the bopomofo characters on top of the Chinese characters:

\documentclass[11pt]{article}
\usepackage{CJKutf8}
\usepackage{ucs}
\usepackage[encapsulated]{CJK}
\newcommand{\cjktext}[1]{\begin{CJK}{UTF8}{bkai}#1\end{CJK}}
\usepackage[overlap, CJK]{ruby}
\renewcommand{\rubysize}{0.5}
\renewcommand{\rubysep}{0ex}

\begin{document}

\cjktext{\ruby{媽}{ㄇㄚ}}
\cjktext{\ruby{麻}{ㄇㄚ\'{}}}
\cjktext{\ruby{馬}{ㄇㄚ\v{}}}
\cjktext{\ruby{罵}{ㄇㄚ\{}}}

\end{document}


The output with the bopomofo on top looks like this (the tone diacritics aren't quite where they should be, but this is the best I could do):

Many thanks!

• Welcome to TeX.SE! – Mensch Jun 29 '19 at 18:52

A comment:

Some fonts already contain the bopo, like HanWangKaiMediumChuIn:

but that means using fontspec and compiling with xelatex.

Code

\documentclass[12pt]{article}
\usepackage{xcolor}
\pagecolor{red!3}

\usepackage{fontspec}
\newcommand\sampletext{了亶他件}

\setromanfont{HanWangKaiMediumChuIn}

\begin{document}
\section{Sample}
\huge
\sampletext
\end{document}



Another possibility is to use TikZ: see Typesetting furigana above and below original text and alter below to right.

I think there is also a ruby solution - I will search for it.

A tabular within a tabular also works.

Code

% !TeX program = xelatex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\newfontface\fcjk{Noto Sans TC Regular}

\newcommand\fvside[2]{%
\begin{tabular}{cc}%
\Huge #1 & #2\\%
\end{tabular}}%

\newcommand\fvover[2]{%
\begin{tabular}[b]{c}%@{}
#1\\
#2\\
\end{tabular}}

\newcommand\fbpmf[3]{%
\fvside{#1}{\fvover{#2}{#3}}%
}

`