LaTeX:修订间差异
跳转到导航
跳转到搜索
WhiteWallClosetFun(留言 | 贡献) 创建页面,内容为“LaTeX是一个科研领域常用的排版系统。<ref>[https://zh.wikipedia.org/wiki/LaTeX 维基百科: LaTeX]</ref> == 在VSCode编辑器上配置LaTeX编写系统 == 需要安装的软件: * [https://code.visualstudio.com/ VSCode] * [https://miktex.org/ MikTeX] 具体的步骤为: <ol> <li> 安装MikTeX。 </li> <li> 安装VSCode编辑器。</li> <li> 在VSCode编辑器中,安装LaTeX Workshop插件。</li> <li> 按住<code>Ctrl+,</code>组合键…” |
WhiteWallClosetFun(留言 | 贡献) 无编辑摘要 |
||
第205行: | 第205行: | ||
\end{document} | \end{document} | ||
</syntaxhighlight> | |||
== 编写贴士 == | |||
=== 跨栏表格的编写 === | |||
跨栏表格列下面还包含子列的表格,编写方式为: | |||
<syntaxhighlight lang="tex" line> | |||
\begin{table}[!ht] | |||
\caption{\textbf{Caption}.} | |||
\smallskip | |||
\label{caption} | |||
\centering | |||
\begin{tabular}{cccccc} | |||
\toprule | |||
\multicolumn{1}{c}{\textbf{Main1}} & | |||
\multicolumn{2}{c}{\textbf{Main2}} & | |||
\multicolumn{3}{c}{\textbf{Main3}} | |||
\\ | |||
\midrule | |||
& \textbf{Sub1} & \textbf{Sub2} & \textbf{Sub3} & \textbf{Sub4} & \textbf{Sub5} \\ | |||
\midrule | |||
\textbf{Element1} & & & & & \\ | |||
\bottomrule | |||
\end{tabular} | |||
\end{table} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 问题解决 == | == 问题解决 == | ||
第240行: | 第263行: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 图片模糊不清 === | |||
一个好习惯是,想要向LaTeX文档中嵌入图片时,请将图片设置为<code>.pdf</code>格式,而非<code>png</code>、<code>jpg</code>等格式。这是因为,除了PDF格式,其它的格式往往面临着放大发虚的问题。 | |||
== 参考资料 == | == 参考资料 == |
2025年7月27日 (日) 01:27的版本
LaTeX是一个科研领域常用的排版系统。[1]
在VSCode编辑器上配置LaTeX编写系统
需要安装的软件:
具体的步骤为:
- 安装MikTeX。
- 安装VSCode编辑器。
- 在VSCode编辑器中,安装LaTeX Workshop插件。
- 按住
Ctrl+,
组合键,搜索“latex tool”,并打开settings.json
文件。 - 在JSON块中,增加下面的配置行:
- 在
latex-workshop.latex.tools
JSON块中,增加下面的配置行。这些配置文件的目的是引入bibtex
工具。 - 在
latex-worksop.latex.recipes
JSON块中,增加下面的配置行。这些配置的引入目的是便于中文编译,以及最终引用格式的生成。
// 禁止自动编译
"latex-workshop.latex.autoBuild.run": "never",
// 编译后自动清理无用文件
"latex-workshop.latex.autoClean.run": "onBuilt",
"latex-workshop.latex.clean.subfolder.enabled": true,
// 自动使用上一次的编译器
"latex-workshop.latex.recipe.default": "lastUsed",
// 根据使用的包自动补全
"latex-workshop.intellisense.package.enabled": true,
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
],
"env": {}
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
一个示例中文LaTeX模板
\documentclass[%12pt 文字大小
]{article}
\usepackage{amsmath,amssymb}
\linespread{1.5}
\usepackage[UTF8]{ctex}
\usepackage{lmodern}
\usepackage{iftex}
\usepackage{indentfirst}
\usepackage{setspace}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{float} %指定图片位置
\usepackage{subfigure}%并排子图 共享标题 有子标题
\usepackage{hyperref}
\usepackage{tcolorbox}
\usepackage{color}
\usepackage{booktabs}
\usepackage[backend=bibtex]{biblatex}
\usepackage{xcolor}
\tcbuselibrary{skins,breakable}
\usepackage[lined,boxed,commentsnumbered]{algorithm2e}
\hypersetup{hidelinks,
colorlinks=true,
allcolors=black,
pdfstartview=Fit,
breaklinks=true}
\lstset{
basicstyle = \sffamily, % 基本代码风格
keywordstyle = \bfseries, % 关键字风格
commentstyle = \rmfamily\itshape, % 注释的风格,斜体
stringstyle = \ttfamily, % 字符串风格
flexiblecolumns, % 别问为什么,加上这个
numbers = left, % 行号的位置在左边
showspaces = false, % 是否显示空格,显示了有点乱,所以不现实了
numberstyle = \zihao{-5}\ttfamily, % 行号的样式,小五号,tt等宽字体
showstringspaces = false,
captionpos = t, % 这段代码的名字所呈现的位置,t指的是top上面
frame = lrtb, % 显示边框
breaklines = true,
}
\setlength{\parindent}{2em}
% 定义
\def\degree{{}^{\circ}}
% 中英文摘要格式
% 标题、作者、日期
\title{\textbf{\huge{标题}}}
\author{作者1,作者2, 作者3\
所属单位}
\date{} % 这一行用来去掉默认的日期显示
%\newcommand{\supercite}[1]{\textsuperscript{\cite{#1}}}
\renewcommand{\contentsname}{目录} % 目录变为中文
\renewcommand{\refname}{参考资料}
\author{}
\date{}
\title{}
\begin{document}
\maketitle
\newpage
\tableofcontents
\newpage
\begin{table}[H]
\centering
\caption{}
\begin{tabular}{}
\toprule
\\
\midrule
\\
\bottomrule
\\
\end{tabular}
\end{table}
\newpage
\end{document}
编写贴士
跨栏表格的编写
跨栏表格列下面还包含子列的表格,编写方式为:
\begin{table}[!ht]
\caption{\textbf{Caption}.}
\smallskip
\label{caption}
\centering
\begin{tabular}{cccccc}
\toprule
\multicolumn{1}{c}{\textbf{Main1}} &
\multicolumn{2}{c}{\textbf{Main2}} &
\multicolumn{3}{c}{\textbf{Main3}}
\\
\midrule
& \textbf{Sub1} & \textbf{Sub2} & \textbf{Sub3} & \textbf{Sub4} & \textbf{Sub5} \\
\midrule
\textbf{Element1} & & & & & \\
\bottomrule
\end{tabular}
\end{table}
问题解决
无法搜寻到引用相关命令
这个问题的表现形式通常为下面的报错:
I found no \citation commands---while reading file myFile.aux I found no \bibdata command---while reading file myFile.aux I found no \bibstyle command---while reading file myFile.aux
解决方法为,在.tex
文件中,加入或修改:
\usepackage[backend=bibtex]{biblatex}
错误的引用命令
这个问题的表现形式通常为下面的报错:
! Package biblatex Error: '\bibliographystyle' invalid. l.260 \bibliographystyle{unsrt} Use the package option 'style' instead. I'm ignoring this command. ! LaTeX Error: Can be used only in preamble.
解决方法为,在.tex
文件中,加入或修改:
\addbibresource{document.bib} % 应当在\begin{document}前添加引用文件。
Missing $ inserted
这个问题的表现形式通常为下面的报错:
Missing $ inserted
这个问题出现的原因是转义字符的问题,需要检查文档,为_
等字符添加转义:
\par{
This is a test_sentence. % 错误
This is a test\_sentence. % 正确
}
图片模糊不清
一个好习惯是,想要向LaTeX文档中嵌入图片时,请将图片设置为.pdf
格式,而非png
、jpg
等格式。这是因为,除了PDF格式,其它的格式往往面临着放大发虚的问题。