How can I place some text centered below other text on the line?

I want to create similar to results to what is found in the ruby package, but instead of placing text above, the extra text is put below the baseline text. In the source code (see ruby.sty), I think I have found the code which places #2 above #1 in \ruby{}{}:

{\@tempdimc \f@size\p@
\@tempdimc \rubysize\@tempdimc
\sbox\z@{\vrule\@height.7\baselineskip\@depth\z@\@width\z@ #1}
    \vrule\@height\z@\@depth.3\baselineskip\@width\z@ #2}
  • It is possible that ruby.sty already provides this feature, but I could not find any mention of this in the documentation (see ruby.txt).

I have also tried these, but the results are a bit different:

  • $\stackrel[below]{above}{middle}$, but I do not need any text above.

  • $\underbrace{above}_{\hbox{below}}$, but I do not need the underbrace.

I would prefer if the format and distance copied that of \ruby{}{}.


This may require some tweaking when using different font sizes, but it seems sufficient in terms of the standard article document class, as shown in the following minimal example:

\ruby duplicate with top/bottom text

\usepackage{ruby}% http://ctan.org/pkg/cjk
\usepackage{lmodern}% http://ctan.org/pkg/lm

  \@tempdimc \f@size\p@
  \@tempdimc \f@size\p@

one \ruby{one}{two} two \ruby{two}{one} one \rubytop{one}{two} two \rubybot{two}{one} one

The two new commands provided are \rubytop{<top>}{<bot>} and \rubybot{<bot>}{<top>}. The former duplicates \ruby{<bot>}{<top>} but uses a tabular, while the latter reverses the process.

ruby is not required if using \rubytop and \rubybot, nor does it have all the other fancy \ruby add-ons (like kern checking). The macros merely duplicate the output.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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