Welcome 微信登录

首页 / 操作系统 / Linux / LaTeX使用--使用XeLaTeX支持中文(可以放弃Office了)

主机平台:Gentoo 11.2内核版本:Linux Kernel 3.2.1即将面临毕业,要写毕业论文,由于自己一直使用Linux,而Linux下的Office软件兼容性实在是达不到论文的要求,以前也听说过Linux下的强大的排版工具--LaTeX。这样就不会出现换台电脑格式就会发生改变,然后忙着修改论文格式的窘境。下面安装环境,看网络上好多都是使用texlive镜像安装,我看了一下,那镜像2个多G,好大。而且通过CJK解决中文问题(现在还不是很了解)。下面是安装XeLaTeX的步骤在Gentoo下直接emerge即可Gentoo下Xetex和默认安装的texlive-core是互相block的,最终方式是选择安装texlive-xetex模块emerge texlive-xetex -av自动解决依赖问题。XeLaTeX可以直接解决字体的问题,直接使用系统的字体,不用像LaTeX手动生成字体。下面是sheriden2006的中文宏包的一个配置文件(字体得自己安装,可以从网上下载,也可以直接在win下copy)
  1. % xetex/xelatex 字体设定宏包  
  2.   
  3. ProvidesPackage{zhfontcfg}  
  4. usepackage[cm-default]{fontspec} %[cm-default]选项主要用来解决使用数学环境时数学符号不能正常显示的问题  
  5.   
  6. usepackage{xunicode,xltxtra}  
  7. defaultfontfeatures{Mapping=tex-text} %如果没有它,会有一些 tex 特殊字符无法正常使用,比如连字符。  
  8. % 中文断行  
  9. XeTeXlinebreaklocale "zh"  
  10. XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt  
  11. %将系统字体名映射为逻辑字体名称,主要是为了维护的方便  
  12. ewcommandfontnamehei{Microsoft YaHei}  
  13. ewcommandfontnamesong{SimSun}  
  14. ewcommandfontnamekai{AR PL KaitiM GB}  
  15. ewcommandfontnamemono{DejaVu Sans Mono}  
  16. ewcommandfontnameroman{Times New Roman}  
  17. %%设置常用中文字号,方便调用  
  18. ewcommand{erhao}{fontsize{22pt}{aselineskip}selectfont}  
  19. ewcommand{xiaoerhao}{fontsize{18pt}{aselineskip}selectfont}  
  20. ewcommand{sanhao}{fontsize{16pt}{aselineskip}selectfont}  
  21. ewcommand{xiaosanhao}{fontsize{15pt}{aselineskip}selectfont}  
  22. ewcommand{sihao}{fontsize{14pt}{aselineskip}selectfont}  
  23. ewcommand{xiaosihao}{fontsize{12pt}{aselineskip}selectfont}  
  24. ewcommand{wuhao}{fontsize{10.5pt}{aselineskip}selectfont}  
  25. ewcommand{xiaowuhao}{fontsize{9pt}{aselineskip}selectfont}  
  26. ewcommand{liuhao}{fontsize{7.5pt}{aselineskip}selectfont}  
  27. %设置文档正文字体为宋体  
  28. setmainfont[BoldFont=fontnamehei]{fontnamesong}  
  29. setsansfont[BoldFont=fontnamehei]{fontnamekai}  
  30. setmonofont{fontnamemono}  
  31. %楷体  
  32. ewfontinstanceKAI {fontnamekai}  
  33. ewcommand{kai}[1]{{KAI#1}}  
  34. %黑体  
  35. ewfontinstanceHEI{fontnamehei}  
  36. ewcommand{hei}[1]{{HEI#1}}  
  37. %英文  
  38. ewfontinstanceENF{fontnameroman}  
  39. ewcommand{en}[1]{,{ENF#1},}  
下面是一个tex测试文件input.tex
  1. documentclass{article}  
  2.   
  3. usepackage{zhfontcfg}  
  4. usepackage[colorlinks,linkcolor=black]{hyperref}  
  5. %opening  
  6. itle{latex多字体简易示例}  
  7. author{颜开}  
  8. egin{document}  
  9. maketitle  
  10. section{楷体}  
  11. kai{楷体}  
  12. section{黑体}  
  13. hei{黑体}  
  14. end{document}  
使用命令xelatex input.tex 这样就生成了input.pdf文件
Linux双线双网卡双IP双网关设置方法Gentoo Linux--使用日志信息完整卸载软件包相关资讯      Gentoo  latex  XeTeX 
  • LaTex中文编辑入门  (今 16:13)
  • 使用xeCJK解决LaTeX中文问题的最小  (07/27/2015 09:18:25)
  • Linux下优秀的文本编辑器(  (03/04/2015 17:12:13)
  • Gentoo LiveDVD “Choice Edition  (06月01日)
  • LaTeX 入门教程  (03/04/2015 17:20:51)
  • 基于mimeTex的数学公式WebService  (02/26/2015 15:32:59)
本文评论 查看全部评论 (1)
表情: 姓名: 字数


评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款