论文3 VScode&texlive&SumatraPDF打造完美书写论文工具

本文详细介绍了如何在Windows环境下配置LaTeX写作环境,包括下载与安装texlive2020、VScode及SumatraPDF,设置VScode LaTeX插件和编译逻辑,以及解决中文路径编译问题。还提供了IEEE论文模板的测试和表格操作方法,为LaTeX初学者提供了一站式的环境搭建方案。
摘要由CSDN通过智能技术生成

介绍一下:

  • exlive 后台编译器, 将写好的论文检测语法, 生成pdf
  • VScode 写论文的编辑器
  • SumatraPDF 实时pdf查看器, 能够实时的查看新编译好的PDF

一. 软件下载安装

1.1 下载

这两个软件都是免费的, texlive只需要找到下载源即可

1.2 安装编译器texlive2020

  • 安装时设置一下路径即可, 因为对texlive不熟, 所以很多插件就都安装一下吧, 虽然用的空间有点大,但是至少后面问题会出现的少一点.
  • 等待很长时间之后, 安装完毕, 打开cmd查看一下是否安装完毕
PS C:\Users\Admin> tex -version
TeX 3.14159265 (TeX Live 2020/W32TeX)
kpathsea version 6.3.2
Copyright 2020 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.

1.3 安装PDF阅读器

直接将pdf阅读器smartPDF下载复制粘贴解压到随便的一个没有中文目录的路径下, 如"D:\software\SumatraPDF\SumatraPDF-3.2-64.exe"

在这里插入图片描述

1.4 编辑器VScode

a. 直接百度或者软件管理下载默认安装

即可, 因为该软件实在是啥都能干

b. 给VScode安装论文编辑相关插件

因为VScode是一个开源软件, 很多功能需要安装插件完成
打开VScode搜索LaTeX,安装下面三个插件
在这里插入图片描述

c. 配置编辑环境

  • 按F 输入set 打开设置
    在这里插入图片描述

  • 在打开的settings.json文件中 {} 内输入下面的代码, 然后重新启动VS
    只需要添加 "// 下面是latex工作环境配置"注释的即可

{
    "window.zoomLevel": 1,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",

    // 下面是latex工作环境配置
    "latex-workshop.latex.recipes": [
      { "name": "latexmk","tools": ["latexmk"]}, 
    ],
    // 下面是LaTeX指令运行逻辑
    "latex-workshop.latex.tools": [
      {"name": "latexmk", "command": "latexmk",
      "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf",  "%DOC%" ]
      }, 
      {"name": "bibtex", "command": "bibtex", "args": ["%DOCFILE%" ] }],
      
      // 下面是latex工作环境中pdf阅读的配置
      "latex-workshop.view.pdf.viewer": "external",
      "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"
      ],
      "editor.minimap.enabled": false,
      // "latex-workshop.view.pdf.viewer": "external",
      "latex-workshop.view.pdf.external.viewer.command": "D:\\software\\SumatraPDF\\SumatraPDF-3.2-64.exe",
      "latex-workshop.view.pdf.external.viewer.args": [
          "-forward-search",  "%TEX%",   "%LINE%",
          "-reuse-instance",  "-inverse-search",
          "\"C:/.../Microsoft VS Code/Code.exe\" \"C:/.../Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
          "%PDF%"
      ],
      "workbench.editorAssociations": [
        {
          "viewType": "jupyter.notebook.ipynb",
          "filenamePattern": "*.ipynb"
        }
      ],
}
  • 下面这个配置是三种不同的编译逻辑, 不过感觉上面的一种编译逻辑就够用了, 下面的可以随便了解一下, 而且下面的的编译逻辑编译论文的时候出错性更多, 如果有懂原理的可以不吝赐教呀.
{
    "window.zoomLevel": 1,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",

    // 下面是latex工作环境配置
    "latex-workshop.latex.recipes": [
      {"name": "xelatex","tools": ["xelatex"]}, 
      { "name": "latexmk","tools": ["latexmk"]}, 
      { "name": "pdflatex -> bibtex -> pdflatex*2",
        "tools": ["pdflatex","bibtex", "pdflatex", "pdflatex" ]
      },
      {  "name": "xelatex -> bibtex -> xelatex*2",
        "tools": ["xelatex","bibtex","xelatex", "xelatex"]
      }
    ],
    "latex-workshop.latex.tools": [
      {"name": "latexmk", "command": "latexmk",
      "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf",  "%DOC%" ]
      }, 
      {"name": "xelatex", "command": "xelatex",
      "args": ["-synctex=1", "-interaction=nonstopmode",  "-file-line-error", "%DOC%" ]
      }, 
      { "name": "pdflatex", "command": "pdflatex",
      "args": ["-synctex=1", "-interaction=nonstopmode", "-file-line-error",  "%DOC%" ]
      }, 
      {"name": "bibtex", "command": "bibtex", "args": ["%DOCFILE%" ] }],
      // 下面是latex工作环境中pdf阅读的配置
      "latex-workshop.view.pdf.viewer": "external",
      "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"
      ],
      "editor.minimap.enabled": false,
      // "latex-workshop.view.pdf.viewer": "external",
      "latex-workshop.view.pdf.external.viewer.command": "D:\\software\\SumatraPDF\\SumatraPDF-3.2-64.exe",
      "latex-workshop.view.pdf.external.viewer.args": [
          "-forward-search",  "%TEX%",   "%LINE%",
          "-reuse-instance",  "-inverse-search",
          "\"C:/.../Microsoft VS Code/Code.exe\" \"C:/.../Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
          "%PDF%"
      ],
}

