学习使用LATEX排版

Posted coding the code

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学习使用LATEX排版相关的知识,希望对你有一定的参考价值。

0.说明

本文使用的LATEX排版工具为CTEX套件,具体可参看上一篇博文。

1.排版实练

1)换行

每行最后加“\\”可进行换行,也可以使用\newline指令。\\换行还可以进行行距控制。

this is a line \\[1cm]
this is a new line

上述内容表示在原来行间距上加上1cm,值可以是负数,表示减去对应的行间距。不使用换行控制,即使进行回车(enter)也不会进行换行。

2)文档类别

先主要介绍“article”与“report",article没有章(chapter),可以用作短文或者小论文,report则是报告或者大论文。

文档结构主要有chapter/section/subsection/等。

3)简单示例

这里为了能对结果pdf进行很好的截图,使用article文档类别,report文档每个chapter会自动分页。test.tex文件内容如下:

 1 \documentclass{article}
 2 \begin{document}
 3 This is the first experience of \LaTeX.
 4 \section{Aesop Fables}
 5 \subsection{The Ant and the Dove}
 6 An ant went to the bank of a river to quench its thirst, and
 7 being carried away by the rush of the stream, was on the
 8 point of drowning.
 9 A Dove sitting on a tree overhanging the water plucked a
10 leaf and let it fall into the stream close to her. The Ant
11 climbed onto it and floated in safety to the bank.
12 \subsection{The Dog in the Manger}
13 A dog lay in a manger, and by his growling and snapping
14 prevented the oxen from eating the hay which had been
15 placed for them.
16 ‘‘What a selfish Dog!’’ said one of them to his companions;
17 ‘‘he cannot eat the hay himself, and yet refuses to allow
18 those to eat who can.’’
19 \section{The Eagle and the Arrow}
20 An eagle sat on a lofty rock, watching the movements of a
21 Hare whom he sought to make his prey.
22 An archer, who saw the Eagle from a place of concealment,
23 took an accurate aim and wounded him mortally.
24 \end{document} 

上述代码编译产生的pdf效果如下图:

技术分享

解释:第3行被当做引言,从而被自动缩进了。section后为节,subsection后为小结,节和小节被自动使用了响应的格式进行了加粗等设置。

4)加入标题(title)等信息

将test.tex的1-3行改为:

\documentclass{article}
\title{Aesop Fables}
\author{Aesop\thanks{Thanks to the reader.}
\and Nobody\thanks{Thanks to nobody.}}
\date{\today}
\begin{document}
\maketitle
This is the first experience of \LaTeX.

编译的pdf结果如下:

技术分享

解释:\title指令添加文章标题,\author加入作者名字,\thanks添加致谢,多位作者用\and 进行连接。\date加入日期,title的插入式在preamble区,并且需要在文本区(\begin{document}后)加入\maketitle指令来生成title信息。

5)加入目录

目录的插入非常简单,在上述基础上,在\maketitle指令后加入一行:

\tableofcontents

LATEX会自动根据章节(chapter)/节(section)/小节(subsection)等内容插入目录,此时需要编译两次,一次用于生成toc文件(table of contents),第二次根据toc真正的编入目录。

本文示例加入目录后,结果如下图:

技术分享

 

6)摘要

article/report文档类别可以有摘要,可以在\maketitle和\tableofcontents之间插入摘要,如下:

\begin{abstract}
The tale, the Parable, and the Fable are all common and popular
modes of conveying instruction. Each is distinguished by its own
special characteristics.
\end{abstract}

摘要使用\begin{abstract}   \end{abstract}进行标记,摘要会自动进行左右缩排,排版结果如下图:

技术分享

7)脚注与边注

可以使用\footnote{}加入脚注\marginpar{}加入边注,脚注和边注的内容写在{}内。

修改第一小节内容如下:

An ant\footnote{mayi in chinese} went to the bank of a river to quench its thirst, and being carried away by the rush of the stream, was on the point of drowning.
A Dove\marginpar{Pigeon} sitting on a tree overhanging the water plucked a leaf and let it fall into the stream close to her. The Ant climbed onto it and floated in safety to the bank.

编译后排版结果如下图:

技术分享

to be coutinued...

以上是关于学习使用LATEX排版的主要内容,如果未能解决你的问题,请参考以下文章

latex 学习笔记

在 LaTeX 中排版音乐

latex排版神器——Mathtype和Excel2LaTeX

latex排版神器——Mathtype和Excel2LaTeX

使用 Python 代码片段编写 LaTeX 文档

Latex中插入C语言代码