Simple configuration of Tex UTF-8 Chinese environment in Ubuntu

Source: Internet
Author: User

There are several options and related methods for configuring the Tex Chinese environment in Ubuntu, some of which are relatively simple (for example, directly using xetex), and some are relatively troublesome (for example, manually generating related fonts ).

Currently, texlive + CJK is the most widely used tool. If you want to make your tex documents universally used in Windows/Linux, this combination is generally used, this is also the most mature (compared with xetex) currently ).

The methods in this article today are made by combining the methods that have been successfully used with the specific environment of ubuntu. Hope to give a reference to anyone who wants to configure the Tex Chinese environment in Ubuntu.

--

First, introduce the most popular method for configuring tex in Linux. Generally, refer to this article:

Http://mailboxpublic.googlepages.com/texlive2007cjkchinesehowto

Download an ISO file of around 1 GB, mount the ISO file, install texlive, and generate relevant font files. General can smoothly configure the Tex + UTF-8 Chinese environment.

However, users who are used to Apt-Get may be reluctant to install the Tex kit from the outside. Therefore, I have referenced some articles and figured out how to use texlive In the Ubuntu source and then manually generate the font package. The advantages are:

  • You do not need to download the 1 gb iso file. You only need to download the several hundred kb font I have prepared to generate the relevant files to use.
  • Only related Tex suites are installed from the Ubuntu source, and other files are not written to the system directory for deletion.
  • You still need to manually generate the font file, but install it in your home directory.

Okay. Please refer to the detailed method:

1. Install texlive + latex + CJK:

Open the terminal and execute the following commands to install texlive and some commonly used latex macro packages (you can add and modify as needed ):

sudo apt-get install texlive texlive-math-extra texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-pictures texlive-science texlive-bibtex-extra texlive-common latex-beamer

If there are plenty of hard disks, you can directly complete the installation:

sudo apt-get install texlive-full latex-beamer

After installation, you can install the CJK software package. If you only need Chinese support, run:

sudo apt-get install latex-cjk-chinese ttf-arphic-* hbf-*

Otherwise, we recommend that you install latex-CJK-all for full support.

Ii. Generate a Chinese character pack

After texlive + CJK is installed, you also need to install a software-fontforge for generating fonts:

sudo apt-get install fontforge

Now, all we have done is standard Debian-based installation. If you don't need it any day, simply remove it.

Before generating a font, prepare the desired font file: simsun. TTC, simhei. TTF, etc. Here we use simsun. TTC () as an example.

Download the following package and decompress it to a place, such as your home directory ~ /Font:

Font.tar.bz2

Then copy simsun. TTC ~ /Font, execute the following command to generate the font map:

cd ~/font
time fontforge -script subfonts.pe simsun.ttc song Unicode.sfd

Time is used to calculate the time. Because it is time-consuming, it takes 40 minutes to generate a song and 24 minutes to generate a Hei under my core 2 Duo t5500.

After the font is generated, create a description file.

In ~ /Font, create a makemap file with the following content:

For I in *. TFM
Do
Cat> song. Map <EOF
$ {I %. TFM }$ {I %. TFM} <$ {I %. TFM}. pfb
EOF
Done

Then run chmod + x makemap on the terminal to add the execution permission to the file, and finally execute:

./makemap

Create a c70song. FD file:

% This is c70song. FD for CJK package.
% Created by Edward G. J. Lee
% Modify by Yue Wang
/Providesfile {c70song. FD}
/Declarefontfamily {C70} {SONG} {/hyphenchar/font/m @ ne}
/Declarefontshape {C70} {SONG} {m} {n} {<-> CJK * SONG }{}
/Declarefontshape {C70} {SONG} {BX} {n} {<-> cjkb * SONG} {/cjkbold}
/Endinput

Okay. All related files have been generated. Copy the font to make it take effect.

Run the following command to generate a hidden personal Tex configuration in your home directory. If you do not need it any day, delete it:

mkdir -p ~/.texmf-var/fonts/map/dvips/CJK
mkdir -p ~/.texmf-var/fonts/tfm/CJK/song
mkdir -p ~/.texmf-var/fonts/type1/CJK/song
mkdir -p ~/.texmf-var/tex/latex/CJK/UTF8

After creating a layered directory, copy the generated font.

cp ~/font/song.map ~/.texmf-var/fonts/map/dvips/CJK
cp ~/font/*.tfm ~/.texmf-var/fonts/tfm/CJK/song
cp ~/font/*.pfb ~/.texmf-var/fonts/type1/CJK/song
cp ~/font/c70song.fd ~/.texmf-var/tex/latex/CJK/UTF8

After the copy is complete, execute the command to refresh the cache and make it take effect:

sudo texhash
updmap --enable Map song.map

Test whether the installed song can be used in any order.

Edit the file anywhere and save it as test. Tex, supporting the UTF-8 format:

/Documentclass {Article}
/Usepackage {cjkutf8}
/Begin {document}
/Begin {CJK} {utf8} {SONG}
Hello! Here is the texlive + CJK environment under Ubuntu!
/End {CJK}
/End {document}

Run the following command to generate a PDF document and use evince to view the document:

pdflatex test.tex
evince test.pdf

Let's see if your process goes smoothly. Is the generated PDF file the same as below?

Use the same method to deal with frequently used Chinese standard fonts such as Hei and Kai. Enjoy your Tex!

References:

Configure the Tex UTF-8 Chinese System on Fedora

Texlive 2007 CJK Chinese howto

Solve latex + CJK in Ubuntu 7.10

Reprint Please note: converted from Linux Desktop Chinese network-In ubuntu simple configuration Tex UTF-8 Chinese Environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.