How to make LaTeX (teTeX) handle unicode and CJK in MacOSX


LaTeX is great for typesetting professional looking scientific / engineering documents, but up till now it has not handled non-roman characters very well. It has taken me a while to find the instructions on how to make it work.

  1. Installation of UCS Package
  2. Installation of CJK Package
  3. Installation of Unicode True Type font (Cyberbit).
    1. download "Cyberbit.ZIP" file from :
      ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP
      Actually there are several .zip files in that directory. uncompress them and you'll get .ttf fonts. But I think all you need is just one.
      • Rename Cyberbit.ttf to lower case (cyberbit.ttf) or else LaTeX might get confused because it is case sensitive.
    2. Install the .tfm and .enc files.
      1. There are two ways to get those files:
        1. Generate the file yourself:
          • download "Unicode.sfd" file from :
            http://delloye.free.fr/Unicode.sfd
          • make sure "Cyberbit.ttf" file and "Unicode.sfd" files are in the same directory
          • from the terminal, go to that directory and run
            % ttf2tfm cyberbit.ttf -w cyberbit@Unicode@
            , in order to create ".tfm" and ".enc" files.
        2. Download: If you cannot run ttf2tfm, you can download the .tfm and .enc files that I generated.
      2. move all the ".tfm" files to an appropriate directory on your local TeX-tree (I put them in I-
        Installer: /usr/local/teTeX/share/texmf.local/fonts/tfm/bitstream/cyberbit/, or
        Fink: /sw/share/texmf-local/fonts/tfm/bitstream/cyberbit/)
      3. move all the ".enc" files to an appropriate directory on your local
        TeX-tree (I put them in
        I-Installer: /usr/local/teTeX/share/texmf.local/pdftex/enc/; or
        Fink: /sw/share/texmf-dist/fonts/enc/pdftex/)
    3. Install "cyberbit.map" file
      1. download from : http://delloye.free.fr/cyberbit.map
      2. move it to an appropriate directory on your local TeX-tree (I put it in
        I-Installer: /usr/local/teTeX/share/texmf.local/pdftex/config/; or
        Fink: /sw/share/texmf-dist/fonts/map/pdftex/updmap/
    4. Install "c70cyberbit.fd" (and optionally .fdv)
      1. file from :
        http://delloye.free.fr/c70cyberbit.fd
        Pai's comment: If you want vertical typesetting, you need a file named c70cyberbit.fdv. -- use this at your own risk! I basically pasted c00bsmi.fdv into the c70cyberbit.fd file to create it.
      2. move it (or both) to an appropriate directory on your local TeX-tree (I put it in
        I-Installer: /usr/local/teTeX/share/texmf.local/tex/misc/, or
        Fink: /sw/share/texmf-local/tex/misc/)
    5. move the "Cyberbit.ttf" (should be renamed cyberbit.ttf -- lower case!!) to an appropriate directory on your local TeX-tree
      (I put it in I-Installer: /usr/local/teTeX/share/texmf.local/fonts/truetype/, or Fink: /sw/share/texmf-local/fonts/truetype/)
      Pai's comment: The following should not be a concern, but if it doesn't work:
      (check in your
      I-Installer: /usr/local/teTeX/share/texmf/web2c/texmf.cnf; or
      Fink: /sw/share/texmf/web2c/texmf.cnf
      file the "%TrueType outline fonts" line and the "TTFONTS" value to make sure it includes the path where your cybebrbit.ttf file is located.)
  4. Declaration of the new font to pdfTeX
    1. open the "pdftex.cfg" file
      (I-Installer: /usr/local/teTeX/share/texmf.local/pdftex/config/pdftex.cfg; or
      Fink: /sw/share/texmf-local/pdftex/config/pdftex.cfg -- though I think if you use Fink, you should use the alternative instruction in part 4.b instead) and add this line
      map +cyberbit.map
      at the end of the file.
      Note: You may have permission problems saving this file. If you know how to use the vi (or pico, probably easier, or emacs) text editor from the command line, your best bet is to cd into that directory and
      % sudo vi pdftex.cfg
      Otherwise, copy this file to a directory you can save, edit, and sudo mv it back to its directory.
    2. [New!]: If you are running TeXLive 2004, you might have to do the following step:
      • (sudo) edit the file /usr/local/teTeX/share/texmf.local/web2c/updmap.cfg
        • add the following line
          Map cyberbit.map
          to the end of the file, save;
          If you are running Fink's distribution, add Map Cyberbit.map to the file
          /sw/share/texmf-dist/web2c/updmap.cfg
      • type the command
        % sudo updmap
        This should re-read all the map files and generate the output files for ps2pk, dvips, pdftex, dvipdfm and run texhash for you. (so you can skip step 4.c)
    3. Update the ls-R files by the command
      % sudo mktexlsr
  5. Using the new environment in LaTeX
    You just need to include the three following lines in the preamble :

    \usepackage[encapsulated]{CJK}
    \usepackage{ucs}
    \usepackage[utf8]{inputenc}
    (for TexLive 2004, use [utf8x] instead of [utf8])
    It may also be convenient to create a new command :
    \newcommand{\cntext}[1]{\begin{CJK}{UTF8}{cyberbit}#1\end{CJK}}

    Now, when you want to type CJK text, you just have to use the command :
    \cntext{enter your CJK text here}

    To do vertical typesetting, just do \usepackage{CJKvert} and CJK characters will be rotated 90 degrees for the vertical orientation.

Pai's comment: Make sure you use an editor such as TeXShop which can save in UTF-8 encoding. Vim also works if you do :set encoding=utf-8 inside vim or in the file ".vimrc" (without colon).

The TrueType unicode font will be embedded for a very smooth looking PDF document.
% pdflatex yourfile.tex


Troubleshooting

Q: I get the error
"mktexpk: don't know how to create bitmap font for cyberbit59." (or something like that)
what do I do?
A: It is most likely your /usr/local/teTeX/share/texmf.local/pdftex/config/pdftex.cfg
file was not updated correctly, or your cyberbit.map file is not there. If you have another stale copy of pdftex.cfg in your current directory (or another directory searched before this one), then pdfTeX looks at it instead. To fix it, remove all stale copies of pdftex.cfg.

By the way, "pk" files are for bitmap fonts, but cyberbit is a TrueType font. This is an indication that your TrueType font file was not found.

Q: I am running TeXLive 2004 but the truetype font can no longer be found, so it keeps trying to make pk font. How do I fix it?
A:

You probably skipped the new step (4.b) above.


Last updated Fri, Oct 31, 2008