2025 TexLive+VScode排版IEEE TGRS论文
本文主要内容:
软件安装
latex 排版 TRGS 论文期间遇到的问题+
清晰图片导出
Latex公式、图、表、算法、参考文献的使用和引用
1. 前言
首先使用Overleaf网页版排版,但是后期排版图片太大,大小有限制,需要充钱,所以放弃了;
之后转战本地排版,需要先下载Texlive(所有的宏和包),之后再下载编辑器;
先下载了TexWork编辑器,但是我认为它不太好用,搜索时高亮不清楚等等;
之后转战vscode编辑器,也遇到了很多问题,下面就进入正片
注:
Overleaf排版TGRS:(3 封私信 / 33 条消息) Overleaf排版IEEE trans.期刊论文 - 知乎
(除了工具不同,公式、图、表、算法等写法皆可参考笔者下文)
安装TexWorks:论文神器teXWorks安装与使用记录-CSDN博客
2. 安装TexLive
点击网址:https://tug.org/texlive/acquire-iso.html
点击进入镜像:
进去之后可能看到的镜像和我下面展示的不同,但是没关系,选择最新的texlive.iso
下载完成后,右击解压texlive.iso到texlive文件夹(安装路径选择英文)
点击进入texlive文件夹,右击install-tl-windows.bat文件以管理员身份运行
之后修改安装路径(和之前的textlive保持一致)
点击advanced——customize,去掉多余的语言,保留三个就好,如下图
点击确定——安装
之后就是漫长的等待
最后安装结束,如果出现下面的情况,不要慌(本人是遇到下面这种情况,但其实是安装完成的)
大家安装到这里可能就一直卡住
上述框出来报错原因是因为安装路径中存在中文,如果有 ,请删掉重新安装
如果安装路径没有中文出现上述情况,请打开下述文件查看是否有“欢迎进入Texlive世界”,如果有九就说明安装完成
之后win+R打开终端,输入下列命令,查看是否安装完成,如果出现安装版本说明安装完成
如果没有出现,请打开查看高级系统设置,配置环境变量
3. 安装vscode
网上教程很多,不再赘述
4. 安装SumatraPDF
网址:https://www.sumatrapdfreader.org/download-free-pdf-viewer
5. vscode配置Latex workshop插件
点击扩展,搜索插件,点击安装
点击设置,打开json配置文件
复制下述配置代码,详细代码讲解请看(5 封私信 / 10 条消息) Visual Studio Code (vscode)配置LaTeX - 知乎这一篇
有些地方需要修改,请继续看下文
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.showContextMenu": true,
"latex-workshop.intellisense.package.enabled": true,
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "D:/Software/texlive/2025/bin/windows/xelatex.exe",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "D:/Software/texlive/2025/bin/windows/pdflatex.exe",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "latexmk",
"command": "D:/Software/texlive/2025/bin/windows/latexmk.exte",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
{
"name": "XeLaTeX",
"tools": [
"xelatex"
]
},
{
"name": "PDFLaTeX",
"tools": [
"pdflatex"
]
},
{
"name": "BibTeX",
"tools": [
"bibtex"
]
},
{
"name": "LaTeXmk",
"tools": [
"latexmk"
]
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
],
"latex-workshop.latex.clean.fileTypes": [
"*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
"*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk"
],
"latex-workshop.latex.autoClean.run": "onFailed",
"latex-workshop.latex.recipe.default": "lastUsed",
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
//使用 SumatraPDF 预览编译好的PDF文件
// 设置VScode内部查看生成的pdf文件
"latex-workshop.view.pdf.viewer": "external",
// PDF查看器用于在\ref上的[View on PDF]链接
"latex-workshop.view.pdf.ref.viewer":"auto",
// 使用外部查看器时要执行的命令。此功能不受官方支持。
"latex-workshop.view.pdf.external.viewer.command": "D:/Software/SumatraPDF/SumatraPDF.exe", // 注意修改路径
// 使用外部查看器时,latex-workshop.view.pdf.external.view .command的参数。此功能不受官方支持。%PDF%是用于生成PDF文件的绝对路径的占位符。
"latex-workshop.view.pdf.external.viewer.args": [
"%PDF%"
],
// 将synctex转发到外部查看器时要执行的命令。此功能不受官方支持。
"latex-workshop.view.pdf.external.synctex.command": "D:/Software/SumatraPDF/SumatraPDF.exe", // 注意修改路径
// latex-workshop.view.pdf.external.synctex的参数。当同步到外部查看器时。%LINE%是行号,%PDF%是生成PDF文件的绝对路径的占位符,%TEX%是触发syncTeX的扩展名为.tex的LaTeX文件路径。
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"\"D:/Microsoft VS Code/Code.exe\" \"D:/Microsoft VS Code/resources/app/out/cli.js\" -r -g \"%f:%l\"", // 注意修改路径
"%PDF%"
]
配置修改1:
下列红色框里的内容可能其他博主写的是xelatex,pdflatex,latexmk
但是我写成那样一直编译不起来,显示下列报错,修改成编译器的绝对路径就好了!!
LaTeX build process spawned with PID undefined.
[10:51:19.300][Build] **LaTeX fatal error on PID undefined**. Error: spawn xelatex ENOENT
[10:51:19.300]**Error: spawn xelatex ENOENT**
at ChildProcess._handle.onexit (node:internal/child_process:285:19)
at onErrorNT (node:internal/child_process:483:16)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
[10:51:19.300][Build] Does the executable exist? $PATH: undefined, $Path:
配置修改2:
换成自己所在的路径
6. TGRS论文模板下载
下载完成后进行解压,用vscode打开所在文件夹
7. .tex文件编译
点击.tex文件,左边出现了TEX插件符号,点击该符号
点击配方:pdflatex→bibtex→pdflatex*2(TGRS论文一般用这个就好,其余的不需要,bibtex是编译参考文献的,一开始没写参考文献可以只用PDFlatex编译)
如果左下角出现√,说明编译成功
输出结果和存在问题查看方式:
编译成功后打开pdf文件:①点击再vscode中查看pdf ② ctrl+alt+v 用之前下载的SumatraaPDF打开pdf
8. 排版遇到的问题
① Cannot find LaTeX root file
解决方法:tex文件开头加上 % !TEX program = pdflatex
②Package hyperref warning: Token not allowed in a PDF string (Unicode):(hyperref) removing ‘math shift’ on input line 2
9. 特殊字符
Latex输入特殊字符#$%&{}_^-<>|_latex &-CSDN博客
10. 公式
如果大家事先在word编辑好的公式,推荐大家截图复制到大模型,让大模型帮助生成对应的latex代码
示例:
占据一行的公式:
\begin{equation} \label{eq1}
\left\{
\begin{array}{ll}
\phi_{1}(x) = \dfrac{1}{\sqrt{2}} \phi_{1,0}(x) + \dfrac{1}{\sqrt{2}} \phi_{1,1}(x), \\
\Psi_{1}(x) = \dfrac{1}{\sqrt{2}} \phi_{1,0}(x) - \dfrac{1}{\sqrt{2}} \phi_{1,1}(x)
\end{array}
\right.
\end{equation}
引用公式:\eqref{eq1} %eq1
是label名称,可自行定义,方便引用
文中里的公式:$\mathrm{\phi_{j,k}(x)}$
11. 图
笔者首先先介绍一下PPT和visio图片导出为png格式,如果有人想要导出为PDF格式插入,请参考其他
PPT导出图片:先设置图像质量高保真——ctrl+A全选所在画图的一页,右击点击另存为图片
visio导出图片:
图片放置半栏,也是是页面的一半
\begin{figure}[!t]
\centering
\includegraphics[width=\columnwidth, keepaspectratio]{images/Fig1.png} %keepaspectratio保持图片横纵比
\caption{图例}
\label{Fig1} %标签,用于引用
\end{figure}
图片放置整行,其实主要再begin和end中多了一个*号
\begin{figure*}[!t]
\centering
\includegraphics[width=\textwidth, keepaspectratio]{images/Fig2.png}
\caption{图例}
\label{Fig2}
\end{figure*}
引用图表:\ref{填写设置的label}
上述两种应该已经够用,如果还有别的需要,可自行查阅资料
12. 表
推荐大家一个在线LaTex表格生成的工具
网址链接:在线 LaTeX 表格 编辑器和生成器 - 表格转换工具
一般表格是三段线,上下两个是粗线
粗线设置:\noalign{\hrule height 1pt}
普通的线设置:\hline
样例展示:
\begin{table}[!ht]
\centering
% \captionsetup{font={small,bf,stretch=1.25}, justification=raggedright}
\caption{标题}
\vspace{-5pt}
\begin{tabular}{ccc}
\noalign{\hrule height 1pt}
Module & Parameters & FLOPs \\ \hline
xxx & xxx & xxxx \\
xxx & xxx & xxxx \\
\noalign{\hrule height 1pt}
\end{tabular}
\label{tab1} %标签名
\vspace{-10pt}
\end{table}
同样的,如果要整行展示表格,begin和end中的table改成table*
引用:\ref{tab1}
13. 算法
写在文件开头的宏
% 定义名为keyword的颜色,RGB值为(1.0, 0.4118, 0.7059),呈现为亮粉色
% 用途:用于标记算法中的关键字(如for、function等)
\definecolor{keyword}{rgb}{1.0, 0.4118, 0.7059}
% 定义名为remark的颜色,RGB值为(0.0, 0.50196, 0.50196),呈现为青绿色
% 用途:通常用于标记注释或说明文字
\definecolor{remark}{rgb}{0.0, 0.50196, 0.50196}
% 重新定义算法环境中的"for"关键字样式,将其设置为keyword颜色
% algorithmic包中默认的\algorithmicfor命令被重写
\algrenewcommand{\algorithmicfor}{\textcolor{keyword}{for}}
% 重新定义算法环境中的"do"关键字样式,设置为keyword颜色并添加冒号
% 修改默认的"do"显示为"do:"并着色
\algrenewcommand{\algorithmicdo}{\textcolor{keyword}{do:}}
% 重新定义算法环境中的"end"关键字样式,设置为keyword颜色
% 用于算法中结束块(如end for、end function)的显示
\algrenewcommand{\algorithmicend}{\textcolor{keyword}{end}}
% 重新定义算法环境中的"function"关键字样式,设置为keyword颜色
% 用于函数定义的开头标记
\algrenewcommand{\algorithmicfunction}{\textcolor{keyword}{function}}
% 重新定义算法环境中的"return"关键字样式,设置为keyword颜色
% 用于函数返回语句的标记
\algrenewcommand{\algorithmicreturn}{\textcolor{keyword}{return}}
% 自定义一个新命令\Class,用于在算法中定义类
% 参数#1是类名,#2是父类,效果为"class 类名 inherits 父类"并着色关键字
\newcommand{\Class}[2]{\State \textcolor{keyword}{class} #1 \textcolor{keyword}{inherits} #2}
% 自定义命令\EndClass,用于标记类定义的结束
% 效果为"end class"并着色关键字
\newcommand{\EndClass}{\State \textcolor{keyword}{end class}}
% 将表格中每行的高度设置为默认的1.2倍
% 增加表格内容的垂直间距,使表格更易读
\renewcommand{\arraystretch}{1.2}
% 定义名为lime的颜色,使用HTML颜色代码A6CE39(一种石灰绿色)
% 可用于后续文本或元素的着色
\definecolor{lime}{HTML}{A6CE39}
参考示例:
笔者建议,可以辅助大模型来写算法的LaTex语句
14. 参考文献
参考文献的插入:
1、再tex同目录下创建ref.bib文件
2、复制参考文献的BibTex格式到bib文件中
免费搜索网址:https://ac.scmor.com/
选择第三个点击进去
如果出不来引用,多刷新几次
插入bib命令:
\bibliographystyle{IEEEtran}
\bibliography{ref}{} % ref是你创建的参考文献bib文件的名字
之后进行编译,但是编译不成功,下面开始找原因
打开终端,输入bibtex .\xx.aux
找到报错文献,进bib进行查看,发现是@software,我这个是直接复制的github上项目的cite引用,但是IEEETran里并不支持software格式,直接改成@misc,就OK啦(这个解决办法网上我搜索了半天没有找到,所以笔者问的大模型,下面是大模型的回答)
在LaTeX中使用@software
类型的引用时出现报错,通常不是因为@software
本身有问题,而是因为你使用的BibTeX样式(.bst文件)不支持这种条目类型。传统的BibTeX样式(如plain、IEEEtran等)只支持有限的条目类型(article、book、inproceedings等),而@software
是较新的扩展类型,用于引用软件或代码仓库。
解决方法有两种:
- 使用支持
@software
的BibTeX样式,如IEEEtran.bst
的更新版本或plainnat.bst
- 将
@software
改为通用的@misc
类型,并保持内容不变:
@misc{Jocher2020yolov5,
author = {Jocher, Glenn},
doi = {10.5281/zenodo.3908559},
license = {AGPL-3.0},
month = may,
title = {{YOLOv5 by Ultralytics}},
url = {<https://github.com/ultralytics/yolov5>},
version = {7.0},
year = {2020}
}
第二种方法更通用,几乎所有BibTeX样式都支持@misc
类型,能解决大多数兼容性问题。
15. 设置引用超链接颜色
\hypersetup{colorlinks=true, citecolor=blue, linkcolor=blue, urlcolor=blue}
16. 感谢参考
有一些参考链接在文中,再次感谢各位笔者的建议
https://zhuanlan.zhihu.com/p/166523064
https://blog.csdn.net/2301_77839359/article/details/143043574
最近几天汇总了latex安装和VScode使用的几个问题,略作整理_latex吧_百度贴吧
(2 封私信 / 4 条消息) LaTex引用公式和图表,超链接点击自动跳转,Latex中使用pdflatex编译eps图片出错 - 知乎