偏偏少年 發表於 2019-12-25 08:03:00

centos 7 安装latex

<p>这里介绍两种不同的配置方法,一种是通过docker,一种是直接ISO进行安装,一种是直接yum install 安装,三种安装方法均需要使用root权限</p>
<p>参考博客:http://yxnchen.github.io/technique/Docker部署ShareLaTeX并简单配置中文环境/</p>
<p>参考博客 https://blog.csdn.net/com_stu_zhang/article/details/81381608</p>
<p>首先安装docker</p>
<pre><code>yum install docker
systemctl start docker
</code></pre>
<p>安装docker镜像</p>
<pre><code>docker pull ubuntu:18.04
</code></pre>
<p>查看下载镜像</p>
<pre><code>docker image ls
</code></pre>
<p>docker run -it --rm ubuntu:18.04 bash</p>
<p>安装latex</p>
<pre><code>sudo apt-get install texlive texlive-science
</code></pre>
<p>安装中文语言包</p>
<pre><code>sudo apt-get install latex-cjk-chinese
</code></pre>
<ul>
<li>制作镜像</li>
</ul>
<p>基于container</p>
<pre><code>exit 退出伪终端后
docker container ls -a
docker commit container-name image-name
docker image ls
</code></pre>
<p>基于dockerfile</p>
<pre><code>FROM ubuntu:18.04
MAINTAINER jeffray zhang
RUN apt update
RUN apt install -y vim
RUN apt install -y texlive texlive-science latex-cjk-chinese
</code></pre>
<p>保存后执行命令生成新image<br>
docker build -t jeffray/latex .</p>
<p>创建docker容器,将host的路径挂载到容器的目录下<br>
docker run -it -v /home/jeffray/latex-workspace:/latex jeffray/latex /bin/bash</p>
<p>在host创建测试文件<br>
/home/jeffray/latex-workspace/test/test.tex<br>
文件内容</p>
<pre><code>\documentclass{article}
\usepackage{CJK}
\begin{document}
\begin{CJK*}{UTF8}{gkai}
测试中文显示
\end{CJK*}
\end{document}
</code></pre>
<p>在容器中进行编译<br>
启动容器 然后进去容器使用</p>
<pre><code>pdflatex test.tex
</code></pre>
<hr>
<p>在centos 7 直接使用root安装texlive</p>
<pre><code> yum -y install texlive texlive-latex texlive-xetex
yum -y install texlive-collection-latex
yum -y install texlive-collection-latexrecommended
yum -y install texlive-xetex-def
yum -y install texlive-collection-xetex
Only if needed:
yum -y install texlive-collection-latexextra
</code></pre>
<p>参考博客https://www.cnblogs.com/dezheng/p/3874434.html</p>
<p>测试latex是否可用,创建文件test.tex</p>
<pre><code>\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{gbsn}
这是一个CJKutf8的例子,使用的字体是gbsn。
\end{CJK}
\end{document}
</code></pre>
<p>使用命令pdflatex可以进行编译,自带的字体只有gbsn(宋体)和gkai(楷体)</p>
<pre><code>pdflatex test.tex
</code></pre>
<p>本来想测试CTEX宏包,发现yum安装的texlive版本太低,不包含这些包,因此使用ISO镜像重新安装新版本</p>
<p>删除yum安装的texlive</p>
<pre><code>yum remove texlive texlive-latex texlive-xetex
yum remove texlive-collection-latex
yum remove texlive-collection-latexrecommended
yum remove texlive-xetex-def
yum remove texlive-collection-xetex
Only if needed:
yum remove texlive-collection-latexextra
</code></pre>
<p>下载ISO镜像</p>
<pre><code>wget http://mirrors.hust.edu.cn/CTAN/systems/texlive/Images/texlive2019-20190410.iso

mount -o loop texlive2017-20170524.iso /mnt/

cd /mnt

./install-t1
</code></pre>
<p>添加环境变量</p>
<pre><code>PATH=/usr/local/texlive/2017/bin/x86_64-linux:$PATH; export PATH
MANPATH=/usr/local/texlive/2017/texmf-dist/doc/man:$MANPATH; export MANPATH
INFOPATH=/usr/local/texlive/2017/texmf-dist/doc/info:$INFOPATH; export INFOPATH
</code></pre>
<p>xelatex编译测试</p>
<pre><code>\documentclass{article}
\usepackage{CTEX}
\begin{document}
这是一个CTEX的utf-8编码例子,{\kaishu 这里是楷体显示},{\songti 这里是宋体显示},{\heiti 这里是黑体显示},{\fangsong 这里是仿宋显示}。
\end{document}
</code></pre>
<p>pdflatex编译测试</p>
<pre><code>\documentclass{article}
\usepackage{CTEX}
\begin{document}
这是一个CTEX的utf-8编码例子,{\kaishu 这里是楷体显示},{\songti 这里是宋体显示},{\heiti 这里是黑体显示},{\fangsong 这里是仿宋显示},{\lishu 这里是隶书显示},{\youyuan 这里是幼圆显示}。
\end{document}
</code></pre><br><br>
来源:https://www.cnblogs.com/raisok/p/12094705.html
頁: [1]
查看完整版本: centos 7 安装latex