• TexLive相当于JDK,TexStudio相当于IntelliJ IDEA,可以方便开发和提高效率。

    01. TexLive的下载与安装

    1.1 下载TexLive

  • 访问TexLive的下载地址:https://www.tug.org/texlive/,点击on DVD。

image.png

  • 点击downloading the TeX Live ISO image and burning your own DVD。

image.png

  • 点击download from a nearby CTAN mirror。

image.png

image.png

  • 下载完成后会得到一个textlive2022.iso的镜像文件。

    1.2 安装TexLive

  • 双击打开textlive2022.iso镜像文件,右键install-tl-windows.bat,以管理员身份运行。

  • 修改以下安装的更目录,然后点击安装按钮即可开始安装。(安装过程很漫长)

image.png

  • 当出现欢迎进入TeX Live的世界!的时候,就说明安装完成了,点击关闭结束安装即可。

image.png

  • 验证安装: ```latex C:\Users\85034>tex -v TeX 3.141592653 (TeX Live 2022) kpathsea version 6.3.4 Copyright 2022 D.E. Knuth. There is NO warranty. Redistribution of this software is covered by the terms of both the TeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the TeX source. Primary author of TeX: D.E. Knuth.

C:\Users\85034>latex -v pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022) kpathsea version 6.3.4 Copyright 2022 Han The Thanh (pdfTeX) et al. There is NO warranty. Redistribution of this software is covered by the terms of both the pdfTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the pdfTeX source. Primary author of pdfTeX: Han The Thanh (pdfTeX) et al. Compiled with libpng 1.6.37; using libpng 1.6.37 Compiled with zlib 1.2.11; using zlib 1.2.11 Compiled with xpdf version 4.03

C:\Users\85034>xelatex -v XeTeX 3.141592653-2.6-0.999994 (TeX Live 2022) kpathsea version 6.3.4 Copyright 2022 SIL International, Jonathan Kew and Khaled Hosny. There is NO warranty. Redistribution of this software is covered by the terms of both the XeTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the XeTeX source. Primary author of XeTeX: Jonathan Kew. Compiled with ICU version 70.1; using 70.1 Compiled with zlib version 1.2.11; using 1.2.11 Compiled with FreeType2 version 2.11.1; using 2.11.1 Compiled with Graphite2 version 1.3.14; using 1.3.14 Compiled with HarfBuzz version 3.4.0; using 3.4.0 Compiled with libpng version 1.6.37; using 1.6.37 Compiled with pplib version v2.05 less toxic i hope Compiled with fontconfig version 2.13.96; using 2.13.96

C:\Users\85034>pdflatex -v pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022) kpathsea version 6.3.4 Copyright 2022 Han The Thanh (pdfTeX) et al. There is NO warranty. Redistribution of this software is covered by the terms of both the pdfTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the pdfTeX source. Primary author of pdfTeX: Han The Thanh (pdfTeX) et al. Compiled with libpng 1.6.37; using libpng 1.6.37 Compiled with zlib 1.2.11; using zlib 1.2.11 Compiled with xpdf version 4.03

  1. <a name="BUtLI"></a>
  2. ### 1.3 更新TexLive
  3. - 在CMD中输入更新命令即可。
  4. ```python
  5. C:\Users\85034>tlmgr update --all

02. 使用命令行实现LaTeX文档的编写

2.1 编译并手动生成PDF

  • 首先在目录中创建一个.tex格式的文件,这里就以text.tex为例。

