Traditional and Simplified Chinese in LaTeX

I’ve been in the habit of using LaTeX’s CJK environment across a whole document to allow me to insert, for example, Japanese anywhere I like. However, if you want to have more than one language (not covered by the same font) in the same document (such as both traditional and simplified Chinese, Japanese and Korean, etc), prepare for trouble. You cannot have one CJK environment for the whole document unless you get a font that can handle all the code points (like this elusive, half-free Cyberbit font that seems to be a pain to install).

I found, however, that there is another (and perhaps the intended) way to do it! You can create a command for each individual CJK environment you will need, and use them as needed. For example:

1
2
3
\newcommand{\zht}[1]{\begin{CJK}{UTF8}{bsmi}#1\end{CJK}}
\newcommand{\zhs}[1]{\begin{CJK}{UTF8}{gbsn}#1\end{CJK}}
\newcommand{\zh}[4]{\zht{#1}/\zhs{#2} (\emph{#3}) ``#4''
}

The \zht command is for traditional chinese characters, the \zhs is for simplified, and the \zh uses both (eg to define a word using both variants in hanzi, a transliteration, and a gloss). For example,

1
\zh{藝術}{艺术}{\yi4 \shu4}{art}

will produce

藝術/艺术 (yì shù) “art”

This works great, except that you have to use one of these tags every time you want to switch to a different character set.

NB: When using this method the very first line is not displayed. I got around this by having a dummy line near the top of the document. For example:

1
2
\zht{}  % Dummy environment to get around display bug.
\zht{藝術} % Now this will be displayed.
This entry was posted in LaTeX and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

7 Comments

  1. Posted 2009.09.28 at 03:45 | Permalink

    Dear Goodami,

    I am trying to produce a book with englsih on one side and chinese tradional on the other. What traditional package do I donwload so that I can put it into Latek?
    I have successfully produced the book with simplified by downloading pinyin Chinese, but it doesn’t work with traditional.

    Many thanks

    Bill (Boardman)

  2. goodmami
    Posted 2009.09.28 at 07:06 | Permalink

    Hi Boardman William,

    Part of the command I used before (\begin{CJK}{UTF8}{bsmi}) begins a UTF-8 environment with the font for traditional Chinese (bsmi), and the other (gbsn) is for simplified Chinese. In order for the commands I posted to work, you will need the CJK package for LaTeX (in Ubuntu Linux, this is cjk-latex), as well as the font packages (probably covered by latex-cjk-chinese). You can use other fonts as long as they work with LaTeX and have the correct codepoints. If you use a different font, you will use something other than “bsmi” or “gbsn” in the commands. If you’re running Windows or Mac, I’m not sure what fonts would be appropriate (perhaps the same ones?).

    I hope that helps

  3. Posted 2009.09.30 at 12:53 | Permalink

    Many thanks goodmami for your reply and help. I have tried your code \begin{CJK}{UTF-8}{bsmi} but it doesn’t produce a sensible traditional text.
    I ‘save as’ from the traditional text in word using encoded script. then when the text comes up in notepad I choose either Traditional (Big 5) or (CNS) or (NS 2023). I then get an aski coding which I copy and paste into my latex technic. None of them seems to work and produce sensible traditional Chinese scriptwhen I compile.
    Does windows XP have traditional fonts? If it doesn’t have them, where do I get them from?
    I didn’t have any trouble with simplified script.

  4. goodmami
    Posted 2009.10.09 at 21:05 | Permalink

    Sorry to hear that you’re still having trouble.

    I don’t use Windows so my ability to help troubleshoot your situation is limited. There are a couple things I could suggest though.

    The “bsmi” in the code is the name of the font. It is likely that you don’t have that font in Windows. You will need to either install that font (sorry I don’t know where to get it) or use a different font (and then change the name of the font in the code).

    Also, you should make sure your editor can handle unicode. Notepad can read/display/save unicode, but you should make sure you do “Save As” and select “Unicode” or “Utf-8″ as the encoding. Choosing Ascii will turn the Chinese characters into gibberish.

    Here are a few links that look promising. I hope you can figure out the problem!
    http://www.mackichan.com/index.html?techtalk/555.htm~mainFrame
    http://www.math.nus.edu.sg/aslaksen/cs/cjk.html

  5. Posted 2010.03.24 at 02:51 | Permalink

    Thanks, was looking for a solution to this problem and this is perfect.

  6. alex grossmann
    Posted 2010.06.14 at 03:57 | Permalink

    I would like to input pinyin and get hanzi,uusing latex if possible.
    Alex

  7. goodmami
    Posted 2010.06.14 at 14:05 | Permalink

    Hi Alex,
    I don’t think that is possible using LaTeX. There is a great deal of homophones in the Chinese languages, so LaTeX would not do a good job of selecting the correct hanzi given only the pinyin. Is there a reason you don’t use a Chinese input method (IME) to input the characters?

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>