[texhax] Typing Chinese with plain TeX

Rodolfo Medina romeomedina at libero.it
Mon Nov 1 19:59:30 CET 2004


Many thanks to all the people from this mailing list
who provided help to this matter:
Edward G.J. Lee, Wouter, Karl Berry, Haruhiko Okumura, Reinhard Kotucha,
and especially Tang, with whom the discussion continued privately.
I'm giving a complete step by step report
(in case it could turn to be useful to somebody else)
of the whole procedure I had to follow
to install ChiTeX first, and then to configure Emacs
to correctly display and input chinese characters.
(I tried to write it carefully,
 but there might be errors and imprecisions.)
Maybe someone will improve and correct this report,
and add some steps or suggest some different ones.
I hope that similar reports about other 'exotic' languages
and writing systems will be written, if they haven't been yet,
and that they are or will be easily found by the users.

The procedure I'm giving does not allow to input
Simplified and Traditional Chinese within the same file.
This is possible using other packages and input methods
like scim and mule-gbk,
but when I installed and tried to use them
other problems and 'side effects' arose,
so I'm not reporting about them.

Rodolfo



-------------------------------------------------------------------------
My operating system: Linux Mandrake 9.1.

1) From http://cxterm.sourceforge.net I downloaded the 5.2.3 version
   of cxterm and installed it with:

   	$ tar xvfz cxterm-5.2.3.tgz
   	$ cd cxterm-5.2.3
   	$ ./configure
   	$ make
   	# make install

   . During the installation, I got the error message

	/usr/bin/ld: cannot find -lncurses

   , so I had to install the package 'libncurses-devel' with the command

	# urpmi libncurses-devel


2) ChiTeX: I went to ftp://ftp.math.ncu.edu.tw/chitex/unix/6.1.2p12lc/
   and downloaded all the files that were there: it's 190 megabyte.
   I created a directory '~/6.1.2p12lc' and put all these files into it.
   In the terminal, in the home directory I gave the command

	$ cxterm

   and a new terminal screen appeared. From this terminal,
   I went into the '~/6.1.2p12lc' directory and gave the command

	# ./setup

   (if necessary, make 'setup' excutable with: '$ chmod +x setup').
   During the installation I was prompted by various messages
   in chinese characters.
   Here's the translation of the most important ones.

   --------------------First message:---------------------------------
          **********************************************
          *                                            *
          *   You are NOT super user "root"            *
          *   You can't perform the installation unless*
          *   you have write permission in the         *
          *   teTeX directory,                         *
          *                                            *
          **********************************************

              c. go on installing
              q. cancel installation

          please type 'c' or 'q' :

   --------------------Second message:--------------------------------
   The directory that has been detected or you have inputed:
           1. The 'texmf' directory (generally is /usr/.../texmf) is:
                /usr/share/texmf
           2. The '*.fmt' files are in the directory (generally is
            /usr/.../texmf/web2c):
                /usr/share/texmf/web2c
           3. .../texfonts directory (generally is /var/tmp/texfonts
           *or* /var/lib/texmf *or* /var/texfonts containing
            subdirectory  tfm, pk etc.) is;
                /var/lib/texmf
             If no such directory, you maybe need to run
              'texmfconfig' to creat this directory.
           4. The executable file 'latex' is in the directory:
                /usr/bin

           Above directorys MUST *not* empty!

           If you make sure all are right, type 'y', otherwise
           type '1' *or* '2' ...
           (in order to correct the wrong directory)
           :

   --------------------Third message:-----------------------------------
   You have said that the directorys are correct:
           Please type 'y' again to confirm, or type 'n' to input
           again
           :

   --------------------Fourth message:----------------------------------
   Two install modes:
           1. run quietly and without asking question.
           2. install through to the end(but will stop to test
           chinese fmt files)

           please type '1' or '2'

   --------------------Fifth message:-----------------------------------
   *** display this message, use the command: *message*
           Anytime you want to know chitex's primary(main) commands,
           use the command:
               *chitex*
           Anytime you want to know internal chinese fonts that can
           be used, use the command:
              *chitex* *-fonts*
           Anytime you want to "test the attached TeX example files",
           "want help" "read the README" etc. use the command:
              *chitex* *-chitexhelp*
           Now you can "Read and test the TeX example files", "Help"
           or "Quit"

           1. Read and test TeX example files.
           2. Help(about ChiTeX).
           b. Return to forefront.
           q. Quit

           Type '1', '2'. 'b' or 'q' to choose one of the above:
   ----------------------------------------------------------------------


3) Now the problem of typing chinese characters in the input file.
   I checked if Emacs could show chinese characters:
   within Emacs, I typed:

	M-x view-hello-file

   and on the line which begins with 'Chinese' I could read
   the chinese characters. Then I typed

	C-u M-x toggle-input-method RET TAB

   and checked that the 'chinese-py' input method was there.
   (If not, installing the 'leim' package may be needed.)


4) Now the problem of *reading* chinese characters in Emacs.
   First I checked the presence of the font name 'fangsong ti'
   in my system with the command

        $ xfontsel

   . I found that font. Then I added to my .emacs the following lines:

	  (create-fontset-from-fontset-spec "-isas-fangsong
         ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0" t)

        (set-language-environment "Chinese-GB")
        (set-selection-coding-system 'cn-gb-2312)
        (set-clipboard-coding-system 'cn-gb-2312)
        ;(set-keyboard-coding-system 'cn-gb-2312)
        (setq locale-coding-system 'cn-gb-2312)
        (set-terminal-coding-system  'chinese-iso-8bit)
        (setq default-input-method 'chinese-py-punct)

   (I cancelled the line about the keyboard coding system
    oherwise I could not input some latin characters
    such as à, è, ù, etc.)

   Then I closed Emacs and reopened it with the example file
   'math1gb.tex' which is featured in the ChiTeX release and... voilà!
   The chinese characters appeared. Now I could both read chinese
   characters, and type them via 'chinese-py' input method.
   This is used to write 'simplified Chinese', widely used in China
   mainland, whereas 'chinese-py-b5' is used to input
   Traditional Chinese, used only in China's Hong Kong and Taiwan district.
   To type 'Hallo', I just did:
	n i 1 h a o 1
   . Besides, I could easily switch from chinese to english input method
   and vice versa just tiping 'C-\'.


5) Now the problem of inputting Traditional Chinese. I opened a new file
   'myfile' with

	$ emacs myfile

   , then did 'C-u C-\ TAB' and select the chinese-py-b5 input method.
   By typing: 'z h o n g TAB 1 1 g u o TAB 2' I got the expression `China'.
   I still could switch to english input method tiping 'C-\'.
   When I saved 'myfile', Emacs asked me to select
   an appropriate coding system. I just selected 'big5'.
   (Anyway, you can select the 'big5' coding system with 'C-x RET f'
    before saving the file.) When I opened 'myfile' I got chaos code,
   because my default coding system was gb2312, so Emacs decoded the file
   with gb2312. Then I closed the 'myfile' buffer,
   did 'C-x RET c TAB' and selected the big5 coding system,
   and then reopened 'myfile' with C-x C-f.
   To avoid getting chaos code, you can also put this line
   as first line of your big5 based file:

            %;; -*-coding: chinese-big5;-*-

   , then Emacs will understand it's a big5 based file,
   and open directly the file with '$ emacs myfile';
   otherwise, open emacs with '$ emacs', do 'C-x RET c', then TAB
   and select the big5 coding system,
   and then open the file with C-x C-f.


6) Configuration of Gnus: I added to ~/.gnus.el the following lines:

        (setq gnus-default-charset 'cn-gb-2312
          gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown
          iso-8859-1))

   in order to handle chinese characters.
   With Gnus I could post and receive email containig cinese characters.


7) Running ChiTeX: if your file, say it 'myfile.tex',
   contains Simplified Chinese, add at the beginning of it
   the first lines of the file 'math1gb.tex' featured in ChiTeX release
   (and at the end of it add the TeX command '\end', of course);
   if your file contains Traditional Chinese
   add at the beginning of it the first lines of the file 'math1.tex'
   also featured in ChiTeX release. Then run ChiTeX with:

	$ chitex myfile







More information about the texhax mailing list