LaTeX Cookbook by Eric

张开发
2026/4/15 7:53:30 15 分钟阅读

分享文章

LaTeX Cookbook by Eric
LaTeX学习教程Learn LaTeX in 30 minutes: Including title, author and date information1. 常见术语1.1 TeX LiveLaTeX语言的编译环境2. LaTeX编辑器2.1 OverleafCn版本可通过香港节点连接2.2 TeXstudio使用TeXstudio来编译LaTex文件关于LaTeX编译环境安装请参考博文《LaTeX写作》——LaTeX编写环境的安装笔记2.2.1 界面介绍侧边栏导航文档结构操作路径View⇒Show⇒Side Panel2.2.2 快捷键Short keyActionCtrlT注释选中行2.2.3 Troubleshooting1构建Build时提示“xxx.bbl 错误 Something’s wrong–perhaps a missing \item. \end{thebibliography}”在TeXstudio中这个错误通常发生在参考文献bibliography部分可能的原因项目中没有.bib文件存在ref.bib文件但是此文件尚未进行编译首先需要确认项目中已经添加.bib文件然后进行编译操作路径菜单栏⇒工具⇒参考文献Bibliography然后就可以构建文档了3. 字体设置粗体\textbf{粗体文字}引用文字\textit{This is a quoted text.}Word颜色复现操作路径选中文字 ⇒ 打开文字颜色菜单 ⇒其它颜色(M)⇒十六进制(H)4. 标点符号空格~双引号前后引号感谢夕小瑶公众号配图来自博文“夕小瑶整理论文写作中注意这些细节能显著提升成稿质量”波浪线\textasciitilde5. 图示格式:.eps绘图工具:PowerPoint5.1 插图instant代码\begin{figure}[!htbp] \centering \includegraphics[width\textwidth]{figure_file.eps}\caption{Figure_Title}\end{figure}figure*:*表示双栏不加*就是单栏。对于表格和公式也是这样位置参数说明!忽略一些内部的排版限制参数积极地将浮动体放在您指定的位置h当前位置尝试但不保证一定会放在当前位置。t顶部。b底部。p浮动页。5.2 图片文件目录管理请参考知乎——“LaTeX 如何插入图片——入门教程”5.3 竖排多图子图横排(ab)子图使用subfloat实现横排多个子图\usepackage{subfig}%引入subfloat \begin{figure}[!htbp]\centering%使插入的图片居中显示 \subfloat[Figure1]{\includegraphics[width0.5\linewidth,clip]{fig.eps}\label{fig1}}\subfloat[Figure2]{\includegraphics[width0.5\linewidth,clip]{fig.eps}\label{fig2}}\caption{Procedureofthe method.}\label{fig_method}\end{figure}竖排(ab)子图使用subfloat实现竖排并列的多个子图\usepackage{subfig}%引入subfloat \begin{figure}[!htbp]\centering%使插入的图片居中显示 \subfloat[Figure1]{\includegraphics[width\linewidth,clip]{fig.eps}\label{fig1}}\\%换行符 \subfloat[Figure2]{\includegraphics[width\linewidth,clip]{fig.eps}\label{fig2}}\caption{Procedureofthe method.}\label{fig_method}\end{figure}5.4 使用clip去除图片周围的空白使用clip去除图示周围的空白即:[width\textwidth,clip]5.5 图片紧凑排版主要是利用[H]进行手动排版6. 表格基本格式\begin{table} \centering % 表示居中 \begin{tabular}{|c|c|c|c|} \hline \multicolumn{2}{|c|}{合并一行两列} 三 四 \\ \hline 1 2 3 4 \\ \hline \end{tabular} \end{table}Note如果出现文字无法对齐的情况对表格中加粗的文字请使用\textbf{}而不要使用\bf{}。6.1 合并单元格请参考《Latex 表格技巧 - 合并单元格》合并一行多列\begin{table}\centering \begin{tabular}{|c|c|c|c|}\hline \multicolumn{2}{|c|}{合并一行两列}三四 \\ \hline1234\\ \hline \end{tabular}\end{table}合并一列多行\multirow\begin{table}[htbp]\centering \caption{Caption}\begin{tabular}{c c c c c c}\hline \multirow{2}*{\textbf{架构}}\multirow{2}*{\textbf{参数}}\multicolumn{4}{c}{\textbf{数据集}}\\ \cline{3-6}~~\textbf{一}\textbf{二}\textbf{三}\textbf{四}\\ \hline ArchitectureParams1234\\ \hline \end{tabular}\end{table}6.2 文字垂直居中\begin{table}\centering%让表格在页面中水平居中 \caption{xxxx}\begin{tabular}{|m{2cm}{\centering}|m{2cm}{\centering}|m{2cm}{\centering}||m{5cm}{\centering}|}\hline DayMin TempMax TempSummary \\ \hline Monday11C22CAclear daywithlotsofsunshine.However,the strong breeze will bring down the temperatures.\\ \hline Tuesday9C19CCloudywithrain,across many northern regions.Clear spells across mostofScotland and Northern Ireland,but rain reaching the far northwest.\\ \hline Wednesday10C21CRain will still lingerforthe morning.Conditions will improve by early afternoon andcontinuethroughout the evening.\\ \hline \end{tabular}\end{table}作者注参考知乎回答文字上下左右都居中7. 列表6.1 无序列表\begin{itemize}\item 第一项内容 \item 第二项内容 \item 第三项内容 \end{itemize}6.2 有序列表\begin{enumerate}\item 第一项内容 \item 第二项内容 \item 第三项内容 \end{enumerate}列表项加粗\begin{itemize} \item \textbf{列表项1}第一项说明。 \item \textbf{列表项2}第二项说明。 \item \textbf{列表项3}第三项说明。 \end{itemize}自由编号列表\begin{itemize}\itemindent 4em \item[(1)]Aaa aaa.\item[(2)]Bbb bbb.\item[(3)]Ccc ccc.\end{itemize}8 数学公式插入公式的代码如下\begin{equation} a 1, \end{equation}8.1 标点符号省略号使用\ldots例如1 , 2 , … , n 1,2,\ldots,n1,2,…,n括号的基本格式\left( y \middle| x \right)–( y | x ) \left( y \middle| x \right)(y∣x)常用的括号() || .这里的\middle|表示条件概率对于超过一个字母的变量或符号要用正文字体需要使用LaTeX已有的符号或者正文样式常用数学表达式\arg, \max, \sin, \cos, \tan正文样式\text{pred}, \text{true}8.2 字体规范模块名称\mathrm{FC}8.3 公式对齐可以使用align关键字进行公式对齐等号对齐对齐方式在等号前面加上8.4 条件方程\begin{cases}W i j { log ⁡ ( a m ) ( i , j ) ∈ A m 0 ( i , j ) ∉ A W_{ij} \begin{cases} \log(a_m) (i,j) \in A_m \\ 0 (i,j) \notin A \end{cases}Wij​{log(am​)0​(i,j)∈Am​(i,j)∈/A​9. 插入代码请参考文章《Latex 插入代码Matlab 或 Python》可以参考伍老师PPT使用algorithm2e命令包代码示例\begin{algorithm}[htbp] \KwIn{$N$ labeled training examples, $\{(\mathbf{x}_n,y_n)\}^N_{n1}$, where $\mathbf{x}_n\in\mathbb{R}^{M\times 1}$\; \hspace*{9mm} $T$ unlabeled examples, $\{\mathbf{x}_t\}_{t1}^T$\;} \KwOut{The PL model predictions for $\{\mathbf{x}_t\}_{t1}^T$.} \tcp{Train the PL model} Train a global fuzzy model using all $N$ training examples\; \For{$m1,...,M$} {Identify the first-order rule partitions for the $m$th input domain of the global fuzzy model\;} Index the partitions using $k$ in (\ref{eq:k})\; Include all partitions in the candidate pool\; $l1$\; \While{$l\le L$}{ Identify from the candidate pool the partition giving the maximum SSE\; Record the location of the partition as the $l$th patch\; Train a patch fuzzy model using only the training examples within the $l$th patch\; \If{the $l$th model is successfully trained\footnotemark{}} {$ll1$\;} Remove the above patch from the candidate pool\;} \caption{PL using fuzzy systems.} \label{alg:PLFS} \end{algorithm}伪代码效果图使用格式化包美化显示python代码请参考博文《不一样的 LaTeX 教程使用 listings 宏包美化代码》10. 参考文献管理工具: JabRef\bibliography{references}9.1 IEEEtran\bibliographystyle{IEEEtran}\bibliography{references}9.1 参考文献连号显示如果参考文献需要连号显示例如“[5, 6]”而默认模板是分开显示的“[5] [6]”则需要加入格式包来进行设置在代码声明中加入如下包声明\usepackage[numbers,sortcompress]{natbib}9.2 强制文献条目刊名字母大写有两种方式使用JabRef的工具自动进行转换。使用花括号{}指定大写单词。9.3 Troubleshooting1TeXstudio提示error: “Citation xxx on page xx undefined”这个错误提示的意思是Citation表达式未定义可能的原因是修改文献ID后IDE还没有重新进行载入此时就重新Build一次看文献引用是否能正常显示如果重新构建后TeXstudio提示No file TeXFileName.bbl.并且引用仍是未定义则需要对.bbl文件单独进行编译操作路径Tools⇒Bibliography然后在重新对tex文件进行构建11. 引用编号在引用编号的时候首先需要用\label指定元素的名称对象引用\ref{}文献引用\cite{}例如% 引用章节 \section{Section1} \label{sec:context1} The section number is \ref{sec:context1}. % 引用公式 So the formula is \ref{eq_formula1}.12. 模板备注8.1 IEEE模板Latex编译器pdflatex(可以支持.png图片格式)13. 论文修订\replaced[idSY]{123}{12 LaTeX论坛提问可以通过以下几种方式进行提问在搜索的博文下面提问可以提问3个博文

更多文章