image.png

  • 用记事本或其他编码工具打开text.tex文件,然后写入以下代码并保存退出。
    • \documentclass{article}:引入article文档类。
      • article文档类是一个用于撰写论文相关操作的文档类。
      • LaTeX的参数都写在一对大括号{}内。
    • \begin{document}表示文档的开始,\end{document}表示文档的结束,文档中的内容要写在begin和end之间。 ```latex \documentclass{article}

\begin{document}

Hello \LaTeX.

\end{document}

  1. - 使用`latex filename.tex`命令编译tex文件,编译会生成`filename.aux``filename.div``filename.log`四个文件。
  2. ```bash
  3. C:\Users\85034\Desktop\LaTeX_Learning>latex text.tex
  4. This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=latex)
  5. restricted \write18 enabled.
  6. entering extended mode
  7. (./text.tex
  8. LaTeX2e <2021-11-15> patch level 1
  9. L3 programming layer <2022-02-24>
  10. (d:/ProfessionalTools/texlive/2022/texmf-dist/tex/latex/base/article.cls
  11. Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
  12. (d:/ProfessionalTools/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
  13. (d:/ProfessionalTools/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-dvi
  14. ps.def)
  15. No file text.aux.
  16. [1] (./text.aux) )
  17. Output written on text.dvi (1 page, 332 bytes).
  18. Transcript written on text.log.
  • 接着用dvipdfmx filename.dvi命令将div文件转换成PDF文件。

    1. C:\Users\85034\Desktop\LaTeX_Learning>dvipdfmx text.dvi
    2. text.dvi -> text.pdf
    3. [1]
    4. 3607 bytes written
  • 此时得到的filename.pdf就是LaTeX的输出文件。

image.png

  • 打开PDF,即可看到写在begin和end之间的内容。

image.png

2.2 编译并自动生成PDF

  • 1.2.1中的方法要用两步才能将.tex文件编译得到PDF文件,但实际上只要用一个xelatex filename.tex命令即可。 ```bash C:\Users\85034\Desktop\LaTeX_Learning 的目录

2022/08/13 20:22

. 2022/08/13 19:56 .. 2022/08/13 19:58 78 text.tex 1 个文件 78 字节 2 个目录 91,487,830,016 可用字节

C:\Users\85034\Desktop\LaTeX_Learning>xelatex text.tex This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex) restricted \write18 enabled. entering extended mode (./text.tex LaTeX2e <2021-11-15> patch level 1 L3 programming layer <2022-02-24> (d:/ProfessionalTools/texlive/2022/texmf-dist/tex/latex/base/article.cls Document Class: article 2021/10/04 v1.4n Standard LaTeX document class (d:/ProfessionalTools/texlive/2022/texmf-dist/tex/latex/base/size10.clo)) (d:/ProfessionalTools/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-xet ex.def (|extractbb —version)) No file text.aux. (d:/ProfessionalTools/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd) [1] (./text.aux) ) Output written on text.pdf (1 page). Transcript written on text.log.

  1. - 这种方式将不在生成`.dvi`文件,而是直接生成PDF文件。
  2. ![image.png](https://cdn.nlark.com/yuque/0/2022/png/2692415/1660393474991-0e53b909-a23b-4351-bb90-6e2cc7532f4b.png#clientId=u331be5b5-d261-4&from=paste&height=95&id=u260d2d0f&originHeight=138&originWidth=723&originalType=binary&ratio=1&rotation=0&showTitle=false&size=9882&status=done&style=none&taskId=uec08651c-ede0-4a8b-8871-1ed7c75538e&title=&width=500)
  3. <a name="Y3Ivf"></a>
  4. ### 2.3 编写带有中文的文档
  5. - 首先要确保`.tex`文件的编码集是UTF-8,然后在文档头部用`\usepackage{ctex}`引入ctex宏包。
  6. ```latex
  7. \documentclass{article}
  8. \usepackage{ctex}
  9. \begin{document}
  10. 你好,\LaTeX。
  11. \end{document}
  • 由于xelatex支持UTF-8编码,因此可以直接使用其编译含有中文的文档。
  • 编译完成后,即可在PDF文档中看见中文信息了。

image.png

03. Tex Studio IDE的安装与使用

3.1 Tex Studio的下载

image.png

3.2 安装Tex Studio

  • 双击打开texstudio-4.3.0-win-qt6.exe文件开始安装,点击下一步。

image.png

  • 自定义安装目录,然后点击安装。

image.png

  • 点击关闭完成安装。

image.png

3.3 Tex Studio的基本使用

3.3.1 切换语言环境

  • 打开TeXstudio应用程序,点击Options >> Configure TeXstudio >> General >> 将Language切换成zh_CN (Chinese) >> 点击OK。

image.png

  • 此时TeXstudio的语言环境就切换成中文了。

image.png

  • 若想切换回去,只需要将Language改回en (English)即可。

    3.3.2 切换默认编译器

  • 因为在日后的编码中可能文档会存在中文,因此需要将LaTeX的编译器切换成xelatex。

  • 点击选项 >> 设置TeXstudio >> 构建 >> 默认编译器 >> 选择并切换成XeLaTeX >> 点击确定。

image.png

3.3.3 用Tex Studio编写LaTeX文档

  • 首先点击新建按钮创建一个tex文档。

image.png

  • 然后在编码区写入LaTeX代码。

image.png

  • 最后点击Run & View按钮编译并运行.tex文件,接着在右侧即可看到文档了。

image.png