2

Furigana seems misaligned in a simple tabular environment. Ruby hacks in MWE are from this answer.

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{ipaexm.ttf}
\usepackage{ruby}
\renewcommand\rubysep{.05ex}
\renewcommand\rubysize{.4}
\let\oldruby\ruby
\def\ruby#1#2{\oldruby{#1}{#2}\futurelet\next\addCJKglue}
\def\addCJKglue{\ifx\next\ruby \CJKglue \fi}
\usepackage{array}

\begin{document} \ruby{一}{いち}\ruby{日}{にち}%Correct \begin{tabular}{|c|} \hline \ruby{一}{いち}\ruby{日}{にち}\%Furigana misaligned \hline \end{tabular} \begin{tabular}{|m{10mm}|} \hline \ruby{一}{いち}\ruby{日}{にち}\%Correct \hline \end{tabular} \end{document}

I would like to understand why the most natural approach with \begin{tabular}{|c|} fails, and how to fix it (as I don't want to manually set up the column width).

Ruby

Matsmath
  • 936

1 Answers1

4

enter image description here

The ruby macro is basing its height on \baselineskip which is 0 in a c column, but you can set it using the array package > declaration.

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{ipaexm.ttf}
\usepackage{ruby}
\renewcommand\rubysep{.05ex}
\renewcommand\rubysize{.4}
\let\oldruby\ruby
\def\ruby#1#2{\oldruby{#1}{#2}\futurelet\next\addCJKglue}
\def\addCJKglue{\ifx\next\ruby \CJKglue \fi}
\usepackage{array}

\begin{document} \ruby{一}{いち}\ruby{日}{にち}%Correct \begin{tabular}{|>{\baselineskip\normalbaselineskip}c|} \hline \ruby{一}{いち}\ruby{日}{にち}\%Furigana misaligned \hline \end{tabular} \begin{tabular}{|m{10mm}|} \hline \ruby{一}{いち}\ruby{日}{にち}\%Correct \hline \end{tabular} \end{document}

David Carlisle
  • 757,742