1.5 测试环境

创建文件夹, 在该文件夹中创建文件main.tex, 输入下面代码

% \documentclass[UTF8]{article}
\documentclass[UTF8]{ctexart} % 支持中文
\usepackage{amsmath}%数学支持
\usepackage[utf8]{inputenc} %字体格式utf8
\usepackage{graphicx} %导入插入
\title{English}
\author{xxx}
\date{October 2020 10 28}%日期显示

\begin{document} %论文开始的主体
\maketitle %生成题目,放在begin之后
\tableofcontents%目录

% \input{abstract} %这里插入abstract
% \input{introduction}

% \\换行
% \par:分段
% \newpage:分页命令。
% \clearpage:和 \newpage 类似。我们在使用 CJK 环境时会加入 \clearpage 在环境末尾。


\section{Introduction}
\subsection{introduction2}
\subsubsection{introduction3}

\[ E=mc^2. \]%段间数学
\begin{equation}
E=mc^2.
\end{equation}

$2=35+23$ %行内公式
$$25+455-415$$%单独一行公式
$$25+4^55-41_5$$
$$\displaystyle \frac{x+y}{y+z}y+z_x+y$$
$$\underline{x+y}x+y$$
$$\overline{xyz}xyz$$ %下划线
$[x+y][x+y]$
$\{x+y\}{x+y}$
$$fjlsdajghl$$
adgsasdrhdsrhdsrh
这里是中文
\end{document}

点击右上角绿色运行按钮即可编译运行
在这里插入图片描述
在这里插入图片描述
然后设置默认PDF为SumatraPDF
在这里插入图片描述

在这里插入图片描述

1.6 IEEE模板测试

模板下载直达请点击
下载解压后, 使用VScode打开文件夹, 在打开main.tex文件
在这里插入图片描述

1.7 中文路径编译出错解决方案

通过修改默认编码即可, 因为utf-8是全球通用编码格式, 包括中文
在这里插入图片描述

二. 开始写作 应用部分

2.1 IEEE论文写作流程

  • 先去IEEE官网下载LaTeX模板
    IEEE模板下载后解压,使用VScode打开
    在这里插入图片描述
  • 修改VScode编译器为latexmk
    因为直接用latexmk即可编译, 所以将该编译器提到前面
    重启VScode后, 点击recipe:LaTeXmk进行第一次编译, 后面只需要快捷键Ctr+S保存即可自动使用该编译器进行编译;
    在这里插入图片描述
    在这里插入图片描述

Ctr+S自动编译, PDF自动更新, 舒服

2.2 表格table操作

a 利用Excel生成tab

  • 下载Excel转LaTeX宏工具
    在这里插入图片描述
  • 下载后双击安装
    此时Excel会提示是否打开宏, 选择是之后, 可以看到Excel加载项
    在这里插入图片描述
  • 新建Excel,在里面输入想要编写的表格数据,下图是制作表头
    在这里插入图片描述
  • 选中数据后点击Excel2LaTeX
    在这里插入图片描述
  • 结果
    在这里插入图片描述

b 修改标题与表的距离

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table*}[htbp]
    \small
    \setlength{\abovecaptionskip}{0pt}  %这里设置距离
    \setlength{\belowcaptionskip}{10pt}
    \caption{Add caption}
    \centering
    \begin{tabular}{ccccccc}
        \toprule
        Vulnerability Type & \multicolumn{1}{p{4.19em}}{A} & \multicolumn{1}{p{4.19em}}{C} & E(\%) & D(\%) & F(\%) & G(\%) \\
        \midrule
        A & 7015  & 21735 & 0.16  & 0.21  & 99.79 & 99.5 \\
        B & 5612  & 17388 & 0.92  & 1.32  & 98.68 & 97.19 \\
        C & 4392  & 13608 & 0.14  & 2.64  & 97.36 & 99.56 \\
        D & 3660  & 11340 & 1.47  & 2.16  & 97.84 & 95.54 \\
        E & 3050  & 9450  & 1.2   & 2.69  & 97.31 & 96.33 \\
        F & 2396  & 7418  & 1.24  & 2.42  & 97.58 & 96.21 \\
        G & 2196  & 6804  & 0.84  & 2.78  & 97.22 & 97.4 \\
        H & 2579  & 4877  & 1.74  & 2.37  & 97.63 & 96.73 \\
        I & 2013  & 3795  & 2.11  & 1.44  & 98.56 & 96.12 \\
        J & 1098  & 3402  & 1.03  & 2.19  & 97.81 & 96.84 \\
        K & 1064  & 2070  & 2.27  & 1.22  & 98.78 & 95.72 \\
        \bottomrule
    \end{tabular}%
    \label{tab:GCN}%
  \end{table*}%

2.3 显示中文

  • method1 设置编码格式utf-8
%--utf-8-- 
\documentclass[UTF8]{ctexart}
  • method2 设置中文版包ctex
\usepackage[UTF8]{ctex}

2.4 加粗下滑颜色斜体

注意颜色需要在preamble.tex中加入
\usepackage{color}

\textbf{Oh my friends} %加粗 \\是换行
\emph{Oh my friends}\\ %斜体
\underline{on my friends}\\ % 下划线
\textbf{\underline{\emph{on my friends}}}\\ %混合使用
\textcolor{red}{my name is zjq}

ref

知乎大佬教程

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

落子无悔!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值