教程:在Linux(Ubuntu/Debian)中编译中文TeX文件
\documentclass{article}
\begin{document}
\title{Texlive on Linux with Chinese support}
\author{Van Abel}
\begin{abstract}
本教程并非手把手的教你如何在Linux机器上编译中文文件. 而是我作为尝试编译ustcthesis的一个学习记录.
\end{abstract}
\tableofcontents
\section{Install of texlive}
A lot of people will try to tell you install texlive by hand (download the texlive2014.iso), but I find it is about 2.5G, so why not just install texlive form the apt-get?
I follow here:
apt-get install texlive apt-get install texlive-xetex
of course this will not make chinese support for texlive.
\section{Chinese Support}
There are two method of texlive to support chinese. One is xecjk method, the other is cjk.
\subsection{xecjk method}
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{Adobe Song Std}
\begin{document}
hi, this is xelatex!
这是中文测试!
\end{document}
The results is, after compile as xelatex test_zh.tex, test_zh.pdf
\subsubsection{File used}
\begin{enumerate}
\item The test_zh.tex source file
\item Need to download Adobe.7z Adobe Fonts and 7zr e Adobe.7z -w /usr/share/fonts/winfonts/ (create ‘winfonts’ directory first)
\item Refreash your font cache as here.
\item Need to modify /usr/share/texlive/texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.def (please adapt it to your installation of texlive) as in the file ctex-xecjk-winfonts.def
\end{enumerate}
If you have other problems, please take a look at the end of this post!
\subsection{cjk method}
\documentclass[UTF8]{ctexart}
\begin{document}
Hi, Ctex!
你好, Ctex!
\end{document}
firstly, let us compile is as latex test_ctex.tex, this will output test_ctex.dvi
Secondly, in order to make pdflatex work, we need the following:
\subsubsection{File used}
\begin{enumerate}
\item The test_ctex.tex source file
\item Need to download Win7Fonts.7z and extract to the same dir as before
\item Need to modify the file /usr/share/texlive/texmf-dist/tex/generic/zhmetrics/zhwinfonts.tex as zhwinfonts.tex
\item Need to add export OSFONTDIR=/usr/share/fonts/winfonts/ in ~/.bash_profile
\end{enumerate}
And finally, we will get, after complie as pdflatex test_ctex.tex test_ctex.pdf
\section{Reference}
\begin{enumerate}
\item Ubuntu下安装TeX Live并配置中文支持
\item UnixFonts
\item $OSFONTDIR on OSX
\end{enumerate}
\section{Techological Remark}
\begin{itemize}
\item If there are some missing sty files, try to use
apt-cache search the-missing-sty | grep tex
where the-missing-sty are replaced by the sty file name
and then use sudo apt-get install the-find-package to install.
I finally installed the following package
sudo apt-get install latex-cjk-chinese texlive-bibtex-extra texlive-math-extra texlive-science texlive-science-doc texlive-latex-extra
\item you can also install the missing package by
tlmgr install the-missing-package
\item If tlmgr report the error:
cannot setup TLPDB in /root/texmf at /usr/bin/tlmgr line 5336.
please try tlmgr init-usertree, I get the solution from here
\item If tlmgr report the error:
/usr/bin/tlmgr: Please install xzdec and try again.
Then try
sudo apt-get install xzdec
\item If you find some package can’t be installed successfully by tlmgr, then try to install it by hand. This is not so hard at all, as an example, let me show you how to install bbm.sty
\begin{enumerate}
\item Firstly, just go http://www.ctan.org/ to search bbm at the top bar
\item It will show you that there are two packages, one is the font package bbm, and the other is the macros package bbm-macros, we need to install both of them
\item click the link of font package bbm, we can see the sources is /fonts/cm/bbm, then download all the package by click the link at the bottom, to the directory ~/texmf/fonts/cm/bbm, maybe you have already noticed that we put the source in the local directory texmf.
\item Refreash the database of texlive by the command mktexlsr, which will tell texlive where the package is located.
\item Similarly to install the macro package bbm-macros.
\end{enumerate}
\end{itemize}
\section{Test of ustcthesis}
At last, you can compile ustcthesis easily, The uploading file has correct the error mentioned here. which is caused by the too old version of ctex, I think.
And how about have a look at the final result: preview of ustcthesis.
\end{document}

some error happened still:
(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty)kpathsea:make_tex: Invalid fontname `Times New Roman’, contains ‘ ‘
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: “font-not-found”
!
! The font “Times New Roman” cannot be found.
Have you ever seen his problem?
How to solve it?
Thank you.
I believe the problem is missing Times New Roman, since it is not inclued by texlive as distribution. See here for a solution suggestion: http://tex.stackexchange.com/a/273560/19832.
By the way, I did not test the texlive with english complie (as my goal is to compile chinese USTCThesis), if you want to test texlive, try to begin with very simple tex file, such as only one line on wiki: tex ’empty Hello world!bye’