Skip to main content

5.4.2 Using AUCTeX with Japanese TeX

To write Japanese text with AUCTeX, you need the versions of TeX and Emacs that support Japanese. AUCTeX supports three Japanese TeX engines by default: NTT jTeX, ASCII pTeX and upTeX.

To use the Japanese TeX engines, activate japanese-plain-tex-mode or japanese-latex-mode. If it doesn’t work, send mail to Masayuki Ataka β€˜<masayuki.ataka@gmail.com>’ or Ikumi Keita β€˜<ikumikeita@jcom.home.ne.jp>’, who currently concern with stuff related to Japanese in AUCTeX. None of the primary AUCTeX maintainers understand Japanese, so they cannot help you.

It is recommended to enable TeX-parse-self for typical Japanese LaTeX users. When enabled, japanese-latex-mode selects the suitable Japanese TeX engine automatically based on the class file name (such as jbook, jsarticle and tjreport) and its option. see Parsing Files.

It is important to select the suitable Japanese TeX engine because the selected engine determines the command name such as β€˜platex’ and β€˜uptex’ to typeset the document. If you find that wrong command is used, check the value of TeX-engine on that buffer. If the value does not suit the current document, change the value by the β€˜TeXing Options’ submenu below the β€˜Command’ menu. see Processor Options.

To make the selected engine to persist across Emacs sessions, there are two ways from which you can choose one according to your needs:

  1. If you use a specific engine (almost) exclusively, customize the option japanese-TeX-engine-default.

    user option japanese-TeX-engine-default​

    The default TeX engine in Japanese TeX mode.

    The default value is β€˜ptex’.

  2. If you want to set the engine on a per file basis, use the file local variables to set TeX-engine.

    Here is a sample code to set TeX-engine to β€˜uptex’:

    %%% Local Variables: %%% mode: japanese-latex %%% TeX-engine: uptex %%% End: 

In the both cases above, the valid value is one of β€˜ptex’, β€˜jtex’ and β€˜uptex’.

You can override the command names associated with the above three engines or define your own engine by customizing TeX-engine-alist. See Processor Options.

It is sometimes necessary to use an engine which differs from the one AUCTeX selects automatically. For example, even when you want to use j-article document class deliberately with ASCII pLaTeX, AUCTeX selects NTT jLaTeX command if TeX-parse-self is enabled, because j-article originally belongs to NTT jLaTeX. In such cases, use the file local variable method above to select the engine you intend to use.

If you usually use AUCTeX in Japanese, setting the following variables is useful.

user option TeX-default-mode​

Mode to enter for a new file when it cannot be determined whether the file is plain TeX or LaTeX or what.

If you want to enter Japanese LaTeX mode whenever this may happen, set the variable like this:

(setq TeX-default-mode 'japanese-latex-mode) 

user option japanese-LaTeX-default-style​

The default style/class when creating a new Japanese LaTeX document.

The default value is β€˜"jarticle"’.

It is recommended also for Japanese users to customize the option TeX-PDF-from-DVI to "Dvipdfmx". See Processor Options

There are three customize options with regard to the encoding of Japanese text.

user option japanese-TeX-use-kanji-opt-flag​

If non-nil, AUCTeX adds -kanji option to the typesetting command when TeX-engine is β€˜ptex’.

Usually AUCTeX guesses the right coding systems for input to and output from the Japanese TeX process, but you can override them by the following two customize options.

user option TeX-japanese-process-input-coding-system​

If non-nil, used for encoding input to Japanese TeX process. When nil, AUCTeX tries to choose suitable coding system.

user option TeX-japanese-process-output-coding-system​

If non-nil, used for decoding output from Japanese TeX process. When nil, AUCTeX tries to choose suitable coding system.

The former customize options japanese-TeX-command-default, japanese-LaTeX-command-default and japanese-TeX-command-list are removed from AUCTeX. Use japanese-TeX-engine-default instead. If you need to customize the executable file name such as β€˜"latex"’, the options for them, or both, customize TeX-engine-alist.

The following two additional font commands are available in LaTeX mode buffer.

C-c C-f g​

Insert gothic face font command β€˜\textgt{βˆ—}’ or β€˜\mathgt{βˆ—}’ depending on the context.

C-c C-f m​

Insert mincho font command β€˜\textmc{βˆ—}’ or β€˜\mathmc{βˆ—}’ depending on the context.

Although they are meaningful only with β€˜ptex’ and β€˜uptex’ engines, it won’t matter in buffers with other engines.

See β€˜tex-jp.el’ for more information.