basic CJK support added

This commit is contained in:
Jan Küster 2019-03-10 14:16:23 +01:00
parent b075c1f168
commit c59d2f9adf
2 changed files with 129 additions and 0 deletions

75
cjk/README.md Normal file
View File

@ -0,0 +1,75 @@
# Chinese, Japanese, Korean (CJK) Language Support
## Installation
At first you need to have the CJK LaTeX packages to be installed on your system.
The easiest way is to install install all packages for Chinese, Japanese and KoreaN (CJK) from the apt repositories (Ubuntu Linux):
```bash
sudo apt-get install latex-cjk-all
```
Or install language specific packages:
Chinese only:
```bash
sudo apt-get install texlive-lang-chinese
```
Japanese only:
```bash
sudo apt-get install texlive-lang-japanese
```
Korean only:
```bash
sudo apt-get install texlive-lang-korean
```
(Pull requests with installation instructions for other OS are much appreciated.)
## Import and use the CJK environment
Considering the structure of this repository you can include the `cjk.tex` using the `\input` command using a relative path. You also need to define a `\cjklang` variable, that defines the character set to use.
```
\documentclass[10pt,A4]{article} % just added to demonstrate where to put the \def and input
\usepackage[utf8]{inputenc} % just added to demonstrate where to put the \def and input
\def \cjklang {gbsn} % defines to use gbsn simplified Chinese for this document
\input{../cjk/cjk.tex} % includes the CJK setup script.
% ...
```
That's it.
You can use for `\cjklang` one of the following options:
* Simplified Chinese: `gbsn`or `gkai`
* Traditional Chinese: `bmsi` or `bkai`
* Japnese: `min` (Mincho), `goth` (Gothic) or `maru` (Maru Gothic)
* Korean: `mj` for MyongJu
Note, that there is no need to place the CJK environment inside the document. It is automatically done when including the `cjk.tex` file. The `cjk.tex` script uses the `\AfterEndPreamble` and `\AtEndDocument` hooks to place the environment at the very beginning and end of the document.
If you need more granular environments (e.g. mixing two or more) you can deactivate these hooks and use the `\begin{cjkenv}` and `\end{cjkenv}` in a custom way.
## Troubleshooting
The `cjk.tex` includes the `CJKutf8` package in order to cross-support the typesetting with the UTF-8 based typesetting of the `main.tex` files of the templates. If there is trouble in displaying characters, this may be your first source for troubleshooting.
If there are errors like
```
! PACKAGE INPUTENC ERROR: UNICODE CHAR Ņ<> (U+5173)
(INPUTENC) NOT SET UP FOR USE WITH LATEX.
SEE THE INPUTENC PACKAGE DOCUMENTATION FOR EXPLANATION.
Type H <return> for immediate help.
```
it may be caused, due to the use of the environment inside a header defining command like `\section`.
For troubleshooting such issues see this post: https://tex.stackexchange.com/questions/478696/is-there-a-way-to-make-fancyhdr-with-pagestyle-fancy-to-be-compatible-with-chine

54
cjk/cjk.tex Normal file
View File

@ -0,0 +1,54 @@
%-----------------------------------------------------------------------------------------------------------------------------------------------%
% The MIT License (MIT)
%
% Copyright (c) 2019 Jan Küster
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
% THE SOFTWARE.
%
%
%-----------------------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------
% BASE PACKAGE FOR CHINESE, JAPANESE, KOREAN
%----------------------------------------------------------------------------------------
\usepackage{CJKutf8}
\usepackage{etoolbox}
\def \cjklang {cjklang is not set}
% TYPESETTING DEFINITIONS
% Define the \cjklang inside your document using one of the following options:
% CHINESE TYPESTTING
% use gbsn or gkai for simplified Chinese
% use bmsi or bkai for traditional Chinese
% JAPANESE TYPESETTING
% use min Mincho
% use goth for Gothic
% use maru for Maru Gothic
% KOREAN TYPESETTING
% use mj for MyongJu
\newenvironment{cjkenv}[1]{\begin{CJK*}{UTF8}{\cjklang}}{\end{CJK*}}
% place environment inside document via hooks
\AfterEndPreamble{\begin{cjkenv}}
\AtEndDocument{\end{cjkenv}}