Conflict between ruby and xeCJK

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.

\documentclass{article}

\usepackage{ruby}

\usepackage{xeCJK}
%\setCJKmainfont{MS Mincho}
%\setCJKsansfont{MS Gothic}
%\setmainfont{Times New Roman}
%\setsansfont{Calibri}

\begin{document}
%\ruby{日}{に}\\
%\ruby{本}{hon}\\
%語\\
Latin text.\\
\textsf{Latin text.}
\end{document}


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 '16 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 '16 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 '16 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 '16 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 '16 at 12:30