Install Texlive in Ubuntu and set the CTeX Chinese edition

Source: Internet
Author: User
Install Texlive in Ubuntu and set the CTeX Chinese edition. 1. Install texlive20131.1. Download texlive2013: Latest

Install Texlive in Ubuntu and set the CTeX Chinese edition

1 install texlive20131.1 download texlive2013

: Http://ftp.ctex.org/mirrors/CTAN/systems/texlive/Images/texlive2013-20130530.iso

1.2 Mount iso and install texlive2013

Mount the downloaded texlive2013-20130530.iso to the/mnt directory and run install-tl for Installation

1 sudo mount -t -iso9660 -o loop texlive2013-20130530.iso /mnt2 cd /mnt/3 sudo ./install-tl

After the option is displayed, enter I to directly install it. The installation can be completed in a few minutes. After the installation is complete, uninstall the texlive2013-20130530.iso.

1 cd /2 sudo umount /mnt/
1.3 modify Environment Variables

The default installation directory for texlive is/usr/local/texlive/2013/bin/i386-linux/. To enable the shell to automatically find the tex bin file, we need to modify the environment variable PATH.

If we want the system to automatically find the man or info document of texlive, we can modify the environment variables MANPATH and INFOPATH. Open/. bashrc and add the following content in it.

PATH=/usr/local/texlive/2013/bin/i386-linux:$PATH; export PATHMANPATH=/usr/local/texlive/2013/texmf-dist/doc/man:$MANPATH; export MANPATHINFOPATH=/usr/local/texlive/2013/texmf-dist/doc/info:$INFOPATH; export INFOPATH
1.4 test whether the installation is successful

(1) first confirm the tex version we have installed

lienhua34:text$ tex --versionTeX 3.1415926 (TeX Live 2013)kpathsea version 6.1.1Copyright 2013 D.E. Knuth.

(2) Compile a simple tex file and compile it.

Create a test. tex file and enter the following content:

1 \documentclass{article}2 \begin{document}3 Hello \LaTeX!4 \end{document}

Run the following command to generate testbench.

1 lienhua34:text$ xelatex test.tex

Double-click testbench and you will see the following content:

OK. texlive works normally.

(3) Test the ctex package

To enable our texlive support documents, we use ctex to install them. For details about ctex, see http://www.ctex.org/homepage. The texlive installation package carries the ctex macro package. The ctex macro package is/usr/local/texlive/2013/texmf-dist/tex/latex/ctex. Create a ctex. tex file and enter the following content.

1 \ documentclass {ctexart} 2 \ begin {document} 3 Hello, \ LaTeX! 4 \ end {document}

Save and run the following command

1 lienhua34:text$ xelatex ctex.tex

Compilation failed. The xelatex Command reports the following error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! fontspec error: "font-not-found"!! The font "SimSun" cannot be found.!! See the fontspec documentation for further information.!! For immediate help type H 
 
  .!...............................................l.5{SimSun}?
 

This is because the ctex macro package uses a windows character, and my ubuntu does not have a windows character, in this case, the SimSun error cannot be found. We need to configure the font. This is what we will talk about in the next section.

Now we can confirm that our texlive has been installed successfully, but it does not support Chinese characters.

2. Configure the ctex Chinese edition

The ctex macro package provides three font options: nofonts, adobefonts, and winfonts. winfonts is used by default. If you do not use other options to modify the font configuration in the tex source file, you need to install four TrueType fonts in the Windows operating system: simsun and simhei) simfang and simkai ).

If you use the adobefonts option, you need to install Adobe's four OpenType fonts in the operating system: Adobe ,, Adobe, Adobe, and Adobe.

Here we plan to use the nofonts option, and then use the CJK Chinese solution to set the Chinese font that comes with ubuntu to the default Chinese font.

2.1 use the nofonts option to set the font

Run the fc-list: lang-zh command to view the built-in Chinese fonts of ubuntu.

Lien000034: text $ fc-list: lang-zh | sortAr pl UKai CN: style = BookAR PL UKai HK: style = BookAR PL UKai tw mbe: style = BookAR PL UKai TW: style = BookAR PL UMing CN: style = LightAR PL UMing HK: style = LightAR PL UMing tw mbe: style = LightAR PL UMing TW: style = Light... wenQuanYi wide micron black, WenQuanYi and other micron black, WenQuanYi Micro Hei Mono: style = Regular WenQuanYi and other wide and upright black, WenQuanYi and other 正, WenQuanYi Zen Hei Mono: style = Regular 文, Wenquan, WenQuanYi Zen Hei Sharp: style = Regular 文 micron black, Wenquan micron black, WenQuanYi Micro Hei: style = Regular WenQuanYi Hei, WenQuanYi Zheng Hei, WenQuanYi Zen Hei: style = Regular

