Latex学习与使用

Table of Contents

Latex学习与使用

  1. 简介

  2. 文档结构

  3. 排版

  4. 表格

  5. 图片

  6. 公式

  7. 索引

简介

Latex(发音lay-tek)是一个用来产生专业文档的系统,但它并不是一个单词处理器。它是一个适合用来生产结构化的文件以及排版公式的工具。

Latex基于Tex, 是由Donald Knuth发明的高质量数字排版系统。LatexMicrosoft Word不同,他们有着不同的工作方式。Microsoft Word"What You See Is What You Get"(WYSIWYG),这意味着你可以直接看到打印的内容。但是,在Latex中,你并不能直接看到最后你打印的结果。这让你聚焦于内容而非外观。

Latex是一个普通文件文件用.tex作为文件后缀。它可以使用一个简单的文本编辑器例如Notepad, 但是多数人发现如果使用专用的Latex编辑器是更容易的。Latex编译后输出的文本是PDF格式(Portable Document Format), 因为它是可以被打印并且在电脑之间容易传输。

文档结构

2.1 Essentials

  • 在使用前请打开Line Numbers,这样比较容易找到code的错误。

  • 在文本编辑中,\documentclass 命令必须出现在每个LATEX文件的开头。 在每个括号内的文本是具体文件类型。

  • article (journal articles and short reports)

  • report(PhD theses)

  • proc(conference proceeding)

  • book and slides

其中点击Typeset按钮用来运行文件。

2.2 Creating a Title

\maketitle 命令创建一个题目。你需要具体化一个title.

\begin{document} 命令后:

\title{My First Document}
\auther{My name}
\date{\today}
\maketitle

\today可以插入今天的日期
你也可以插入一个不同的日期,比如:\date{Novermber 2013}

Article文件开始文本在同页,而Reports在不同页

2.3 Sections

你应该分割你的文本成chapters,sections and subsections.

对于article类别:

  • \section{...}

  • \subsection{...}

  • \subsubsectin{...}

  • \paragraph{...}

  • \subparagraph{...}

2.4 Table of Contents

如果想使用命令来改变页码,则可以使用\pagenumbering{...}命令(i,ii.iii)
这些命令将确保文档开始于第一页

\tableofcontents来生成table of contents目录

整合命令如下:

\documentclass[a4paper,12pt]{article}

\begin{document}

\title{My First Document}
\author{My name}
\date{\today}
\maketitle

\tableofcontents
\newpage
\pagenumbering{arabic}

\end{document}

排版

3.1 Font Effects

输入:

\textsl{words slanted} \\
\textit{words in italics}  \\
\textsc{words in smallcaps} \\
\textbf{words in bold} \\
\texttt{words in teletype} \\
\textsf{sans serif words} \\
\textrm{roman words} \\
\underline{underlined words} \\

结果:

3.2 Coloured Text

\begin{document}前面添加\usepackage{color}包可以开始使用颜色包。具体的使用方法是,利用{\color{red}fire}

此时,fire就会变成红色

3.3 Font Sizes

{\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}

3.4 Lists

Latex支持两种类型的list,

enumerate 支持numbered lists

itemizebulleted lists.

每个list item\item定义

\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}

3.5 Comments & Spacing

注释使用%

\用来开始一个新行

\#
\$
\%
\^{}
\&
\-
\{
\}
\~{}

表格

tabular命令被用于排版表,\begin{tabular}{}

l for a column of left-aligned text
r for a column of right-aligned text
c for a column of centre-aligned text
| for a vertical line

例如{lll}{i.e.left left left}将生产3列左对齐的非垂直线,然而{|l|l|r|}将产生两列左对齐和一列右对齐的垂直线。

  • &是被放置在列中

  • \被放在行的末尾

  • \hline插入一个水平线

  • \cline{1-2}插入一个临时的水平线在column 1column 2

\begin{tabular}{|l|l|}
\hline
Apples & Green \\
\hline
Strawberries & Red \\
\hline
Oranges & Orange \\
\hline
\end{tabular}

图片

插入图片graphicx包。图片类型可以是PDF,PNG,JPEG,GIF

首先使用\usepackage{graphicx}在文件的前言
\begin{document}之前

找到一个image并存储文件到LaTeX course

\begin{figure}[h]
\centering
\includegraphics[width=1\textwidth]{myimage}
\caption{Here is my image}
\label{image-myimage}
\end{figure}

取代ImageFilename使用文件的名字,去掉文件的扩展

公式

6.1 number display equation

你可以输入数学公式并使用dollar sign,这可以被用于数学符号在一个句子中。$1+2=3$
For example, $$1+2=3$$

若想有number display equation:

\begin{equation}
1+2 = 3
\end{equation}
\begin{eqnarray}
a & = & b + c\\
  & = & y - z
\end{eqnarray}

Powers被插入使用hat^符号,比如$n^2$生产n^2

Indices被插入使用underscore _ .比如$2_a$生产2a

如果power或者index包含多个one character,$b_{a-2}$

6.2 Fractions

Fractions被插入使用\frac{numerator}{denominator}

$$\frac{a}{3}$$ produces:

a/3

Fractions can be nested:

$$\frac{y}{\frac{3}{x}+b}$$

6.3 Roots

Square root symbols被插入\sqrt{} 被取代root内容
$$\sqrt{y^2}$$

$$\sqrt[x]{y^2}$$

Sums&Intgrals

命令\sum被插入一个sum symbol, \int插入一个integral.

$$\sum_{x=1}^5 y^z$$

$$\int_a^b f(x)$$

6.4 Greek letters

$\alpha$
$\beta$
$\delta,\Delta$
$\theta,\Theta$
$\mu$
$\pi,\Pi$
$sigma,\Sigma$
$\phi,\Phi$
$\psi,\Psi$
$\omega,\Omega$

索引

7.1 Inserting Referencees

Latex包含着可以使用引用和创建bibliographies.这个文件将会解释如何使用分离的BibTex文件来存储参考目录的细节。

接下来本章将会解释如何使用一个分离的BibTeX文件来存储索引的细节。

7.2 The BibTex file


BibTeX file拥有文件扩展名.bib,它必须和文件名保持一致。.bib文件是普通文本,他可以使用Latex编辑器编辑。用户可以使用BibTex文件来编辑如下格式。

@article{
Birdetal2001,
    Author = {Bird, R.B. and Smith},
    Title = {The hunting handicap: costly signaling in human foraging strategies},
    Journal = {Behavioral Ecology and Sociobiology},
    Volume = {50},
    Pages = {9-19},
    Year = {2001}

}

7.3 Inserting the bibliography

使用bibliography,

  • \bibliographystyle{plain}

  • \bibliography{Doc1}

7.4 Citing references

使用\cite{citationkey}可以引用索引在.tex文本中,如果你不想要一个文本引用,但是仍然希望引用出现在bibliography中,使用\nocite{citationkey}.

如果想加入一个page number 在in-text citaton中,使用\cite[p.215]{citationkey}来进行

如果想要使用多个索引报刊不同的citation key,可以使用\cite{citation01,citation02,citation03}.

猜你喜欢

转载自www.cnblogs.com/zhichun/p/12060653.html