8

I read texdoc cjk and this CJK documentation recommends \usepackage{CJK} to enable CJK functionality. However, I see a lot of examples use \usepackage{CJKutf8}. The CJK package documentation doesn't recommend, or even mention, CJKutf8. What is the difference between these two?

  • CJKutf8 is part of the CJK bundle. CJK offers various encodings which you can choose for each \begin{CJK}\end{CJK}. If you want to use just UTF8 input, you should load the associated package. – LaRiFaRi Jan 15 '15 at 6:36
  • Okay, but the texdoc cjk documentation says to use \usepackage{CJK}{UTF8}{<font>} instead? Same thing? Or CJKutf8 is the old/new way? Something else? – ana Jan 15 '15 at 6:41
  • Oops, I meant that the texdoc cjk documentation says to use \usepackage{CJK} and then \begin{CJK}{UTF8}{...} instead? – ana Jan 15 '15 at 6:46
  • As far as I understand: yes. But just give it a try. And you could add \listfiles to your document and have a look on the loaded packages in your .log-file. If we are talking about different packages here, this should become clearly visible then. – LaRiFaRi Jan 15 '15 at 6:48
11

CJKutf8 package is a part of CJK bundle, it is designed for documents in UTF-8 encoding only, and it actually loads CJK package internally.

The main aim of CJKutf8 package is, to use utf8 option in inputenc package together with CJK package. That is to say, CJKutf8 patches original CJK package to make it work well with inputenc. And it loads inputenc package with utf8 option internally.

Most users do not need to know the technical details. But you can use CJKutf8 to typeset French, German and Chinese in one document easily. That's it.

enter image description here

% !TEX encoding = UTF-8
% !TEX program = pdflatex
\documentclass{article}
\usepackage{CJKutf8}
\usepackage[utf8]{inputenc} % optional
\usepackage[T1]{fontenc}

\begin{document}
% We always use CJK package globally to prevent some bugs.
\begin{CJK}{UTF8}{gbsn}

Without \texttt{CJKutf8} package, the result will be wrong.

Café: 咖啡厅

Gödel: 哥德尔

© 版权所有

\clearpage\end{CJK}
\end{document}
| improve this answer | |
8

In the very first lines of CJKutf8 it has:

\RequirePackage[encapsulated]{CJK}

So to your question in comment: CJKutf8 is newer than CJK.

In discussions on CTeX forum, someone (ti8er) claims that CJKutf8 is able to handle punctuation marks. For example cannot be at the beginning of a line and cannot be at the end of a line.

Moreover, characters in PDFs generated using CJKutf8 is copyable. This is because it generates a good cmap which is recognized by PDF viewers.

The drawback is that there are only two fonts available: gbsn and gkai.

By the way, XeCJK provides even more features including font-tuning. But slow, sadly.

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