最近开始使用latex,学习《Latex for Beginners》,记了一些笔记,在此分享一下。
第一章 介绍
第二章 文档结构
\documentclass[]{} % 所有.tex以此开头,[]内为参数,{}内为类别
% ... 在此定义全局参数,引入包,如下:
\usepackage{color}
\title{My Title}
\author{My Name}
\data{\today}
\pagenumbering{roman} %设置页码格式
\begin{document} % 文档开始
\maketitle % 显示title
\tableofcontents % 显示目录
\section{} % 章节
\subsection{}
\label{sec} % 设备标签
\subsubsection{}
\paragraph{}
\section{}
refer to Section \ref{sec} on Page \pageref{sec} % 引用便签
\end{document} 结束文档,之后的内容被忽略
class
class | usage |
---|---|
article | 适用于较短的文档,eg:journal articles and short reports |
report | 使用于较长的文档,包含chapter |
proc | conference proceedings |
book | 暂不清楚 |
slides | 暂不清楚 |
第三章 排版文本
字体
\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}
颜色
\usepackage{color} % 此命令应在\begin{document}之前
\color{color_name}text %color_name 可以是red、green、blue、cyan、yellow、magenta、white
字体大小
{\tiny tiny words}
{\scriptsize scriptsize words}
{\footnotesize footnotesize words}
{\small small words}
{\normalsize normalsize words}
{\large large words}
{\Large Large words}
{\LARGE LARGE words}
{\huge huge words}
列表list
有两种,有序和无序。
有序enumerate
\begin{enumerate}
\item One
\item Two
\end{enumerate}
无序itemize
\begin{itemize}
\item[] item %[]中填符号,默认为黑点
\item[] item
\end{itemize}
字符
字符 | 表示方式 |
---|---|
# | \# |
$ | \$ |
% | \% |
^ | \^{} 注意要加{},否则默认为紧跟的字符 |
& | \& |
_ | \_ |
{ | \{ |
} | \} |
~ | \~{} 注意要加{},否则默认为紧跟的字符 |
\ | \textbackslash,注意不是\\ |
注:
- 多个空格或换行,视为一个空格或换行
- \\ 表示换行
- 空行表示下一段
第四章 表格
\begin{tabular}{|l|r|c|} % |代表竖线,l代表左对齐,r代表右对齐,c代表居中
name & age & gender \\ % &代表分列,\\代表换行
\hline % 水平线
Francis & 10 & male \\
\cline{1-2} % 水平线,从第一列到第二列
Alice & 11 & female \\
\end{tabular}
第五章 图
\usepackage{graphicx} % 此命令应在\begin{document}之前
\begin{figure}[] %[]内填h(此处)、t(页顶)、b(页底)、p(独立一页),加!表示强制
\centering % 居中,默认左对齐
\includegraphics[width=1\textwidth]{my_figure} % 宽度为1倍文本宽度,1可以改为其他参数,my_figure为图名,包含路径和后缀
\caption{My Title} %图片标题
\label{My Label}
\end{figure}
第六章 公式
格式
$1+1=2$ % 行内公式
$$1+1=2$$ % 行间公式
\begin{equation} 1+1=2 \end{equation} % 带序号的行间公式
\begin{eqnarray} % 带序号多行公式
a & = & b+c\\
& = & d+e
\end{eqnarray}
若equation、eqnarray写为equation*、eqnarray*,则不带序号
分数
\frac{分子}{分母}
希腊字母
第七章 参考文献
暂不涉及。
更多高级用法,请参照http://en.wikibooks.org/wiki/LaTeX/。