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?

qubyte
  • 17,299
  • 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 02:51
  • I have MacTeX 2011 and your MWE compiles fine on my system. – user2473 Jan 19 '12 at 02: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 03:04
  • Damn it, it was a document encoding issue... – qubyte Jan 19 '12 at 03:06
  • I'm not sure this is a dupe, but check How to write Japanese with LaTeX? :) – Alenanno Jan 19 '12 at 15:10
  • @Alenanno: Seems not a dupe, since none of the answers addressed encoding. – qubyte Jan 19 '12 at 15:25
  • @MarkS.Everitt Ah ok. I'm not very expert at LaTeX so I thought of giving you the link... :P – Alenanno Jan 19 '12 at 15:27
  • @Alenanno: Thanks for pointing me to it though. I'm not an expert either! – qubyte Jan 19 '12 at 16:02

1 Answers1

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

qubyte
  • 17,299