问题描述
使用TeXworks编译运行.tex文件,报错如下:
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/W32TeX) (preloaded format=pdflatex)
restricted \write18 enabled.
Use of uninitialized value $ver in scalar chomp at D:/Program Files/texlive/2020/tlpkg/TeXLive/TLWinGoo.pm line 205.
Use of uninitialized value $ver in substitution (s///) at D:/Program Files/texlive/2020/tlpkg/TeXLive/TLWinGoo.pm line 206.
Use of uninitialized value $ver in substitution (s///) at D:/Program Files/texlive/2020/tlpkg/TeXLive/TLWinGoo.pm line 206.
fmtutil: fmtutil is using the following fmtutil.cnf files (in precedence order):
fmtutil: d:/program files/texlive/2020/texmf-dist/web2c/fmtutil.cnf
fmtutil: fmtutil is using the following fmtutil.cnf file for writing changes:
fmtutil: c:/users/84512/.texlive2020/texmf-config/web2c/fmtutil.cnf
fmtutil [INFO]: writing formats under c:/users/84512/.texlive2020/texmf-var/web2c
fmtutil [INFO]: --- remaking pdflatex with pdftex
Can't spawn "cmd.exe": No such file or directory at d:\Program Files\texlive\2020\texmf-dist\scripts\texlive\fmtutil.pl line 600.
fmtutil [WARNING]: inifile pdflatex.ini for pdflatex/pdftex not found.
fmtutil [INFO]: disabled formats: 5
fmtutil [INFO]: not selected formats: 54
fmtutil [INFO]: failed to build: 1 (pdftex/pdflatex)
fmtutil [INFO]: total formats: 60
fmtutil [INFO]: exiting with status 1
D:\Program Files\texlive\2020\bin\win32\runscript.tlu:915: command failed with exit code 1:
perl.exe "d:\Program Files\texlive\2020\texmf-dist\scripts\texlive\fmtutil.pl" --user --byfmt pdflatex
Running the command D:\Program Files\texlive\2020\bin\win32\fmtutil-user.exe
I can't find the format file `pdflatex.fmt'!
kpathsea: Running mktexfmt pdflatex.fmt
The command name is D:\Program Files\texlive\2020\bin\win32\mktexfmt
产生原因
在使用相关插件生成PDF文件时,需要一些相关包的支持,而在仅装了texlive的情况下,相关包时缺失的,需要自己再手动导入
解决步骤
1、添加环境变量
在系统变量 “PATH” 下,添加“C:\Windows\System32”
2、在命令行窗口执行命令
打开cmd命令行窗口,执行:“fmtutil-sys --all”命令。
如果一切操作无误,正确执行命令的话,系统会用5-10分钟时间装载相关文件。
装了相关包之后,顺利运行tex文件
补充—用latex写论文需要的最基础简洁的环境
安装texlive2020,不懂哪些可以取消,一路默认即可。
它是自带texworks等相关IDE的,可供编辑运行tex文件。
在无任何其他操作的情况下去运行一个hello world的示例程序,就会出现本文的错误,在执行“fmtutil-sys --all”命令后,就满足了用latex写论文的最基本的条件。