0

Inspired by LaTeX package ruby @egreg's suggestion to the problem (Displaying pinyin over Chinese characters, without impacting word spacing) I implemented the following command with example of usage:

\documentclass[a5paper]{article}
\usepackage[heading]{ctex}
\newcommand{\annote}[2]{%
  \leavevmode
  \vbox{\offinterlineskip
    \halign{%\hfil
      ##\hfil\cr
      \strut#2\cr
      \noalign{\vskip-0.3ex}%
      \strut#1\cr}%
  }%
}
\begin{document}

\noindent \annote{床前}{In front my couch,} \annote{明月光,}{there's moonlight}\\
\annote{疑是地上霜。}{It looks like frost on the ground}\\
\annote{举头望}{Looking up} \annote{明月,}{the moon}\\
\annote{低头思}{Looking down missing} \annote{故乡。}{my hometown}

\end{document}

My purpose is to add an annotation to a text phrase. It seems working, but sometimes, I ran into a problem when compiling a LaTeX file with the command, my Ubuntu machine would completely be frozen.

Would you please help me to review and improve?

Here is the output, when it works with XeLaTeX:

enter image description here

  • 2
    We'd need a failing example for debugging. – egreg Oct 7 '19 at 21:19
  • @egreg thanks! I'll try to collect it. By merely reviewing my adaptation of your suggestion, is there anything that I should improve? I almost zero experience of writing LaTeX macro. – Yu Shen Oct 8 '19 at 3:39

Your Answer

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

Browse other questions tagged or ask your own question.