基于LaTeX_工作室的2020年8月开始的直播内容,该系列文章将用图文的模式记录下其中的重要内容,方便查阅与学习。
编译环境: $\textrm{Tex Live}$
编辑环境: $\textrm{vscode}$
相关视频:LaTeX 直播之三 -LaTeX排版入门从基础文本到模板使用
本次视频主要包含以下内容:
- 基础知识
- 文档要素
- 模板使用
- 大型文档
所有教学基于$\textrm{texdoc lshort-zh-cn}$中的文档内容
基础知识
- 源文件结构
- 设置文档类别
- $\textrm{\documentclass{…}}$
- 有且只能有一个文档类
- 确定文档性质
- 调入宏集
- $\textrm{\usepackage{…}}$
- 可以调入任意多个宏集
- 扩展功能
- 撰写文档——正文区,有且只能有一个
- $\textrm{\begin{docunment} …… \end{document}}$
- 文本
- 公式——分为行内与行间公式
- 图表
- 文献
- 设置文档类别
%引入文档类 \documentclass{article} %导言区 \usepackage{ctex} %处理中文的宏包Chinese-tex \usepackage{graphicx} \newcommand{\ECNU}{华东师范大学} %自己定义的宏 %正文区 \begin{document} Hello. \LaTeX. \ECNU \end{document}

