In my preamble I call xeCJK and ruby in order to add ruby text to Japanese characters. I'm compiling with xetex.

Someone mentioned in an earlier post that ruby calls CJK causing a compile error (the document looks fine, though).

How do I avoid this? The documentation for xeCJK is written in Chinese so I can't read it and I can't find ruby's documentation (lots of stuff on the programming language, though).

Before we go any further, here is a MWE as requested.



   %\setCJKmainfont{MS Mincho}
   %\setCJKsansfont{MS Gothic}
   %\setmainfont{Times New Roman}

   Latin text.\\
   \textsf{Latin text.}

The comments are there so that you can play around and see if the errors change given different types of input.

The first error I get (with comments as they are) is:

"xparse/command-already-defined"! See the LaTeX3 documentation for further information.

Swapping the order of xeCJK and ruby produces no errors! Why?

Is there a better package than ruby which will never conflict with xeCJK or a better selection of packages that is less prone to errors?

  • I'll add my preamble once I get home, I'm just on mobile at the moment.
    – jamesh625
    May 26, 2016 at 0:54
  • What's the error? And please add a complete minimal example. We don't need your entire preamble. We do want a complete, small document we can compile to reproduce the issue. The code you post should produce the exact error you report when we compile it.
    – cfr
    May 26, 2016 at 1:02
  • You can't avoid ruby.sty calling cjk.sty. It is itself part of the cjk package and depends essentially on cjk.sty. As far as I can tell, you either find an alternative to ruby or you use cjk rather than xecjk.
    – cfr
    May 26, 2016 at 1:53
  • How can ruby.sty be part of cjk.sty if they are separate packages? Are they always distributed together then?
    – jamesh625
    May 26, 2016 at 4:21
  • 'package' is unfortunately ambiguous. They are separate packages in the sense that they are separate .sty files. But they are part of the same package in the sense that they are part of a single set of files which constitutes a package in CTAN's sense. Here is the MANIFEST for cjk, which lists all files provided by the package, including ruby.sty.
    – cfr
    May 26, 2016 at 12:30

1 Answer 1


You can avoid the error by loading ruby after xecjk.

Be aware that this is cheating: You are only preventing xecjk to detect that you are loading cjk. It is quite possible that you get other conflicts -- ruby and cjk is not written for xelatex. But it could work, if you adapt the \ruby command as shown in this answer:https://tex.stackexchange.com/a/178858/2388

You must log in to answer this question.

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