Open the previous ctex. tex file and enter the following content:

1 \ documentclass [nofonts] {ctexart} 2 \ setCJKmainfont [ItalicFont = {ar pl UKai CN}] {ar pl UMing CN} % set the default Chinese font 3 \ setCJKsansfont {WenQuanYi Zen Hei} % set the font of WenQuanYi zhenghei as the font of the Chinese unlined Line 4 \ setCJKmonofont {WenQuanYi Zen Hei Mono} % set the font of WenQuanYi and other Kuan Zheng Hei as the Chinese typewriter font 5 \ begin {document} 6 good, \ LaTeX! 7 \ end {document}

Save and run the command

1 lienhua34:text$ xelatex ctex.tex

After the ctex.pdf file is compiled successfully, we double-click the ctex.pdf file to open it. The following content is displayed:


OK. Our texlive can process Chinese characters. But...

2.2 customize the mylinuxfonts. sty macro package

Using commands such as setCJKmainfont, we can use texlive to process Chinese characters. However, it is really annoying to write such a command in every Chinese document. We can write this command to the custom macro package file mylinuxfonts. sty, and then use this custom macro package with the command \ usepackage {mylinuxfonts} in the document.

1% mylinuxfonts. sty2 \ ProvidesPackage {mylinuxfonts} 3 \ setCJKmainfont [ItalicFont = {ar pl UKai CN}] {ar pl UMing CN} % set the default Chinese font 4 \ setCJKsansfont {WenQuanYi Zen Hei} % the font of the Chinese unlined line is WenQuanYi zhenhei 5 \ setCJKmonofont {WenQuanYi Zen Hei Mono} %. Set the Chinese typewriter (equal width) font: wenquanyi zhenghei 6 \ endinput

Modify the content of ctex. tex as follows.

1 \ documentclass [nofonts] {ctexart} 2 \ usepackage {mylinuxfonts} 3 \ begin {document} 4 hello, \ LaTeX! 5 \ end {document}

So where can I find mylinuxfonts. sty automatically in texlive? Texlive provides a variable TEXMFHOME (default value ~ /Texmf) to store the macro packages and character bodies installed independently by the user. The macro package file must be stored in the directory TEXMFHOME/tex/latex or its sub-directory. We put mylinuxfonts. sty in the directory ~ /Texmf/tex/latex, and then compile the ctex. tex file. OK, success!

Of course, if you put mylinuxfonts. sty in the directory ~ In/texmf/tex/latex, only the current user can use it. What if we want this macro package to be available to all users who can log on to the current machine? Texlive also provides a variable TEXMFLOCAL (/usr/local/texlive/texmf-local by default), which is used by the system administrator to install additional macro packages or fonts for the entire system. Macro package files must be stored in the TEXMFLOCAL/tex/latex directory or its subdirectories. Put the mylinuxfonts. sty file in this directory.

1 lienhua34:latex$ sudo cp mylinuxfonts.sty /usr/local/texlive/texmf-local/tex/latex/local

Then compile the ctex. tex file, but the system prompts that the "mylinuxfonts. sty" file cannot be found,

This is because the TEXMFLOCAL directory requires a database with updated file names, otherwise the newly added files cannot be found. We can update it by running the mktexlsr command.

lienhua34:latex$ sudo mktexlsrmktexlsr: Updating /usr/local/texlive/2013/texmf-config/ls-R...mktexlsr: Updating /usr/local/texlive/2013/texmf-dist/ls-R...mktexlsr: Updating /usr/local/texlive/2013/../texmf-local/ls-R...mktexlsr: Updating /usr/local/texlive/2013/texmf-var/ls-R...mktexlsr: Done.

Then compile ctex. tex. OK, no problem.

2.3 Configuration Optimization

Now our texlive supports Chinese, but we can optimize our ctex configuration.

Windows fonts are not installed in my ubuntu. By default, ctex uses winfonts as the font configuration option. Therefore, nofonts must be set in each tex document that uses the ctex macro package.

The ctex macro package provides a configuration file ctexopts. cfg. The code in this file will be executed at the beginning of the ctex macro package (after the option definition. We can use this file to set the default options of the ctex macro package.

1 lienhua34:text$ cd /usr/local/texlive/2013/texmf-dist/tex/latex/ctex/cfg2 lienhua34:cfg$ sudo cp ctexopts.cfg.template ctexopts.cfg3 lienhua34:cfg$ sudo vi ctexopts.cfg

Enter the content

1 % ctexopts.cfg: set default options2 \ExecuteOptions{nofonts}3 \endinput

Save and run the mktexlsr command. OK. Now the default font option of the ctex macro package is changed to nofonts.

Ubuntu 12.04 installation with Texlive2012 http://www.linuxidc.com/Linux/2013-05/84540.htm

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-07/120634.htm

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.