1

The XeLaTeX Japanese examples I find on TeX.sx seem to have this issue in common on my system. I'm running MacTeX 2011, fully updated at the time of writing. The following sample

%!TEX TS-program = xelatex
\documentclass{standalone}

\usepackage{xeCJK}
\usepackage{ruby}
\setCJKmainfont{Hiragino Mincho Pro}

\begin{document}

\ruby{学}{がく}\ruby{生}{せい}

\end{document}

gives me this output

enter image description here

I checked Font Book, and the font in the example is present (this happens whatever font I try). In an ideal world I'd like to use Japanese with furigana (ruby text). Is there something wrong with my code, or something not quite right with MacTeX on this system?

  • I have MacTeX2011 as well on one of my computers (MacOSX 10.7.2), and the example you provide compiles fine. (It's "gaku-sen", right?) I do get the following message in the log file: "Could not resolve font Hiragino Mincho Pro/I (it probably doesn't exist)." There seem to be no problems with the regular, bold, and bold-italic variants. You may want to check if the Hiragino Mincho Pro font you have is up-to-date. – Mico Jan 19 '12 at 2:51
  • I have MacTeX 2011 and your MWE compiles fine on my system. – user2473 Jan 19 '12 at 2:52
  • @Mico: The log file indicates no issues, and everything is up to date. Any ideas what's going on? Could it be a document encoding issue? – qubyte Jan 19 '12 at 3:04
  • Damn it, it was a document encoding issue... – qubyte Jan 19 '12 at 3:06
  • I'm not sure this is a dupe, but check How to write Japanese with LaTeX? :) – Alenanno Jan 19 '12 at 15:10
5

It's an encoding issue. Tell TeXShop to use unicode, either through the preferences or a TeXShop directive shown in the following:

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
\documentclass{standalone}

\usepackage{xeCJK}
\usepackage{ruby}
\setCJKmainfont{Hiragino Mincho Pro}

\renewcommand\rubysep{0.1ex}

\begin{document}

\ruby{学}{がく}\ruby{生}{せい}

\end{document}

I've also changed the value of \rubysep to make the spacing a little better.

enter image description here

| 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.