写在开头:这篇博文是我自己在使用latex的时候的一些安装过程的记录,所以要注意你的环境和我的是否相同,如果不是一样的,那么博文中提到的解决方案,都只能具有一定的参考价值,切勿直接试.
系统环境:Ubuntu14.04,latex版本应该没有影响
所以安装的过程都是手动安装texlive和texmaker,最推荐的安装方式!不管你是新手,还是老手.
——————————————————–正文分割线————————————————————-
2017.10.12 更新 : 今天在一台新的机子上配环境,结果在安装texmaker的时候找不到对应Ubuntu14.04的包,在官网上 也只能下载到17.07的包,而我又不太想用源码安装,找了很久的ubuntu14.04对应的安装包,终于找到了一个网站,下面分享给大家,
网址
sudo dpkg -i texmaker_4.1-1_amd64.deb
#如果出现了依赖问题,如下图,那么安装缺少的依赖,直接执行
sudo apt-get install -f
在测试texmaker的时候出现了”command not find”的报错,解决方案:在options->configure texmaker页面中的第二行
改成:
如果你想用quick bulid编译支持中文输入(F1快捷键):
其中前缀就是我们手动安装texlive的地址
分析:为什么会需要改命令格式?
1.texmaker在运行latex命令时是通过终端PATH(环境变量)的机制访问到的latex命令.如果你在.bashrc中加入了
PATH= "/usr/local/texlive/2017/bin/x86_64-linux/:$PATH"
在终端运行latex,会看到下面的输出
2.为什么在终端能运行,但是在texmaker中就会出现”command not found”呢?
可能原因
1.就是texmaker执行命令的时候,并没有开启终端,
2.或者开启的终端(比如运行的不是本机用户而是他自己新创的一个用户)不会运行.bashrc文件,导致PATH里面并没有latex的命令地址,所以就导致”command not find”
为latex添加中文支持
测试代码:
\documentclass{article}
\usepackage{ctex}
\begin{document}
hello rhuths
你好
jjfff
还不错
\end{document}
使用xelatex编译
—————————————————————–分割线—————————————————————————
尽管大部分常见Linux系统的包管理器内都会包含texlive,然而最好还是安装TUG发布的原版TeX Live。这是由于:1,软件仓库内的TeX Live 通常版本较陈旧;2,由于版权因素一些tex宏包没有被软件仓库收录;3,软件仓库内的TeX Live分割混乱,更新和维护都不方便,事实上,TeX Live 本身的TDS结构就已经相当清晰完善了。
所以这篇文章写的是关于如何手动安装texlive2016,并完善texlive包管理。
texlive-full+编辑器texmaker
简单介绍
TEX
学习latex,不管是在调编译器还是正常敲代码的过程中,肯定会遇到很多关于tex的名词。如果不理解他们之间的关系,就很难理解如何去做,云里雾里的,所以先聊一下我们经常能听到的各种名词的关系
下面的图是刘海洋教授的Latex入门这本书里面的:
1.Tex,pdfTex,xeTex,LuaTex均为编译的引擎,也就是用他们来编译我们所写的tex代码成文档,其中tex是最基础的引擎,其他的都是后来对于tex的改进。xeTex和LuaTex都默认支持utf-8,而tex默认支持的是ASCII,所以对于中文我们大多数使xetex引擎
2.PlainTex,Latex,ConText都是编写格式,引擎基本都可以解析,不过要采用不同的解析命令,当然不同的引擎解析的结果也都不同。
3.对于前两行的解析命令生成的是dvi文档格式,后三行解析命令生成的是pdf文档格式。对于我们使用Latex和xetex引擎的,一般使用xelatex命令
发行套装
可能有人会不理解texlive和tex到底是什么关系?其实他们不是一个层面的东西。texlive和ctex都是tex的发行套装,是tex各种引擎,命令,宏包的一个大集合,他不是一个新的东西,只是所有已存在的东西的一个集合。
1.ctex,如果你是新手,并且使用的是windows系统,那么这个应该是最好的选择,因为他处理中文非常出色。
2.textlive,如果你使用的不是windows系统,也不用担心,因为texlive就是适合所有系统使用的。你可以通过一番设置,比如ctex宏包,或者xeCKJ宏包自己实现。
我们使用的是texlive
texlive的安装
本来想自己写,感觉没有必要,我是根据这个链接中所讲的过程来的。链接:http://www.linuxidc.com/Linux/2016-08/133913.htm
(安装过程就是将数据拷贝到指定的文件夹,然后在几个常用的命令设置文件中添加数据,确保在终端可以使用tex等命令)
就像他说的,如果你使用过apt-get安装过,那么要全部卸载之后才能继续安装。亲测如果不卸载在安装过程中也没有问题,只是在dummy package过程会出错。
网上给的卸载方法(有的话就卸载,没有就不用删了):
sudo apt-get purge texlive*
rm -rf /usr/local/texlive/2013 and rm -rf ~/.texlive2013
rm -rf /usr/local/share/texmf
rm -rf /var/lib/texmf
rm -rf /etc/texmf
sudo apt-get remove tex-common --purge
rm -rf ~/.texlive
dummy package
texlive2016安装之后需要“告诉”系统texlive相关软件包都安装好了。这样在系统安装依赖于tex的软件(比如R)时就不必重新下载软件仓库中的旧版 texlive 相关软件。也不会造成不同版本 tex 命令的冲突。dummy package 就是解决这样的软件依赖问题的“虚包”。
制作
$ sudo aptitude install equivs # as root
$ sudo mkdir /tmp/tl-equivs && cd /tmp/tl-equivs
$ sudo equivs-control texlive-local
#edit texlive-local (see below)
$ sudo gedit texlive-local
$ sudo equivs-build texlive-local
将下面的内容复制到texlive-local文件中:
Section: misc
Priority: optional
Standards-Version: 3.9.8
Package: texlive-local
Version: 2016-2
Maintainer: you <you@yourdomain.example.org>
Provides: chktex, biblatex, biblatex-dw, cm-super, cm-super-minimal, context,
dvidvi, dvipng, feynmf, fragmaster, jadetex, lacheck, latex-beamer,
latex-cjk-all, latex-cjk-chinese, latex-cjk-chinese-arphic-bkai00mp,
latex-cjk-chinese-arphic-bsmi00lp, latex-cjk-chinese-arphic-gbsn00lp,
latex-cjk-chinese-arphic-gkai00mp, latex-cjk-common, latex-cjk-japanese,
latex-cjk-japanese-wadalab, latex-cjk-korean, latex-cjk-thai, latexdiff,
latexmk, latex-sanskrit, latex-xcolor, lcdf-typetools, lmodern, luatex,
musixtex, passivetex, pgf, preview-latex-style, prosper, ps2eps, psutils,
purifyeps, t1utils, tex4ht, tex4ht-common, tex-gyre, texlive, texlive-base,
texlive-bibtex-extra, texlive-binaries, texlive-common, texlive-extra-utils,
texlive-fonts-extra, texlive-fonts-extra-doc, texlive-fonts-recommended,
texlive-fonts-recommended-doc, texlive-font-utils, texlive-formats-extra,
texlive-games, texlive-generic-extra, texlive-generic-recommended,
texlive-humanities, texlive-humanities-doc, texlive-lang-african,
texlive-lang-all, texlive-lang-arabic, texlive-lang-cjk, texlive-lang-cyrillic,
texlive-lang-czechslovak, texlive-lang-english, texlive-lang-european,
texlive-lang-japanese, texlive-lang-chinese, texlive-lang-korean,
texlive-lang-french, texlive-lang-german, texlive-lang-greek,
texlive-lang-indic, texlive-lang-italian, texlive-lang-other,
texlive-lang-polish, texlive-lang-portuguese, texlive-lang-spanish,
texlive-latex-base, texlive-latex-base-doc, texlive-latex-extra,
texlive-latex-extra-doc, texlive-latex-recommended,
texlive-latex-recommended-doc, texlive-luatex, texlive-math-extra,
texlive-metapost, texlive-metapost-doc, texlive-music,
texlive-omega, texlive-pictures, texlive-pictures-doc, texlive-plain-extra,
texlive-pstricks, texlive-pstricks-doc, texlive-publishers,
texlive-publishers-doc, texlive-science, texlive-science-doc, texlive-xetex,
thailatex, tipa, tipa-doc, xindy, xindy-rules, xmltex, asymptote, texinfo
Depends: freeglut3
Architecture: all
Description: My local installation of TeX Live 2016.
A full "vanilla" TeX Live 2016
http://tug.org/texlive/debian#vanilla
注:上面这个是2016版本的texlive,其他版本可以访问官网
然后直接安装:
$ sudo dpkg -i texlive-local_2016-1_all.deb
安装成功的图:
如果安装失败,比如这样:
是因为没有卸载干净,运行:
dpkg -l | grep texlive(查看是不是没有卸载干净)
sudo apt-get purge texlive*
dummy package的作用
没安装虚包之前:
安装虚包之后:
当然虚包有人已经制作好了,可以直接下载:
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2016年资料/8月/4日/Linux 系统下原版 TeX Live 2016 的安装与配置/
下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm
手动安装是清楚的知道,自己使用的是哪个版本,已经自己安装的东西在什么地方,如果想要卸载,直接删除/usr/local/texlive文件夹就可以,而且他自带的包管理命令也是方便了我们进行包的更新和管理,所以我推荐如果要是安装texlive还是手动安装比较方便之后的管理。
——2016.12.31