TeXLive 2015 in Linux
Today, I suddenly found that the text in the pdf compiled by xeLaTeX cannot be displayed in Chinese in the built-in viewer and evince of TeXMaker. The text in the text is blank and the English is normal; however, the Chinese characters are displayed normally in FireFox and Chrome browsers.
It is said that the following methods can be implemented for TeXlive in Linux:
1. This method comes from
XeCJK + xeLaTeX, which is probably the best Chinese solution so far.
\ Documentclass {article}
\ Usepackage {xeCJK}
XeCJK uses the Fandole font that comes with TeXLive by default. To be able to compile, you need to install the Chinese fonts of TeXLive to the system. The simplest way is ~ /. Create a soft link under the fonts directory:
Ln-s/opt/texlive/2014/texmf-dist/fonts/opentype/public/fandol ~ /. Fonts/
Then use the xelatex command to compile foo. tex.
2. This method is from. Compared with method 1, this is probably the older TeXlive Implementation of the Chinese and English hybrid sorting method (?).
In a document foo. tex:
\ Documentclass {ctexart}
\ Begin {document}
Hello, \ LaTeX!
\ End {document}
An error occurs if you compile the file directly:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!
!
! Fontspec error: "font-not-found"
!
! The font "SimSun" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!....................................... ........
L.5
{SimSun}
?
This is because the ctex macro package uses the windows system fonts, but there is no windows system fonts or the font name is no longer SimSun in Linux, in this case, the SimSun error cannot be found.
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.
For example:
Idea 1: Let cTeX use the nofonts option, and then use the CJK Chinese solution to set the built-in Chinese font to the default Chinese font.
Step 1: run the fc-list: lang-zh command to view the built-in Chinese fonts of Ubuntu.
$ Fc-list: lang-zh | sort
Ar pl UKai CN: style = Book
Ar pl UKai HK: style = Book
Ar pl UKai tw mbe: style = Book
Ar pl UKai TW: style = Book
Ar pl UMing CN: style = Light
Ar pl UMing HK: style = Light
Ar pl UMing tw mbe: style = Light
Ar pl UMing TW: style = Light
...
WenQuanYi wide micron black, WenQuanYi and other micron black, WenQuanYi Micro Hei Mono: style = Regular
WenQuanYi and other Kuan Zheng Hei, WenQuanYi, and others Zheng Hei, WenQuanYi Zen Hei Mono: style = Regular
WenQuanYi lattice is black, WenQuanYi vertex is black, WenQuanYi Zen Hei Sharp: style = Regular
WenQuanYi micron black, WenQuanYi micron black, WenQuanYi Micro Hei: style = Regular
WenQuanYi zhenghei, WenQuanYi zhenghei, WenQuanYi Zen Hei: style = Regular
Step 2: Use the following font settings at the beginning of the document:
\ Documentclass [nofonts] {ctexart}
\ SetCJKmainfont [ItalicFont = {ar pl UKai CN}] {ar pl UMing CN} % set the default Chinese font
\ SetCJKsansfont {WenQuanYi Zen Hei} % set the font of WenQuanYi zhenghei as the Chinese font without line lining
\ SetCJKmonofont {WenQuanYi Zen Hei Mono} % set wide and black fonts such as WenQuanYi as Chinese typewriter Fonts
\ Begin {document}
Hello, \ LaTeX!
\ End {document}
Then you can use xeLateX for compilation.
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.
So I had a second idea.
Idea 2: Write the preceding command to the custom macro package file mylinuxfonts. and use the custom macro package \ usepackage {mylinuxfonts} in the document.
Create mylinuxfonts. sty as follows:
\ ProvidesPackage {mylinuxfonts}
\ SetCJKmainfont [ItalicFont = {ar pl UKai CN}] {ar pl UMing CN} % set the default Chinese font
\ SetCJKsansfont {WenQuanYi Zen Hei} % set the Chinese unlined font to WenQuanYi zhenhei
\ SetCJKmonofont {WenQuanYi Zen Hei Mono} % set the Chinese typewriter (equal width) font to WenQuanYi zhenghei
\ Endinput
Use the following in the document:
\ Documentclass [nofonts] {ctexart}
\ Usepackage {mylinuxfonts}
\ Begin {document}
Hello, \ LaTeX!
\ End {document}
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 ~ In/texmf/tex/latex, compile the foo. tex file. 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:
Sudo cp mylinuxfonts. sty/usr/local/texlive/texmf-local/tex/latex/local
The TEXMFLOCAL directory requires a database with updated file names. Otherwise, the new file cannot be found. We can update it by running the mktexlsr command.
Optimized configuration provided by the original author:
Now our texlive supports Chinese, but we can optimize our ctex configuration.
As mentioned above, the default font configuration option of ctex is winfonts. Therefore, we need to set the nofonts option 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.
Lien000034: text $ cd/usr/local/texlive/2015/texmf-dist/tex/latex/ctex/cfg
Lien000034: cfg $ sudo cp ctexopts. cfg. template ctexopts. cfg
Lien000034: cfg $ sudo vi ctexopts. cfg
Enter the content
% Ctexopts. cfg: set default options
\ ExecuteOptions {nofonts}
\ Endinput
Save and run the mktexlsr command. OK. Now the default font option of the ctex macro package is changed to nofonts.
This article permanently updates the link address: