手把手教你在Linux上安裝LaTeX環境

Original artical url:

http://www.ylzx8.cn/linux/linux-unix/280361.html


把手教你在Linux下安裝LaTeX環境

一、LaTeX簡介

LaTeX(LATEX,音譯“拉泰赫”)是一種基於TeX的排版系統,由美國計算機學家萊斯利·蘭伯特(Leslie Lamport)在20世紀80年代初期開發,利用這種格式,即使使用者沒有排版和程序設計的知識也可以充分發揮由TeX所提供的強大功能,能在幾天,甚至幾小時內生成很多具有書籍質量的印刷品

LaTeX在Windows、Linux、Mac OS上都有發行版:

 

 操作系統  發行版  編輯器
Windows  MikTeX  TeXnicCenter、WinEdt
Unix/Linux TeX Live Emacs、vim、Kile
Mac OS MacTeX TeXShop

   

二、LaTeX 下載安裝

首先我們下載TexLive鏡像,這是推薦廈門大學開源軟件鏡像,上面有最新的TexLive 2012 ,下載速度也很可觀。
         http://mirrors.xmu.edu.cn/CTAN/systems/texlive/Images/
下面安裝TexLive:
#cd Downloads
#su
passwd:
# mount -t  <span id="8_nwp" style="width: auto; height: auto; float: none;"><a target=_blank id="8_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?c=news&cf=5&ch=0&di=128&fv=11&jk=d4075488539088f&k=iso&k0=iso&kdi0=0&luki=1&n=10&p=baidu&q=v77y4_cpr&rb=0&rs=1&seller_id=1&sid=8f0839854875400d&ssp2=1&stid=0&t=tpclicked3_hc&tu=u2102575&u=http%3A%2F%2Fwww%2Eylzx8%2Ecn%2Flinux%2Flinux%2Dunix%2F280361%2Ehtml&urlid=0" target="_blank" mpid="8" style="color: rgb(1, 70, 108); text-decoration: none;"><span style="color: rgb(0, 0, 255); width: auto; height: auto;">iso</span></a></span>9660 -o loop texlive2012-20120701.iso /mnt/
mount: warning: /mnt/ seems to be mounted read-only.
#./install-tl 

三、LaTeX 配置
首先我們從別處拷貝需要的字體,比如從Windows的C:/Windows/Fonts下拷貝最常使用的幾種字體:
msyh.ttf(微軟雅黑)  simfang.ttf(仿宋)  simhei.ttf(黑體)  simkai.ttf(楷體)  simsun.ttc(宋體)
比如說我們拷貝到Linux的/home/username/Fonts目錄下:
接下來打開終端進行配置:


# mkdir /usr/share/fonts/winfonts/
# cp ~/Fonts/msyh.ttf /usr/share/fonts/winfonts/  
# cp ~/Fonts/simfang.ttf /usr/share/fonts/winfonts/ 
# cp ~/Fonts/simhei.ttf /usr/share/fonts/winfonts/ 
# cp ~/Fonts/simkai.ttf /usr/share/fonts/winfonts/ 
# cp ~/Fonts/simsun.ttf /usr/share/fonts/winfonts/ 



如果需要更多的字體,使用同樣辦法拷貝即可。
拷貝完成之後一定要注意使用chmod給字體權限
# sudo chmod a+x  /usr/share/fonts/winfonts/ 


接下來再進行下列操作
# cd /usr/share/fonts/winfonts/
# mkfontscale  
# mkfontdir  
# fc-cache

以上命令的作用分別是:爲X字體創建可裁剪的索引,在一個目錄中創建X字體文件的索引,建立字體信息緩存文件。

接下來,使用fc-list 命令查看:
# sudo fc-list :lang=zh-cn

