3

I know that using the xpinyin package can solve this, but I need to use Lualatex, which is not supported.

At first I used the following code:

\documentclass{ctexart}
\usepackage{amsmath}
\newcommand\zhuyin[2]{$\overset{\textrm{#1}}{#2}$}

\begin{document}
\zhuyin{tiān}{天}
\end{document}

For general Chinese characters, it works very well.

But now I have some rare characters that need to be annotated, they are in the Unicode Extension B area, which means that the normal font does not include them (I've tried fonts like Source Han Sans): 𧉍(U+2724D), 𧉆(U+27246). On my system, it seems that only simsunb.ttf can display them. I'm having trouble changing the font in mathematical mode. I tried the following code and it failed:

\documentclass{ctexart}
\usepackage{amsmath}
\newcommand\zhuyin[2]{$\overset{\textrm{#1}}{#2}$}
\newfontfamily{\zyextb}{simsunb.ttf}[NFSSFamily=simsunb]
\DeclareMathAlphabet{\mathzy}{TU}{simsunb}{m}{n}

\begin{document}
%I also tried \zhuyin{jí}{\zyextb 𧉆}
\zhuyin{jí}{\mathzy 𧉆}
\end{document}

Can you help me?

1
  • This answer suggests that you can use luatexja (developed for Japanese + LuaTeX) for Chinese typesetting too. luatexja (according to the manual) has an add-on luatexja-ruby package for typesetting pronunciation annotations. Maybe you can look into that? Commented Aug 14, 2023 at 1:34

1 Answer 1

2

You can use luatexja-ruby package.

\documentclass{ctexart}
\usepackage{luatexja-ruby}
\newcommand\zhuyin[3][]{\ltjruby[{#1}]{#3}{#2}}
\newCJKfontfamily{\esimsun}{simsun.ttc}[NFSSFamily=esimsun,
  AlternateFont=
    {
      {"20000->"2FA1D}{simsunb.ttf}, 
%      {"30000->"323AF}{simsung.ttf}
    }]

\begin{document}

\zhuyin{tiān}{天}
\zhuyin{jí}{\esimsun 𧉆}

{\esimsun\zhuyin{tiān|jí}{天|𧉆}}

\end{document}

result

CJK characters are JAchar, and their fonts are different from ALchar's. \newfontfamily is using to set ALChar's font.

You can use AlternateFont key to set alternate fonts, so that this font command can switch to another font automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .