LaTeX基础
Become a LaTeXer
LaTeX 的优雅不必多言。使用 LaTeX 不必刻意学习,享受乐趣即可。
PART 1 文档结构
LaTeX 源文件的结构分三大部分,依次为:文档类声明、序言、正文。
文档类声明用来指定文档的类型;序言用来完成一些特殊任务,比如引入宏包,定义命令,设置环境等;文档的实际内容则放在正文部分,即 \begin{document} 和 \end{document} 之间的部分。
LaTeX 预置了 article, report 等文档类,每一个 tex 文件都应声明\documentclass{xxx}
当然你也可以使用美赛模板 mcmthesis 或国赛模板 cumcmthesis,后者需要引入 cls 文件。
宏包类似 C++ 中的头文件,引入它们\usepackage{xxx}才能使用一些功能函数。
常用的宏包有 amsmath, multirow, booktabs, graphicx, geometry 等,使用模板文档类时可以不引用宏包。
PART 2 正文内容
%正文:
\begin{document}
...
\end{document}
%展示标题:
\title{Math}
\author{Me}
\date{2022-3-31}
\maketitle
%摘要:
\begin{abstract}
...
\end{abstract}
%展示目录:
\tableofcontents
\section{A}
\subsection*{a} %不显示标题
%参考文献:
\begin{thebibliography}{10}
\bibitem{ref 1} ...
\bibitem{ref 2} ...
\end{thebibliography}
%附录:
\begin{appendices}
...
\end{appendices}
%标签:
\caption{figure} %图表标题
\label{eq1} %标记
\ref{eq1} %引用
\tag{one} %编号
\pageref{img} %引用标记页码
\footnote{this} %脚注
%图像:
\begin{figure}[htbp]
\centering
\includegraphics[width=9.5cm,height=8cm]{figure.jpg}
\caption{Elliptic Paraboloid}
\end{figure}
\begin{minipage}[t]{0.3\textwidth}
\subfigure{...}
\end{minipage} %多图并列
\begin{wrapfigure}[8]{r}{12em}
...
\end{wrapfigure} %环绕排列
%表格:
\begin{table}[htbp]
\caption{table}
\begin{tabular}{l|c|r}
1&2&3\\
\hline
\end{tabular}
\end{table}
\multirow{2}{*}{a} %占据多行
\multicolumn{2}{c|}{b} %占据多列
\toprule, \midrule, \bottomrule %三线表
%列表:
\begin{itemize}
\item ...
\item ...
\end{itemize} %无序列表
\begin{enumerate}
\item ...
\item ...
\end{enumerate} %有序列表
\begin{description}
\item ...
\item ...
\end{description} %去点无序列表
%对齐方式:
\begin{flushleft}
...
\end{flushleft} %段落居左
\begin{flushright}
...
\end{flushright} %段落居右
\begin{center}
...
\end{center} %段落居中
%原文照排:
\begin{verbatim}
...
\end{verbatim}
%盒子:
\mbox{box}, \makebox[100pt][l]{box} %水平盒子
\fbox{box}, \framebox[100pt][r]{box} %带框盒子
\parbox{box}[c]{100pt}{box1\\box2} %垂直盒子
%数学内容:
$ r = 1cm $ %行内公式
\[ a^2 + b^2 = c^2 \] %行间公式
\begin{align}
...
\end{align} %编号对齐
\[
\begin{aligned}
...
\end{aligned}
\] %不编号对齐
\begin{array}
...
\end{array} %阵列
%代码:
\begin{lstlisting}[language=c++]
...
\end{lstlisting}
PART 3 文字排版
\geometry{left=2.54cm,right=2.54cm} %设置页面大小
\geometry{textheight=20cm} %设置版心位置
\lhead{team} %设置页眉
\rfoot{\thepage} %设置页脚
\pagenumbering{arabic} %设置页码
\lettrine[lines=2]{T}{he} %放大段首字母
\huge{Title} %字号命令
\textbf{Question} %字样命令
\text{d} %文本字体
\setlength{\parskip}{0pt} %段间距
\noindent %取消缩进
\notag %取消编号
\\ %换行
\par %换段
\newpage %换页
\verb|\begin| %原文照排

浙公网安备 33010602011771号