卜算法学习笔记- latex必备知识
开始第一个project
创建一个.tax文件或者在overleaf中创建一个project
\documentclass{article}
\begin{document}
First document. This is a simple example, with no
extra parameters or packages included.
\end{document}
- 第一行表示文章的类别class为article,还有一些类别,如book、report等;
- 之后的内容是文章的正文,包裹在\begin(document}和\end{document}中;
- 正文里面的内容可以进行编辑,编辑之后的内容要看效果需要点击recompile,在一些简单的编辑器里面,可以在命令行输入pdflatex <your document>之后就可以看到编辑之后的效果;
绪论preamble
\begin{document}之前的部分都是绪论,定义了文章类型、文章使用的语言等;首先看一下一个常见的绪论:
\documentclass[12pt, letterpaper]{article}
\usepackage[utf8]{inputenc}
- \documentclass[12pt, letterpaper]{article}
定义了字体大小12pt,还有一些尺寸(9pt, 11pt, 12pt),默认为10pt;
定义了纸张尺寸letterpaper,还有尺寸a4paper 和 legalpaper
如果还有疑问访问page size and margins - \usepackage[utf8]{inputenc}
定义编码
添加作者、标题、日期
需要在正文中添加\maketitle
\documentclass[12pt, letterpaper, twoside]{article}
\usepackage[utf8]{inputenc}
\title{First document}
\author{Hubert Farnsworth \thanks{funded by the Overleaf team}}
\date{February 2017}
\begin{document}
\maketitle
We have now added a title, author and date to our first \LaTeX{} document!
\end{document}
添加注释
在注释前添加%
黑体、斜体、下划线
- 黑体:\textbf{…}
- 斜体:\textit{…}
- 下划线:\underline{…}
- \emph{…}:在正常字体中斜体,在斜体中就是正常字体
加载图片
\documentclass{article}
% 在文章中加载图片需要添加的包
\usepackage{graphicx}
% 指示图片所在的文件夹
\graphicspath{ {images/} }
\begin{document}
The universe is immense and it seems to be homogeneous,
in a large scale, everywhere we look at.
% 真正将图片添加在文章中的地方
\includegraphics{universe}
There's a picture of a galaxy above
\end{document}
图片题目、说明和引用
\begin{figure}[h]
\centering
\includegraphics[width=0.25\textwidth]{mesh}
% 图片名称
\caption{a nice plot}
% 给图片标签
\label{fig:mesh1}
\end{figure}
% \ref引用
As you can see in the figure \ref{fig:mesh1}, the
function grows near 0. Also, in the page \pageref{fig:mesh1}
is the same example.
创建列表
无序列表
\begin{itemize}
\item The individual entries are indicated with a black dot, a so-called bullet.
\item The text in the entries may be of any length.
\end{itemize}
有序列表
\begin{enumerate}
\item This is the first entry in our list
\item The list numbers increase with each entry we add
\end{enumerate}
数学公式
需要添加\usepackage{amsmath}
内联公式
\( ... \), $ ... $ or \begin{math} ... \end{math}
行内公式
\[ ... \], \begin{displaymath} ... \end{displaymath} or \begin{equation} ... \end{equation}
文章格式
摘要
\begin{document}
\begin{abstract}
This is a simple paragraph at the beginning of the
document. A brief introduction about the main subject.
\end{abstract}
\end{document}
开始一个新段落
按两次换行
换行
\\, \newline
chapter、section
次序:
part和chapter只可以在report和book中
-1 \part{part}
0 \chapter{chapter}
1 \section{section}
2 \subsection{subsection}
3 \subsubsection{subsubsection}
4 \paragraph{paragraph}
5 \subparagraph{subparagraph}
表格
\begin{center}
\begin{tabular}{ c c c }
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9
\end{tabular}
\end{center}
\begin{tabular}{ c c c }
里面的{c c c}
表示有三列,c
表示居中,还有r
和l
- 以下是一个添加分割线的例子
\begin{center}
\begin{tabular}{||c c c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
\hline
2 & 7 & 78 & 5415 \\
\hline
3 & 545 & 778 & 7507 \\
\hline
4 & 545 & 18744 & 7560 \\
\hline
5 & 88 & 788 & 6344 \\ [1ex]
\hline
\end{tabular}
\end{center}
添加表标题
Table \ref{table:data} is an example of referenced \LaTeX{} elements.
\begin{table}[h!]
\centering
\begin{tabular}{||c c c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
2 & 7 & 78 & 5415 \\
3 & 545 & 778 & 7507 \\
4 & 545 & 18744 & 7560 \\
5 & 88 & 788 & 6344 \\ [1ex]
\hline
\end{tabular}
\caption{Table to test captions and labels}
\label{table:data}
\end{table}
目录
section
chapter
自动识别目录,但是section*
需要添加\addcontentsline{toc}{section}{Unnumbered Section}
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{Sections and Chapters}
\author{Gubert Farnsworth}
\date{ }
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
This is the first section.
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam lobortisfacilisis sem. Nullam nec mi et
neque pharetra sollicitudin. Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...
\section*{Unnumbered Section}
\addcontentsline{toc}{section}{Unnumbered Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...
\end{document}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异