4

I'm trying to produce a report using memoir and CJK and seem to keep running into a wall. I was hoping someone on here uses CJK and can point me in the right direction.

First, if I want the entire document to be in Japanese, I can use the \begin{CJK} and \end{CJK} tags immediately after and before the \begin{document} and \end{document} tags respectively, right? The problem is that while I can get Japanese text into the body this way, pdfLaTeX throws an error if I put it in the chapter or title fields. Any ideas why?

Secondly, according to CJK.txt there are three parameters, [<fontencoding>], {<encoding>}, and {<family>}. I'm on Mac OS X and just want to type the Japanese characters directly into my .tex document using the built-in Japanese support (I believe it's called Kotoeri). What encoding and fontencoding settings should I use? The only one I'm having any luck with is UTF-8. Also, "fontencoding" is wrapped in square brackets in the CJK.txt document, but shouldn't they be curly braces? Or do the square brackets indicate it's an optional parameter?

Thirdly, what's a good font family to use, and where should I put the files once I've downloaded them? This example uses the "min" family, but the characters look really sloppy – I'd prefer something that looks more like MS Mincho or Hiragino Mincho Pro. If I have these fonts on my computer (i.e., in Font Book), is that enough for LaTeX to use them, or do I need to download separate font packages for use with LaTeX? If those fonts are accessible, is it enough to enter "Hiragino", for instance, in the "family" parameter of the \begin{CJK} tag, or do I need to do something special?

Finally, have you heard of any incompatibility between the memoir package and CJK?

I had no idea using Japanese in LaTeX was so much work. I guess I'm used to the luxury of a word processor.

Thank you very much for taking the time to look.

1 Answer 1

8

While each of your issues can be addressed in detail, I think the easiest solution for you now is to use XeLaTeX. You can then access any Japanese fonts installed on your operating system.

A minimal example:

\documentclass{memoir}

\usepackage{xeCJK}
\setCJKmainfont{Hiragino Mincho Pro}
\setmainfont{Baskerville}

\usepackage[japanese]{babel}
\renewcommand\chaptername{第}
\addtodef{\afterchapternum}{章}{} % Rather an ugly hack

\begin{document}
\tableofcontents
\chapter{手引}
おはようございます!

\begin{figure}[hbt!]
\centering\Large よろしくお願いします。
\caption{はーい}
\end{figure}

\begin{table}[hbt!]
\centering
\begin{tabular}{c c}
\hline
one & 一\\
two & 二\\
\hline
\end{tabular}
\caption{あれ。}
\end{table}

\section{文章}
何これ?

\end{document}

Remember to process the above code with xelatex , not pdflatex.

I was pleasantly surprised to find that there's a japanese localisation file for babel, and it works with XeLaTeX! So you'll get "目次" instead of "Contents" for the ToC heading, etc. You will have to install the japanese package. (Available on TeXLive and hence MacTeX, but not bundled with MikTeX.) However the chapter labels ("Chapter 1") aren't localised, so we'll have to change that ourselves. It takes two commands to do it, since we need the ordinal prefix before the chapter number, and the chapter name after it.

If you prefer to set the localisation strings manually (or if you have problems with \usepackage[japanese]{babel}:

\renewcommand\contentsname{目次}
\renewcommand\figurename{図}
\renewcommand\tablename{表}
...

See section 18.20 (Words and Phrases) in the memoir manual, where there is a list of strings that you can localise by \renewcommanding them.

Alternatively, there is the ptex platform, which is optimised for Japanese typesetting, but I've never tried it out.

11
  • Thank you so much! This is so much simpler than what I was trying to do. Also, the sectional headings and ToC labels rendered fine – perhaps the package has been updated? Commented Nov 11, 2011 at 3:03
  • 1
    I was pleasantly surprised to discover just now that there's a japanese language file for babel, and it works in XeLaTeX just fine! I've updated my answer accordingly.
    – imnothere
    Commented Nov 11, 2011 at 7:12
  • 1
    You have to install a package named japanese, it's listed in the TeX Live Utility. If all fails, you can still set the localisation strings manually: see my updated answer.
    – imnothere
    Commented Nov 12, 2011 at 7:16
  • 1
    Using xeCJK, you can also use \xeCJKcaption{ja} to load ja.cpx which is included in CJK bundle.
    – Leo Liu
    Commented Dec 3, 2011 at 15:05
  • 1
    @kfmfe04 Try \documentclass{ctexart} or \documentclass{ctexbook}. :)
    – imnothere
    Commented Jan 29, 2012 at 7:43

You must log in to answer this question.

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