01_LaTeX环境安装及配置
1.1、安装及HelloWorld
1、下载编辑器
2、测试安装,自动更新
C:\Users\Shaw>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\Shaw>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\Shaw>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\Shaw>tlmgr update -all
tlmgr.pl: package repository https://mirror.ctan.org/systems/texlive/tlnet (not verified: gpg unavailable)
===============================================================================
tlmgr itself needs to be updated.
Please do this via either
tlmgr update --self
or by getting the latest updater for Unix-ish systems:
https://mirror.ctan.org/systems/texlive/tlnet/update-tlmgr-latest.sh
and/or Windows systems:
https://mirror.ctan.org/systems/texlive/tlnet/update-tlmgr-latest.exe
Then continue with other updates as usual.
===============================================================================
tlmgr.pl: An error has occurred. See above messages. Exiting.
C:\Users\Shaw>
3、编译Hello
在test.tex
中写入:
\documentclass{article}
\begin{document}
Hello \LaTeX.
\end{document}
编译latex test.tex
,生成一系列文件*.aux,*.dvi,*.log
。
然后在编译成pdf文件dvipdfmx test.dvi
,生成*.pdf
。
test.tex
可直接使用xelatex test.tex
快速编译得到pdf文件。
4、编写*.bat
脚本
为了防止生成中间文件,使用脚本批处理执行:
新建build.bat
,写入:
latex test.tex
dvipdfmx test.dvi
del *.aux *.dvi *.log
或者新建buildx.bat
,写入:
xelatex test.tex
del *.aux *.dvi *.log
1.2、测试中文
修改test.tex
如下:
\documentclass{article}
\begin{document}
你好,\LaTeX 。
\end{document}
编译执行发现不能正常显式中文。
因为缺失一些东西:
- 保存编码格式必须是
UTF-8
- 引入宏包
\usepackage{ctex}
如下:
1.3、安装配置texstudio
由于命令行+记事本操作复杂,使用texstudio软件方便操作。