NSimSun,新宋體:<span id="6_nwp" style="width: auto; height: auto; float: none;"><a target=_blank id="6_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?c=news&cf=5&ch=0&di=128&fv=11&jk=d4075488539088f&k=style&k0=style&kdi0=0&luki=7&n=10&p=baidu&q=v77y4_cpr&rb=0&rs=1&seller_id=1&sid=8f0839854875400d&ssp2=1&stid=0&t=tpclicked3_hc&tu=u2102575&u=http%3A%2F%2Fwww%2Eylzx8%2Ecn%2Flinux%2Flinux%2Dunix%2F280361%2Ehtml&urlid=0" target="_blank" mpid="6" style="color: rgb(1, 70, 108); text-decoration: none;"><span style="color: rgb(0, 0, 255); width: auto; height: auto;">style</span></a></span>=Regular
KaiTi,楷體:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
SimSun,宋體:style=RegularUnibit:style=Regular
WenQuanYi Zen Hei,文泉驛正黑,文泉驛正黑:style=Regular
SimHei,黑體:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
WenQuanYi Zen Hei Mono,文泉驛等寬正黑,文泉驛等寬正黑:<span id="7_nwp" style="width: auto; height: auto; float: none;"><a target=_blank id="7_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?c=news&cf=5&ch=0&di=128&fv=11&jk=d4075488539088f&k=style&k0=style&kdi0=0&luki=7&n=10&p=baidu&q=v77y4_cpr&rb=0&rs=1&seller_id=1&sid=8f0839854875400d&ssp2=1&stid=0&t=tpclicked3_hc&tu=u2102575&u=http%3A%2F%2Fwww%2Eylzx8%2Ecn%2Flinux%2Flinux%2Dunix%2F280361%2Ehtml&urlid=0" target="_blank" mpid="7" style="color: rgb(1, 70, 108); text-decoration: none;"><span style="color: rgb(0, 0, 255); width: auto; height: auto;">style</span></a></span>=Regular
WenQuanYi Zen Hei Sharp,文泉驛點陣正黑,文泉驛點陣正黑:style=Regular



最後,咱們根據fc-list命令顯示的信息修改文件/usr/local/texlive/2012/texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.def
# cat /usr/local/texlive/2012/texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.def

  % ctex-xecjk-winfonts.def: Windows 的 xeCJK 字體設置,默認爲六種中易字體  
  % <span id="5_nwp" style="width: auto; height: auto; float: none;"><a target=_blank id="5_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?c=news&cf=5&ch=0&di=128&fv=11&jk=d4075488539088f&k=vim&k0=vim&kdi0=0&luki=9&n=10&p=baidu&q=v77y4_cpr&rb=0&rs=1&seller_id=1&sid=8f0839854875400d&ssp2=1&stid=0&t=tpclicked3_hc&tu=u2102575&u=http%3A%2F%2Fwww%2Eylzx8%2Ecn%2Flinux%2Flinux%2Dunix%2F280361%2Ehtml&urlid=0" target="_blank" mpid="5" style="color: rgb(1, 70, 108); text-decoration: none;"><span style="color: rgb(0, 0, 255); width: auto; height: auto;">vim</span></a></span>:ft=tex  
    
  \setCJKmainfont[BoldFont={SimHei},ItalicFont={[SIMKAI.TTF]}]
    {SimSun}
    \setCJKsansfont{SimHei}
    \setCJKmonofont{[SIMFANG.TTF]}
      
    \setCJKfamilyfont{zhsong}{SimSun}
    \setCJKfamilyfont{zhhei}{SimHei}
    \setCJKfamilyfont{zhkai}{[SIMKAI.TTF]}
    \setCJKfamilyfont{zhfs}{[SIMFANG.TTF]}
    % \setCJKfamilyfont{zhli}{LiSu}
    % \setCJKfamilyfont{zhyou}{YouYuan}
      
    \newcommand*{\songti}{\CJKfamily{zhsong}} % 宋體
    \newcommand*{\heiti}{\CJKfamily{zhhei}}   % 黑體
    \newcommand*{\kaishu}{\CJKfamily{zhkai}}  % 楷書
    \newcommand*{\fangsong}{\CJKfamily{zhfs}} % 仿宋
    % \newcommand*{\lishu}{\CJKfamily{zhli}}    % 隸書
    % \newcommand*{\youyuan}{\CJKfamily{zhyou}} % 幼圓
      
    \endinput 




