1、基本结构
\documentclass[a4paper, 12pt]{article} %文档类型
\begin{document}
\title{My First Document}
\author{My Name}
\date{\today}
\maketitle
A sentence of text.
\end{document}
2、带有章、节、小节的结构
\documentclass[a4paper, 12pt]{article}
\begin{document}
\title{My First Document}
\author{My Name}
\date{\today}
\maketitle
\section{Introduction}
This is the introduction.
\section{Methods}
\subsection{Stage 1}
The first part of the methods.
\subsection{Stage 2}
The second part of the methods.
\section{Results}
Here are my results.
\end{document}
3、引用 \label{} \ref{} \pageref{}
\section{Methods}
123
\subsection{Stage 1}
\label{sec1} 123
\section{Results}
Here are my results. Referring to section \ref{sec1} on page \pageref{sec1}
4、带有目录的结构
\documentclass[a4paper, 12pt]{article}
\begin{document}
\title{My First Document}
\author{My Name}
\date{\today}
\maketitle
\pagenumbering{roman} %当前页页码使用roman
\tableofcontents %生成目录
\newpage
\pagenumbering{arabic} %当前页页码使用arabic
\section{Introduction}
This is the introduction.
\section{Methods}
\subsection{Stage 1}
The first part of the methods.
\subsection{Stage 2}
The second part of the methods.
\section{Results}
Here are my results.
\end{document}
5、字体
1、中文支持 在前导命令部分(\begin{doucument}的前面)导入宏包
\usepackage[UTF8]{ctex}
2、部分字体
\textit{words in italics} \textsl{words slanted} \textsc{words in smallcaps} \textbf{words
in bold} \texttt{words in teletype} \textsf{sans serif words} \textrm{roman
words} \underline{underlined words}
3、字体颜色 需要导入宏包\usepackage{color}
格式为{\color{colorname}text}
{\color{red}fire}
4、字体大小
normal size words
{\tiny tiny words}
{\scriptsize scriptsize words}
{\footnotesize footnotesize words}
{\small small words}
{\large large words}
{\Large Large words}
{\LARGE LARGE words}
{\huge huge words}
6、段落缩进
LaTeX 默认每个章节第一段首行顶格,之后的段落首行缩进。如果想要段落顶格,在要顶格的段落前加 \noindent 命令即可。如果希望全局所有段落都顶格,在文档的某一位置使用 \setlength{\parindent}{0pt} 命令,之后的所有段落都会顶格。
7、空格和空行
多个连续空格在 LaTeX 中被视为一个空格。多个连续空行被视为一个空行。两个反斜杠(\\
)可以被用来换行。\hspace{100em}用来产生空格效果,其中em是单位,1em表示当前字体下大写M的宽度。
8、列表
LaTeX 支持两种类型的列表:有序列表(enumerate)和无序列表(itemize)。列表中的元素定义为 \item
。列表可以有子列表。
可以使用方括号参数来修改无序列表头的标志。例如,\item[-]
会使用一个杠作为标志,你甚至可以使用一个单词,比如 \item[One]
。
\begin{enumerate}
\item First thing
\item Second thing
\begin{itemize}
\item A sub-thing
\item Another sub-thing
\end{itemize}
\item Third thing
\end{enumerate}
\begin{itemize}
\item[-] First thing
\item[+] Second thing
\begin{itemize}
\item[Fish] A sub-thing
\item[Plants] Another sub-thing
\end{itemize}
\item[Q] Third thing
\end{itemize}