【教程】linux latex+vscode安装、配置与卸载
·
ubuntu 22.04安装textlive-full
安装
sudo apt-get install texlive-full
# 安装时间有点长,其中的xetex集成了中文字体的环境,使得中文文档的生成变得很容易,可以使用系统自带得字体,使用更好看得字体。
apt-cache search cjk
# 找到相关宏包,安装
sudo apt-get install latex-cjk-xcjk cjk-latex latex-cjk-chinese
# 从windows机器上,复制字体文件过来,并刷新缓存
sudo mkdir /usr/share/fonts/winfonts
cp xxxx/fonts/* /usr/share/fonts/winfonts/
cd /usr/share/fonts/winfonts
sudo mkfontscale
sudo mkfontdir
# 刷新字体缓存
sudo fc-cache -vf
配置
vscode,插件中心,搜索latex workshop,安装
ctrl+shift+p,输入settings.json,选择这个文件,把配置复制到文件末尾(如果本身这个文件是空的,那要先打一对{},再复制)
// 设置是否自动编译
"latex-workshop.latex.autoBuild.run":"onFileChange",
//右键菜单
"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": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "lualatex",
"command": "lualatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-shell-escape",//这个命令行在网上的Latex Workshop设置里一般没有,所以直接recipe会报错
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
// 用于配置编译链
"latex-workshop.latex.recipes": [
{
"name": "XeLaTeX",
"tools": [
"xelatex"
]
},
{
"name": "PDFLaTeX",
"tools": [
"pdflatex"
]
},
{
"name": "LuaLaTeX",
"tools": [
"lualatex"
]
},
{
"name": "BibTeX",
"tools": [
"bibtex"
]
},
{
"name": "LaTeXmk",
"tools": [
"latexmk"
]
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
//文件清理。此属性必须是字符串数组
"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"
],
//设置为onFaild 在构建失败后清除辅助文件
"latex-workshop.latex.autoClean.run": "onFailed",
// 使用上次的recipe编译组合
"latex-workshop.latex.recipe.default": "lastUsed",
//使用 SumatraPDF 预览编译好的PDF文件
// 设置VScode内部查看生成的pdf文件
"latex-workshop.view.pdf.viewer": "tab",
// PDF查看器用于在\ref上的[View on PDF]链接
"latex-workshop.view.pdf.ref.viewer": "auto",
"editor.renderControlCharacters": false,
测试
新建一个main.tex文件
\documentclass{article}
\usepackage[a4paper, left=1in, right=1in, top=1in, bottom=1in]{geometry}
\usepackage{xeCJK} %调用 xeCJK 宏包
\usepackage{listings}
\author{ ice }
\date {2019.01.28}
\setmainfont{SimSun} % 宋体
%\setCJKmainfont{WenQuanYi Micro Hei Mono:style=Regular} %设置 CJK 主字体为 SimSun (宋体)
\title{Latex入门学习}
\begin{document}
\maketitle
\begin{center}
\end{center}
\tableofcontents %添加目录
\tableofcontents
\begin{abstract}
this is abstract。
\end{abstract}
\section{asf}
你好。
\section{as}
hello world
% Lorem \cite{Lutz2017} ipsum dolor sit amet, consectetur adipisicing
% \bibliography{info}
\bibliographystyle{ieeetr}
\end{document}
终端输入
xelatex main.tex
能渲染出.pdf,成功
光速入门
基本文件结构
一个简单的 LaTeX 项目通常包含以下几类文件:
- 主文件:通常以 .tex 为扩展名,是整个文档的核心,包含文档的整体结构和设置。例如 main.tex。 样式文件:以 .cls 或
- sty 为扩展名,用于定义文档的样式和格式。很多期刊或学校会提供自己的样式文件。
- 图片文件:用于插入到文档中的图片,常见格式有png、.jpg、.pdf 等。一般会创建一个单独的 figures 文件夹来存放这些图片。
- 参考文献文件:以 .bib为扩展名,包含文档中引用的参考文献信息
通常.tex文件的常包含以下几个部分
% 文档类型声明。常见的文档类型还有 book、report 等。
\documentclass{article}
% 导入宏包
\usepackage{amsmath} % 用于数学公式
\usepackage{graphicx} % 用于插入图片
% 文档设置
\title{My First LaTeX Document}
\author{Your Name}
\date{\today}
% 文档开始
\begin{document}
% 生成标题
\maketitle
% 正文内容
\section{Introduction}
This is the introduction of my document.
% 插入图片示例
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{figures/figure1.png}
\caption{This is a sample figure.}
\label{fig:figure1}
\end{figure}
% 参考文献示例
\bibliographystyle{plain}
\bibliography{references}
% 文档结束
\end{document}
类似于html的tag,都有开始和结束标记,然后在中间写内容,或者在头部加格式,当然也可以用统一的样式表。
其他的,再掌握一下正向搜索(源文件到pdf)和反向搜索(pdf定位到源文件),公式、公式编号、图表的语法,就能简单实用了。
卸载
完全卸载
原文链接:https://blog.csdn.net/qq_40199232/article/details/106505730
sudo apt-get purge texlive*
rm -rf /usr/local/texlive/2024
rm -rf ~/.texlive2024
rm -rf /usr/local/share/texmf
rm -rf /var/lib/texmf
rm -rf /etc/texmf
sudo apt-get remove tex-common --purge
rm -rf ~/.texlive
更多推荐
所有评论(0)