- 源文件内容
- 普通文本
- 命令
- 大小写敏感
- 两种格式: $\textrm{\+command}$或者$\textrm{\+char+command}$
- 忽略命令后面的空格
- 命令的结束标志是空白,数字或非字母的字符(最好是$\textrm{ASCII}$字符)
- 特殊字符
- 输出$\textrm{%}$用$\textrm{\%}$
- $\textrm{\\\\}$表示手动换行,要输出$\textrm{\\}$使用$\textrm{\textbackslash}$
- 环境
- 环境开始:$\textrm{\begin{environment name}[optional arguments]{mandatory arguments}}$
- 环境结束:$\textrm{\end{environment name}}$
- 作用:局部生效,特殊元素
- 分组:用一对$\textrm{{}}$的形式来局部定义其内部的格式,如字体,大小等参数。
- 空白
- 空白字符
- 空格
- $\textrm{TAB}$
- 换行
- 空行—分段
- 空白字符
- 标点符号
- 中文—直接输入
- 英文
- 引号
- 左:$\textrm{1}$左边,$\textrm{TAB}$上边的按键
- `
- ` `
- 右:$\textrm{L}$右边的按键
- ‘
- ”
- 左:$\textrm{1}$左边,$\textrm{TAB}$上边的按键
- 横线
- 连字号$\textrm{(hyphen): – ,}$表示复合词
- 短破折号$\textrm{(en-dash): — ,}$表示数字范围
- 长破折号$\textrm{(em-dash): — ,}$表示连接单词
- 省略号
- $\textrm{\ldots}$
- $\textrm{\dots}$
- 其他—直接输入
- 引号
- 工作流程
- 编辑$\textrm{.tex}$文件
- 编译$\textrm{pdfLaTeX, XeLaTeX}$
- $\textrm{PDF}$生成
- 软件工具
- 编辑器
- 专用
- $\textrm{TeXStudio}$
- $\textrm{WinEdt}$
- 通用(插件)
- $\textrm{Vs Code}$
- $\textrm{Vim}$
- $\textrm{Emacs}$
- 记事本
- 主要功能
- 语法高亮
- 自动补全
- 拼写检查
- 代码缩进
- 专用
- 发行版
- 引擎
- $\textrm{pdfTeX}$
- $\textrm{XeTeX}$
- $\textrm{LuaTeX}$
- $\textrm{……}$
- 格式
- $\textrm{plain TeX}$
- $\textrm{LaTeX}$
- $\textrm{ConTeXt}$
- 引擎
- $\textrm{PDF}$查看
- $\textrm{Adobe Acrobat Reader DC}$
- 其他
- 编辑器
- 文档类$\textrm{\documentclass[options]{class}}$
- $\textrm{class}$指明文档类型
- $\textrm{article/ctexart}$—排版科技期刊、短报告、程序文档、邀请函等
- $\textrm{report/ctexrep}$—排版多章节的长报告、短篇的书籍、博士论文等
- $\textrm{book/ctexbook}$—排版书籍
- $\textrm{beamer/ctexbeamer}$—排版演示问文稿
- $\textrm{options}$调节文档类属性
- 设置字体大小,缺省$\textrm{10pt}$
- 定义纸张大小,缺省$\textrm{letterpaper}$
- 设置数学公式左对齐,缺省中间对齐
- 设置数学公式编号位于左侧,缺省右侧
- 是否在文档标题后开始一新页,$\textrm{article}$缺省不开始,$\textrm{book}$缺省开始
- 指定排版方式,单栏或双栏
- 指定排版格式,单面或双面,$\textrm{article}$和$\textrm{report}$缺省单面,$\textrm{book}$缺省双面
- 指定新的一章开始在右边页(技术页)还是下一可用页,$\textrm{article}$中无效(没有章的概念),$\textrm{report}$缺省下一页 可用,$\textrm{book}$缺省右边页。
- $\textrm{class}$指明文档类型
%引入文档类 \documentclass{beamer} %导言区 \title{This is a Title} \author{ Kuroko\thanks{E-mail:x.kuroko@qq.com} \and Shirai\thanks{Corresponding author} \and others} \date{\today} %正文区 \begin{document} \begin{frame} \titlepage \end{frame} \end{document}

- 宏包$\textrm{\usepackage[options][package]}$
- $\textrm{package}$是宏包名称
- $\textrm{options}$是触发宏包中的特殊功能的关键词
- 调试
- 定位错误—注释法,推荐折半查找
- 注释一部分代码
- 若编译成功,则错误出现在注释部分
- 对注释部分再次进行二分,缩小查找范围
- 分析错误
- 命令/环境错误
- 依赖错误
- 宏包冲突
- 解决错误
- 定位错误—注释法,推荐折半查找
- 各类文件
- 对每个文档创建一个文件夹,便于管理。
- $\textrm{.sty }$宏包文件。宏包的名称与文件名一致。
- $\textrm{.cls }$文档类文件。文档类名称与文件名一致。
- $\textrm{.bib BIBTEX }$参考文献数据库文件。
- $\textrm{.bst BIBTEX }$用到的参考文献格式模板。详见$\textrm{ 6.1.4 }$小节。
- $\textrm{LATEX }$在编译过程中除了生成$\textrm{ .dvi }$或$\textrm{ .pdf }$格式的文档外$\textrm{7}$,还可能会生成相当多的辅助文件和日志。一些功能如交叉引用、参考文献、目录、索引等,需要先通过编译生成辅助文件,然后再次编译时读入辅助文件得到正确的结果,所以复杂的$\textrm{ LATEX }$源代码可能要编译多次:
- $\textrm{.log }$排版引擎生成的日志文件,供排查错误使用。
- $\textrm{.aux LATEX }$生成的主辅助文件,记录交叉引用、目录、参考文献的引用等。
- $\textrm{.toc LATEX }$生成的目录记录文件。
- $\textrm{.lof LATEX }$生成的图片目录记录文件。
- $\textrm{.lot LATEX }$生成的表格目录记录文件。
- $\textrm{.bbl BIBTEX }$生成的参考文献记录文件。
- $\textrm{.blg BIBTEX }$生成的日志文件。
- $\textrm{.idx LATEX }$生成的供$\textrm{ makeindex }$处理的索引记录文件。
- $\textrm{.ind makeindex }$处理$\textrm{ .idx }$生成的用于排版的格式化索引文件。
- $\textrm{.ilg makeindex }$生成的日志文件。
- $\textrm{.out hyperref }$宏包生成的$\textrm{ PDF }$书签记录文件。
文档要素
- 基本要素
- 断行与分页
- 间距
- 空格—可伸缩
- 带子:~ —不可断行
- 断行
- $\textrm{\\\\[length]}$换行,$\textrm{length}$表示垂直间距
- $\textrm{\\\\*[length]}$为禁止分页,$\textrm{length}$表示垂直间距
- $\textrm{\newline}$
- $\textrm{\linebreak[n]}$,$\textrm{n}$为建议程度,取值为$\textrm{0}$到$\textrm{4}$,默认为$\textrm{4}$,下同
- $\textrm{\nolinebreak[n]}$
- $\textrm{\sloppy}$,执行断行标准,增加间隔,防止出现过长行(不建议使用)
- 分页
- $\textrm{\newpage}$
- $\textrm{\clearpage}$
- $\textrm{\pagebreak[n]}$
- $\textrm{\nopagebreak[n]}$
- 断字
- $\textrm{\-}$
- 在单词中插入一个自主的断字点
- 对于含特殊字符的单词特别有用
- $\textrm{\mbox{text}}$,保证把几个单词排在同一行上
- $\textrm{\fbox}$,和$\textrm{\mbox}$类似,还能围绕内容画一个框
- $\textrm{\-}$
- 间距
- 标题,章与节
- $\textrm{\maketitle}$
- 整篇文档的标题
- 需要定义
- $\textrm{\title{…}}$
- $\textrm{\author{…}}$
- $\textrm{\date{…}}$
- 样式修改
- 重定义$\textrm{\maketitle}$
- $\textrm{titling}$宏包
- $\textrm{authblk}$宏包
- 分节命令
- $\textrm{article,report}$和$\textrm{book}$风格文档
- $\textrm{part{…}}$
- $\textrm{section{…}}$
- $\textrm{subsection{…}}$
- $\textrm{subsubsection{…}}$
- $\textrm{paragraph{…}}$
- $\textrm{subparagraph{…}}$
- 样式修改
- $\textrm{titilesec}$宏包
- $\textrm{\ctexset}$命令
- $\textrm{report}$和$\textrm{book}$风格文档
- $\textrm{\chapter}$
- 节的序号和标题的字号由$\textrm{LaTeX}$自动设置
- 带星号的分节命令—节标题不出现于目录,不带序号
- 标题前的可选参量
- 代替真正的标题出现在目录中
- 通常是比较长不适合出现在目录中
- $\textrm{article,report}$和$\textrm{book}$风格文档
- $\textrm{\tableofcontents}$
- 在出现位置插入目录
- 需要编译两次
- $\textrm{LaTeX2e}$用于$\textrm{book}$风格的文档
- $\textrm{\frontmatter}$
- $\textrm{\mainmatter}$
- $\textrm{\appendix}$
- $\textrm{\backmatter}$
- $\textrm{\maketitle}$
- 图
- 插图
- 使用$\textrm{graphicx}$宏包
- 图片格式(见下图)
- $\textrm{\includegraphics[optipons]{filename}}$
- $\textrm{filename}$
- 命名
- 禁用空格
- 禁用多余点号
- 不建议使用中文
- 路径
- 相对路径
- 绝对路径
- 搜索路径
- 命名
- $\textrm{options}$
- $\textrm{width=(width)}$将图片缩放到宽度为$\textrm{(width)}$
- $\textrm{height=(height)}$将图片缩放到高度为$\textrm{(height)}$
- $\textrm{scale=(scale)}$将图片相对于原尺寸缩放$\textrm{(scale)}$倍
- $\textrm{angle=(angle)}$令图片逆时针旋转$\textrm{angle)}$度
- $\textrm{filename}$
- 绘图
- $\textrm{TikZ&pgf}$
- $\textrm{PSTricks}$
- $\textrm{METAPOST&Asymptote}$
- 插图
- 表
- $\textrm{tabular}$环境
- $\textrm{align}$对齐方式
- $\textrm{colunm-spec}$定义表格样式
- 环境中
- $\textrm{\multicolumn{n}{column-spec}{item}}$—合并单元格
- 特殊表格—宏包支持
- $\textrm{CSV}$文件
- 浮动体
- 环境
- $\textrm{\begin{figure}[placement] … \end{figure}}$
- $\textrm{\begin{table}[placement] … \end{table}}$
- 相当于一个盒子,可以放置文字,公式,图片,表格等
- $\textrm{placement}$位置参数
- 跨栏浮动体
- $\textrm{\caption[option text]{caption text}}$
- 图标目录
- 交叉引用
- 创建标签 $\textrm{\label{label-name}}$
- 章节标题
- 行间公式
- 有序列表
- 图标标题
- 定理环境
- 带星号的不记编号的命令不正确
- 引用标签
- $\textrm{\\ref{label-name}}$
- $\textrm{\pageref{label-name}}$
- 多次编译
- $\textrm{\ref}$会被替换成相应的序号
- $\textrm{\pageref}$会被替换成相应的页码
- 使用的序号由前面编译所产生
- 创建标签 $\textrm{\label{label-name}}$
- 并排和子图标
- 建议
- 定稿前随意浮动
- 定稿后适度调整
- 增加文字
- 缩减文字
- 调整大小
- 环境
- 脚注$\textrm{\footnote{<footnote>}}$
- $\textrm{footnote}$为脚注内容
- 表格、盒子中使用
- 使用$\textrm{\footnotemark}$来标记
- 使用$\textrm{\footnotetext}$来写内容
- 强调
- $\textrm{\underline{text}}$下划线强调
- ultem宏包
- lua-ul宏包
- $\textrm{\emph{text}}$
- 斜体排印强调单词
- 中文没有$\textrm{Italics}$字体,用楷体代替
- 具体效果依赖上下文
- 斜体排印强调单词
- $\textrm{\underline{text}}$下划线强调
- 特殊环境
- $\textrm{\begin{environment} text \end{environment}}$
- 列表环境
- $\textrm{itemize}$环境用于简单的列表
- $\textrm{enumerate}$环境用于带序号的列表
- $\textrm{description}$环境用于带描述的列表
- 对其环境
- $\textrm{flushleft}$环境产生靠左排列的段落
- $\textrm{flushright}$环境产生靠右排列的段落
- $\textrm{center}$环境产生居中的文本
- 如果不输入$\textrm{\\\\}$指定断行点,程序将自行决定
- 引用环境
- $\textrm{quote}$:较短文字,首行不缩进
- $\textrm{quotation}$:若干行文字,对段落进行缩进
- $\textrm{verse}$:诗歌,首行悬挂缩进
- 一般有额外左右缩进
- 断行与分页

- 数学公式
- 基本知识
- 数学模式与文本模式的不同
- 行内公式—与文字混排
- $\textrm{\\(}$和$\textrm{\)}$
- $\textrm{\$}$和$\textrm{\$}$
- $\textrm{\begin{math}}$和$\textrm{\end{math}}$
- 行间公式—独立成行
- 不编号
- $\textrm{\\[}$和$\textrm{\]}$
- $\textrm{display math}$环境
- $\textrm{equation*}$环境
- 编号—$\textrm{equation}$环境
- 不编号
- 交叉引用
- 数学公式模块
- 常用的所有符号—通过$\textrm{texdoc symbols-a4}$命令获取
- 基本知识
模板使用
- 获取
- $\textrm{bing}$
- $\textrm{google}$
- $\textrm{ctan}$
- $\textrm{github/gitee}$
- $\textrm{git clone}$
- $\textrm{download zip}$
- $\textrm{LaTeX}$工作室
- 使用
- 发行版发布—直接使用
- 独立发布
- $\textrm{tlmgr}$安装
- 手动复制到发行版目录树
- 复制到当前工作目录
- 载入
- $\textrm{\documentclass}$
- $\textrm{\usepackage}$
- 阅读说明
- 手册
- $\textrm{README.md}$
- 依赖关系
- 编译参数
- 宏包依赖
- 版本限制
- 样例
- $\textrm{demo.tex}$
- $\textrm{main.tex}$
- 案例
- $\textrm{MCMThesis,}$通过$\textrm{texdoc mcmthesis}$命令获取
- $\textrm{github}$
- $\textrm{gitee}$
- 视频教程
- 从$\textrm{0}$开始的美赛$\textrm{LaTeX}$模板
- $\textrm{CUMCMThesis}$
- 学位论文
- $\textrm{github}$
- $\textrm{ctan}$
- $\textrm{textdoc thuthesis}$
- $\textrm{ElegantBook,}$通过$\textrm{texdoc elegantbook}$命令获取
- $\textrm{nwafuprojrep}$
- $\textrm{MCMThesis,}$通过$\textrm{texdoc mcmthesis}$命令获取
大型文档
- $\textrm{\input{filename}}$
- 不在新页排版引入文本
- 只是简单的引入文件,无其他限制
- $\textrm{\include{filename}}$
- 在文档的正文中使用
- 引入文件名为$\textrm{filename.tex}$的内容
- 在开始处理$\textrm{filename.tex}$的内容之前将会开始一新页
- $\textrm{\includeonly{filename,filename,…}}$
- 可用在文档的导言区
- 知道$\textrm{LaTeX}$仅仅读入某些$\textrm{\included}$文件
- 在导言区执行后,所有$\textrm{\include}$命令只有$\textrm{\includeonly}$命令参数中列出的文件才会被执行
- 在参数中,文件名和逗号之间不能有空格
可以注意到本文更像是一个索引,这也是视频中的思想,还是希望读者可以通过一份不太简短的$\textrm{LaTeX}$介绍来了解学习$\textrm{LaTeX}$。
$\textrm{Author}$@$\href{http://kuroko.info}{\textrm{Kuroko}}$
$\textrm{GitHub}$@$\href{https://github.com/SuperKuroko}{\textrm{SuperKuroko}}$
$\textrm{LeetCode}$@$\href{https://leetcode-cn.com/u/kuroko177/}{\textrm{kuroko177}}$
$\textrm{Last Modified: 2021-01-26 22:08}$
退出登录?