咱需要對紅色標記的做修改,修改成fc-list上與楷體(或者其他)相關的,我這爲KaiTi,有的環境上爲KaiTi_GB2312,修改需要根據環境上fc-list打印的信息而定。
修改後,咱再來看看:

# cat /usr/local/texlive/2012/texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.def

% ctex-xecjk-winfonts.def: Windows 的 xeCJK 字體設置,默認爲六種中易字體  
% <span id="4_nwp" style="width: auto; height: auto; float: none;"><a target=_blank id="4_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?c=news&cf=5&ch=0&di=128&fv=11&jk=d4075488539088f&k=vim&k0=vim&kdi0=0&luki=9&n=10&p=baidu&q=v77y4_cpr&rb=0&rs=1&seller_id=1&sid=8f0839854875400d&ssp2=1&stid=0&t=tpclicked3_hc&tu=u2102575&u=http%3A%2F%2Fwww%2Eylzx8%2Ecn%2Flinux%2Flinux%2Dunix%2F280361%2Ehtml&urlid=0" target="_blank" mpid="4" style="color: rgb(1, 70, 108); text-decoration: none;"><span style="color: rgb(0, 0, 255); width: auto; height: auto;">vim</span></a></span>:ft=tex  
  
\setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]
  {SimSun}
  \setCJKsansfont{SimHei}
  \setCJKmonofont{[SIMFANG.TTF]}
    
  \setCJKfamilyfont{zhsong}{SimSun}
  \setCJKfamilyfont{zhhei}{SimHei}
  \setCJKfamilyfont{zhkai}{KaiTi}
  \setCJKfamilyfont{zhfs}{[SIMFANG.TTF]}
  % \setCJKfamilyfont{zhli}{LiSu}
  % \setCJKfamilyfont{zhyou}{YouYuan}
    
  \newcommand*{\songti}{\CJKfamily{zhsong}} % 宋體
  \newcommand*{\heiti}{\CJKfamily{zhhei}}   % 黑體
  \newcommand*{\kaishu}{\CJKfamily{zhkai}}  % 楷書
  \newcommand*{\fangsong}{\CJKfamily{zhfs}} % 仿宋
  % \newcommand*{\lishu}{\CJKfamily{zhli}}    % 隸書
  % \newcommand*{\youyuan}{\CJKfamily{zhyou}} % 幼圓
    
  \endinput  


至此,配置完畢。

我在使用xelatex時會有提示,xelatex :command not found 之類的信息,之後通過如下手動配置得以正常使用:
 #vim /etc/bash.bashrc
   在最後添加一行:   PATH=$PATH : /usr/local/texlive/2012/bin/i386-linux/  (這個路徑最好一步一步走,使用自動補全找到,不過一般差異爲最後,64位機器爲x86_64-linux)
  #source /etc/bash.bashrc
之後關閉所有終端,即可!

四、LaTeX學習幫助

LaTeX 學習文檔下載:
http://download.csdn.net/detail/longerzone/4703133
http://download.csdn.net/detail/longerzone/4703238

參考文檔

【1】 http://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf

【2】 http://www.aboutlinux.info/2005/12/adding-windows-fonts-in-linux.html

【3】 http://hi.baidu.com/defeattroy/blog/item/5df1ffcac3348415be09e6de.html

【4】 http://learningloong.blog.163.com/blog/static/1623081242011731102219361/

【5】 http://forum.ubuntu.com.cn/viewtopic.php?f=35&t=350882

【6】http://blog.csdn.net/defeattroy/article/details/7581846

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章