文档库 最新最全的文档下载
当前位置:文档库 › LaTeX Floats, Figures and Captions

LaTeX Floats, Figures and Captions

LaTeX Floats, Figures and Captions
LaTeX Floats, Figures and Captions

LaTeX/Floats, Figures and Captions

Getting Started

Introduction

Installation

Installing Extra Packages

Basics

Common Elements

Document Structure

Text Formatting

Paragraph Formatting

Colors

Fonts

List Structures

Special Characters

Internationalization

Rotations

Tables

Title creation

Page Layout

Importing Graphics

Floats, Figures and Captions

Footnotes and Margin Notes

Hyperlinks

The previous chapter introduced importing graphics. However, just having a picture stuck in between paragraphs does not look professional. For starters, we want a way of adding captions, and to be able to cross-reference. What we need is a way of defining figures. It would also be good if LaTeX could apply principles similar to when it arranges text to look its best to arranging pictures as well. This is where floats come into play.

Floats

Floats are containers for things in a document that cannot be broken over a page. LaTeX by default recognizes "table" and "figure" floats, but you can define new ones of your own (see Custom Floats below). Floats are there to deal with the problem of the object that won't fit on the present page, and to help when you really don't want the object here just now.

Floats are not part of the normal stream of text, but separate entities, positioned in a part of the page to themselves (top, middle, bottom, left, right, or wherever the designer specifies). They always have a caption describing them and they are always numbered so they can be referred to from elsewhere in the text. LaTeX automatically floats Tables and Figures, depending on how much space is left on the page at the point that they are processed. If there is not enough room on the current page, the float is moved to the top of the next page. This can be changed by moving the Table or Figure definition to an earlier or later point in the text, or by adjusting some of the parameters which control automatic floating.

Authors sometimes have many floats occurring in rapid succession, which raises the problem of how they are supposed to fit on the page and still leave room for text. In this case, LaTeX stacks them all up and prints them together if possible, or leaves them to the end of the chapter in protest. The skill is to space them out within your text so that they intrude neither on the thread of your argument or discussion, nor on the visual balance of the typeset pages.

Figures

To create a figure that floats, use the figure environment.

\begin{figure}[placement specifier] ... figure contents ... \end{figure}

The previous section mentioned how floats are used to allow LaTeX to handle figures, while maintaining the best possible presentation. However, there may be times when you disagree, and a typical example is with its positioning of figures. The placement specifier parameter exists as a compromise, and its purpose is to give the author a greater degree of control over where certain floats are placed.

Specifier Permission

h Place the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)

t Position at the top of the page.

b Position at the bottom of the page.

p Put on a special page for floats only.

!Override internal parameters LaTeX uses for determining "good" float positions.

H

Places the float at precisely the location in the LaTeX code. Requires the float package,[3]

e.g., \usepackage{float}. This

is somewhat equivalent to h!.

What you do with these placement permissions is to list which of the options you wish to make available to LaTeX. These are simply possibilities, and LaTeX will decide when typesetting your document which of your supplied specifiers it thinks is best. In some special cases LaTeX won't follow these positioning parameters and additional commands will be necessary, for example, if one needs to specify an alignment other than centered for a float that sits alone in one page[4].

Use \listoffigures to add a list of the figures in the beginning of the document. To change the name used in the caption from Figure to Example, use \renewcommand{\figurename}{Example}in the figure contents.

Figures with borders

It's possible to get a thin border around all figures. You have to write the following once at the beginning of the document:

\usepackage{float}\floatstyle{boxed}\restylefloat{figure}

The border will not include the caption.

Tables

Floating tables are covered in a separate chapter. Let's give a quick reminder here. The tabular environment that was used to construct the tables is not a float by default. Therefore, for tables you wish to float, wrap the tabular environment within a table environment, like this:

\begin{table}\begin{tabular}{...} ... table data ... \end{tabular} \end{table}

You may feel that it is a bit long winded, but such distinctions are necessary, because you may not want all tables to be treated as a float.

Use \listoftables to add a list of the tables in the beginning of the document.

Keeping floats in their place

The placeins [5] package provides the command \FloatBarrier, which can be used to prevent floats from being moved over it. This can, e.g., be useful at the beginning of each section. The package even provides an option to change the definition of \section to automatically include a \FloatBarrier. This can be set by loading the package with the option [section] (\usepackage[section]{placeins}). \FloatBarrier may also be useful to prevent floats intruding on lists created using itemize or enumerate. The flafter package can be used to force floats to appear after they are defined, and the endfloat [6] package can be used to place all floats at the end of a document.

Captions

It is always good practice to add a caption to any figure or table. Fortunately, this is very simple in LaTeX. All you need to do is use the \caption{''text''}command within the float environment. Because of how LaTeX deals sensibly with logical structure, it will automatically keep track of the numbering of figures, so you do not need to include this within the caption text.

The location of the caption is traditionally underneath the float. However, it is up to you to therefore insert the caption command after the actual contents of the float (but still within the environment). If you place it before, then the caption will appear above the float. Try out the following example to demonstrate this effect:

\documentclass[a4paper,12pt]{article}

\usepackage[english]{babel}\usepackage{graphicx}

\begin{document}\begin{figure}[h!] \caption{A picture

of a gull.}\centering

\includegraphics[width=0.5\textwidth]{gull}

\end{figure}\begin{figure}[h!] \centering

\reflectbox{%

\includegraphics[width=0.5\textwidth]{gull}}\caption{A

picture of the same gull looking the other way!}

\end{figure}\begin{table}[h!] \begin{center}

\begin{tabular}{

Note that the command \reflectbox{...}flips its content horizontally.

Side captions

It is sometimes desirable to have a caption appear on the side of a float, rather than above or below. The sidecap package can be used to place a caption beside a figure or table. The following example demonstrates this for a figure by using a SCfigure environment in place of the figure environment.

\documentclass{article}

\usepackage[pdftex]{graphicx}\usepackage{sidecap}

\begin{document}\begin{SCfigure}\centering

\includegraphics[width=0.5\textwidth]%

{Giraff_picture}% picture filename\caption{ ...

caption text ... }\end{SCfigure}\end{document}

Unnumbered captions

In some types of document (such as presentations), it may not be desirable for figure captions to start Figure:. This is easy to suppress by just placing the caption text in the Figure environment, without enclosing it in a Caption. This however means that there is no caption available for inclusion in a list of figures.

Lists of figures and tables

Captions can be listed at the beginning of a paper or report in a "List of Tables" or a "List of Figures" section by

using the \listoftables or \listoffigures commands, respectively. The caption used for each figure

will appear in these lists, along with the figure numbers, and page numbers that they appear on.

The \caption command also has an optional parameter, \caption[''short'']{''long''}which is

used for the List of Tables or List of Figures. Typically the short description is for the caption listing, and the long

description will be placed beside the figure or table. This is particularly useful if the caption is long, and only a

"one-liner" is desired in the figure/table listing. Here is an example of this usage:

\documentclass[12pt]{article}\usepackage{graphicx}

\begin{document}\listoffigures

\section{Introduction}\begin{figure}[hb] \centering

\includegraphics[width=4in]{gecko}\caption[Close up

of \textit{Hemidactylus} sp.]{Close up of

\textit{Hemidactylus} sp., which is part the genus of

the gecko family. It is the second most speciose

genus in the family.}\end{figure}\end{document}

Labels and Cross-referencing

Labels and cross-references work fairly similarly to the general case - see the Labels and Cross-referencing section for more information.

If the label picks up the section or list number instead of the figure number, put the label inside the caption to ensure correct numbering. If you get an error when the label is inside the caption, use \protect in front of the \label command.

Wrapping text around figures

Although not normally the case in academic writing, an author may prefer that some floats do not break the flow of text, but instead allow text to wrap around it. (Obviously, this effect only looks decent when the figure in question is significantly narrower than the text width.)

A word of warning: Wrapping figures in LaTex will require a lot of manual adjustment of your document. There are several packages available for the task, but none of them work perfectly. Before you make the choice of including figures with text wrapping in your document, make sure you have considered all the options. For example, you could use a layout with two columns for your documents and have no text-wrapping at all.

Anyway, we will look at the package wrapfig. Note that wrapfig may not come with the default installation of LaTeX; you might need to install additional packages.

To use wrapfig, you must first add this to the preamble:

\usepackage{wrapfig}

This then gives you access to:

\begin{wrapfigure}[lineheight]{position}{width}

There are overall eight possible positioning targets:

r R right side of the text

l L left side of the text

i I inside edge–near the binding (in a twoside document)

o O outside edge–far from the binding

The uppercase-character allows the figure to float, while the lowercase version means "exactly here". [7]

The width is, of course, the width of the figure. An example:

\begin{center}

\includegraphics[width=0.48\textwidth]{gull}

\end{center}\caption{A gull}

\end{wrapfigure}

Note that we have specified a size for both the wrapfigure environment and the image we have included. We did it in terms of the text width: it is always better to use relative sizes in LaTeX, let LaTeX do the work for you! The "wrap"

is slightly bigger than the picture, so the compiler will not return any strange warning and you will have a small white frame between the image and the surrounding text. You can change it to get a better result, but if you don't keep the image smaller than the "wrap", you will see the image over the text.

The wrapfig package can also be used with user-defined floats with float package. See below in the section on custom floats.

Tip for figures with too much white space

It happens that you'll generate figures with too much (or too little) white space on the top or bottom. In such a case, you can simply make use of the optional argument [lineheight] . It specifies the height of the figure in number of lines of text. Also remember that the environment center adds some extra white space at its top and bottom;

consider using the command \centering instead.

Another possibility is adding space within the float using the \vspace{...}command. The argument is the size of the space you want to add, you can use any unit you want, including pt, mm, in, etc. If you provide a negative argument, it will add a negative space, thus removing some white space. Using \vspace tends to move the caption relative to the float while the [lineheight] argument does not. Here is an example using the \vspace command, the code is exactly the one of the previous case, we just added some negative vertical spaces to shrink everything up:

\vspace{-20pt}\begin{center}

\includegraphics[width=0.48\textwidth]{gull}

\end{center}\vspace{-20pt}\caption{A

gull}\vspace{-10pt}\end{wrapfigure}

In this case it may look too shrunk, but you can manage spaces the way you like. In general, it is best not to add any space at all: let LaTeX do the formatting work!

(In this case, the problem is the use of \begin{center}to center the image. The center environment adds extra space that can be avoided if \centering is used instead.)

Alternatively you might use the picins package instead of the wrapfig package which produces a correct version without the excess white space out of the box without any hand tuning.

There is also an alternative to wrapfig: the package floatflt [8]. (For documentation see [9].)

To remove the white space from a figure once for all, one should refer to the program pdfcrop, included in most TeX installations.

Subfloats

A useful extension is the subcaption package [10] (the subfigure and subfig packages are deprecated and shouldn't be

used any more), which uses subfloats within a single float. This gives the author the ability to have subfigures within figures, or subtables within table floats. Subfloats have their own caption, and an optional global caption. An example will best illustrate the usage of this package:

\usepackage{graphicx}\usepackage{caption}\usepackage{subcaption} \begin{figure}\centering\begin{subfigure}[b]{0.3\textwidth}\centering \includegraphics[width=\textwidth]{gull}\caption{A gull}\label{fig:gull} \end{subfigure}% ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc. %(or a blank line to force the subfigure onto a new line) \begin{subfigure}[b]{0.3\textwidth}\centering \includegraphics[width=\textwidth]{tiger}\caption{A tiger}\label{fig:tiger} \end{subfigure} ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc. %(or a blank line to force the subfigure onto a new line) \begin{subfigure}[b]{0.3\textwidth}\centering \includegraphics[width=\textwidth]{mouse}\caption{A mouse}\label{fig:mouse} \end{subfigure}\caption{Pictures of animals}\label{fig:animals}\end{figure}

You will notice that the figure environment is set up as usual. You may also use a table environment for subtables. For each subfloat, you need to use:

\begin{table}[] \begin{subtable}[]{}\centering ... table 1 ... \caption{} \end{subtable} ~ \begin{subtable}[]{}\centering ... table 2 ... \caption{}\end{subtable}\end{table}

If you intend to cross-reference any of the subfloats, see where the label is inserted; \caption outside the subfigure-environment will provide the global caption.

subcaption will arrange the figures or tables side-by-side providing they can fit, otherwise, it will automatically shift subfloats below. This effect can be added manually, by putting the newline command (\\) before the figure you wish to move to a newline.

Horizontal spaces between figures are controlled by one of several commands, which are placed in between \begin{subfigure}and \end{subfigure}:

? A non-breaking space (specified by ~ as in the example above) can be used to insert a space in between the subfigs.

?Math spaces: \qquad, \quad, \;, and \,

?Generic space: \hspace{''length''}

?Automatically expanding/contracting space: \hfill

Wide figures in two column documents

If you are writing a document using two columns (i.e. you started your document with something like \documentclass[twocolumn]{article}), you might have noticed that you can't use floating elements that are wider than the width of a column (using a LaTeX notation, wider than 0.5\textwidth), otherwise you will see the image overlapping with text. If you really have to use such wide elements, the only solution is to use the "starred" variants of the floating environments, that are {figure*}and {table*}. Those "starred" versions work exactly like the standard ones, but they will be as wide as the page, so you will get no overlapping.

A bad point of those environments is that they can be placed only at the top of the page or on their own page. If you try to specify their position using modifiers like b or h they will be ignored. Add \usepackage{dblfloatfix}to the preamble in order to alleviate this problem with regard to placing these floats at the bottom of a page, using the optional specifier [b] . Default is [tbp] . However, h still does not work.

To prevent the figures from being placed out-of-order with respect to their "non-starred" counterparts, the package fixltx2e[11] should be used (e.g. \usepackage{fixltx2e}).

Custom Floats

If tables and figures are not adequate for your needs, then you always have the option to create your own! Examples of such instances could be source code examples, or maps. For a program float example, one might therefore wish to create a float named program. The package float is your friend for this task. All commands to set up the new float must be placed in the preamble, and not within the document.

1.Add \usepackage{float}to the preamble of your document

2.Declare your new float using: \newfloat{type}{placement}{ext}[outer counter] , where:

?type - the new name you wish to call your float, in this instance, 'program'.

?placement - t, b, p, or h (as previously described in Placement), where letters enumerate permitted placements.

?ext - the file name extension of an auxiliary file for the list of figures (or whatever). Latex writes the captions to this file.

?outer counter - the presence of this parameter indicates that the counter associated with this new float should depend on outer counter, for example 'chapter'.

3.The default name that appears at the start of the caption is the type. If you wish to alter this, use

\floatname{type}{floatname}

4.Changing float style can be issued with \floatstyle{style}(Works on all subsequent \newfloat

commands, therefore, must be inserted before \newfloat to be effective).

?plain - the normal style for Latex floats, but the caption is always below the content.

?plaintop - the normal style for Latex floats, but the caption is always above the content.

?boxed - a box is drawn that surrounds the float, and the caption is printed below.

?ruled - the caption appears above the float, with rules immediately above and below. Then the float contents, followed by a final horizontal rule.

Float styles can also be customized as the second example below illustrates.

An example document using a new program float type:

\documentclass{article}\usepackage{float}\floatstyle{ruled} \newfloat{program}{thp}{lop}\floatname{program}{Program}\begin{document} \begin{program}\begin{verbatim} class HelloWorldApp { public static void main(String[] args) { //Display the string System.out.println("Hello World!"); }}\end{verbatim}\caption{The Hello World! program in Java.}\end{program} \end{document}

The verbatim environment is an environment that is already part of Latex. Although not introduced so far, its name is fairly intuitive! LaTeX will reproduce everything you give it, including new lines, spaces, etc. It is good for source code, but if you want to introduce a lot of code you might consider using the listings package, that was made just for it.

While this is useful, one should be careful when embedding the float within another float. In particular, the error

not in outer par mode

may occur. One solution might be to use the [H] option (not any other) on the inner float, as this option "pins" the inner float to the outer one.

Newly created floats with \newfloat can also be used in combination with the wrapfig package from above. E.g. the following code creates a floating text box, which floats in the text on the right side of the page and is complete

with caption, numbering, an index file with the extension .lob and a customization of the float's visual layout:

\documentclass{article}% have hyperref package before float in order to get strange errors with .\theHfloatbox\usepackage[pdftex]{hyperref}

\usepackage{float}% allows use of "@" in control sequence names \makeatletter

% this creates a custom and simpler ruled box style

\newcommand\floatc@simplerule[2]{{\@fs@cfont #1 #2}\par}

\newcommand\fs@simplerule{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@simplerule \def\@fs@pre{\hrule height.8pt depth0pt \kern4pt}%

\def\@fs@post{\kern4pt\hrule height.8pt depth0pt \kern4pt \relax}%

\def\@fs@mid{\kern8pt}%\let\@fs@iftopcapt\iftrue}% this code block defines

the new and custom floatbox float environment \floatstyle{simplerule}

\newfloat{floatbox}{thp}{lob}[section] \floatname{floatbox}{Text Box}

\begin{document}\begin{floatbox}{r}{}\textit{Bootstrapping} is a resampling technique used for robustly estimating statistical quantities, such as the model fit $R^2$. It offers some protection against the sampling bias.

\caption{Bootstrapping}\end{floatbox}\end{document}

Caption Styles

To change the appearance of captions, use the caption [12] package. For example, to make all caption labels small

and bold:

\usepackage[font=small,labelfont=bf]{caption}

The KOMA script packages [13] have their own caption customizing features with e.g. \captionabove,

\captionformat and \setcapwidth. However these definitions have limited effect on newly created float environments with the wrapfig package.

Alternatively, you can redefine the \thefigure command:

\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}

See this page for more information on counters. Finally, note that the caption2 package has long been deprecated.

Labels in the figures

There is a LaTeX package lpic [14] to put LaTeX on top of included graphics, thus allowing to add TeX annotations

to imported graphics. It defines a convenient interface to put TeX over included graphics, and allows for drawing a white background under the typeset material to overshadow the graphics. It is a better alternative for labels inside of graphics; you do not have to change text size when rescaling pictures, and all LaTeX power is available for labels.

A very similar package, with somewhat different syntax, is pinlabel [15]. The link given also points to the packages psfrag and overpic.

A much more complicated package which can be used in the same way is TikZ. TikZ is a front-end to a drawing library called pgf (which is used to make beamer for instance). It can be used to label figures by adding text nodes on

top of an image node.

Summary

That concludes all the fundamentals of floats. You will hopefully see how much easier it is to let LaTeX do all the hard work and tweak the page layouts in order to get your figures in the best place. As always, the fact that LaTeX takes care of all caption and reference numbering is a great time saver.

Notes and References

[1]https://www.wendangku.net/doc/8e13370231.html,/w/index.php?title=Template:LaTeX/Top&action=edit

[2]https://www.wendangku.net/doc/8e13370231.html,/w/index.php?title=Template:LaTeX/Contents&action=edit

[3]https://www.wendangku.net/doc/8e13370231.html,/tex-archive/macros/latex/contrib/float/

[4]https://www.wendangku.net/doc/8e13370231.html,/questions/28556/how-to-place-a-float-at-the-top-of-a-floats-only-page

[5]https://www.wendangku.net/doc/8e13370231.html,/tex-archive/macros/latex/contrib/placeins

[6]https://www.wendangku.net/doc/8e13370231.html,/pkg/endfloat

[7]http://ftp.univie.ac.at/packages/tex/macros/latex/contrib/wrapfig/wrapfig-doc.pdf

[8]https://www.wendangku.net/doc/8e13370231.html,/tex-archive/macros/latex/contrib/floatflt/

[9]https://www.wendangku.net/doc/8e13370231.html,/tex-archive/macros/latex/contrib/floatflt/floatflt.pdf

[10]ftp://ftp.dante.de/tex-archive/macros/latex/contrib/caption/subcaption.pdf

[11]https://www.wendangku.net/doc/8e13370231.html,/cgi-bin/texfaq2html?label=2colfltorder

[12]https://www.wendangku.net/doc/8e13370231.html,/macros/latex/contrib/caption/caption-eng.pdf

[13]http://www.komascript.de/

[14]http://www.math.uni-leipzig.de/~matveyev/lpic/

[15]https://www.wendangku.net/doc/8e13370231.html,/tex-archive/help/Catalogue/entries/pinlabel.html

This page uses material from Andy Roberts' Getting to grips with LaTeX (https://www.wendangku.net/doc/8e13370231.html,/writing/ latex) with permission from the author.

LaTeX入门教程

LaTeX入门教程 里面的图好多都刷不出来,于是我就自己运行了一遍,至少验证了这个教程的正确性O(∩_∩)O哈哈~ CTEX - 在线文档- TeX/LaTeX 常用宏包 资料下载: LaTeX2e插图指南LaT eX2e使用手册TeX语言CTeX FAQ 常见问题集 Contents ?TEX/L A TEX是什么? ?为什么要用TEX/L A TEX? ?安装 ?开始使用 ?数学符号 o行内公式与行间公式 o上标与下标 o常见的数学公式 o行列式与矩阵 o方程组与分段函数 ?使用中文 ?文章的各个部分 ?表格 ?插图 ?罗列 ?分割长文档 ?学习资料 ?幻灯片制作简介 ?重要建议 ?Bibliography T E X/L A T E X是什么? T E X 是一个非常优秀的排版软件,L A T E X 是基于T E X 之上的一个宏包集。因为L A T E X 的出现,使得人们使用T E X 更加容易,目前大部分人们使用的T E X 系统都是L A T E X 这个宏集。 为什么要用T E X/L A T E X? 我们为什么要用T E X/L A T E X 来排版我们的论文、书籍呢?因为它 ?排版的效果非常整齐漂亮; ?排版的效率高; ?非常稳定,从95年到现在,T E X 系统只发现了一个bug。由此可见它的稳定性; ?排版科技文献,尤其是含有很多数学公式的文献特别方便、高效。现今没有一个排版软件在排版数学公式上面能和T E X/L A T E X 相媲美; 安装 我们可以从https://www.wendangku.net/doc/8e13370231.html,上下载最新的中文T E X 套装,Windows 用户请下载CT E X 套装,Linux 用户可以下载TeXlive 来安装。安装过程就不用我多说了吧!

(完整word版)LaTeX入门教程v2.doc

计算机与 IT 入门实验讲义 LaTeX入门实验实验手册 大连理工大学软件学院 实训基地 2016 年 7 月

1 LaTeX 简介 LaTeX( L A T E X ,音译“拉泰赫”)是一种基于ΤΕΧ的排版系统,由美国计 算机学家莱斯利·兰伯特( Leslie Lamport)在 20 世纪 80 年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由 TeX 所提供的强大功能,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。这个系统同样适用于生成从简单的信件到完整书籍的所有其他种类的文档。 LaTeX 编辑器有很多,这里我们使用 WinEdt,它是 CTeX 自带的一款,功能比较齐全,也是我的入门编辑器。入门首推这款,下载CTeX 即可,也可以单独安装。 2 WinEdt 指南 首先我们来简单了解WinEdt 的使用,打开 WinEdt,新建空白文件,软件的基本界面如图所示。工具栏中蓝色框内为编译模式选项,本次实验中我们选择选择 PDFLaTeX。编译后我们可以使用该下拉菜单下的PDFTeXify 选项查看生成的PDF。

3 LaTeX 案例讲解 本次实验我们以 example.pdf 文档的编写为例讲解LaTex 编写文档的过程, 涉及到中文支持,图片插入,公式编辑,表格编辑,算法编辑等。文档对应的 .tex 源文件为 example.tex。 3.1 LaTeX 宏定义及中文支持 LaTex 宏定义主要设置了文档的基本格式和以及源文档编译时会用到的包。 如案例文档的源文件中,设置了如下的宏定义: \documentclass指定了要编写的文档类型为普通的文章。3-4 行设定了文档中 的段落要首行缩进两个空格,最后两行设定了文档的页边距,即上下左右均留出1.0cm 的空白。 LaTeX 在默认情况下不能支持中文字符,因此为了支持文档中的中文,我们 需要导入相应的中文包,其中最常用的方法是导入CJK 包,具体的命令如上图 第二行所示, \usepackage{CJK}。 3.2 LaTeX 文档结构 LaTeX 的文档包括宏定义和正文两个大部分,其中正文部分要写在一组 \begin{} 和\end{} 标签,如下所示 \end{document} 后面的内容不会出现在生成的文档中。 由于本案例中需要使用中文,要额外添加一对标签 \begin{CJK*} \end{CJK*},

LaTeX新人教程,教你快速入门

LaTeX新人教程,30分钟从完全陌生到基本入门 by Nan 对于真心渴望迅速上手LaTeX的人,前言部分可以跳过不看。 本教程面向对LaTeX完全无认知无基础的新人。 旨在让新人能够用最简单快捷的方式,轻松入门,能够迅速使用LaTeX完成基本的文本编辑。 尤其旨在破除部分新人对LaTeX在传闻中难以学习的恐惧感。 在入门之后,面对各种进阶应用、特殊要求与异常状况,可以自行咨询google 解决。 先用三句话来介绍什么是LaTeX,以下三点基于我个人的主观经验的总结。 https://www.wendangku.net/doc/8e13370231.html,TeX是一类用于编辑和排版的软件,用于生成PDF文档。 https://www.wendangku.net/doc/8e13370231.html,TeX编辑和排版的核心思想在于,通过\section和\paragraph等语句,规定了每一句话在文章中所从属的层次,从而极大方便了对各个层次批量处理。 https://www.wendangku.net/doc/8e13370231.html,TeX在使用体验方面,最不易被Word替代的有四个方面:方便美观的数学公式编辑、不会乱动的退格对齐、非所见即所得因此可以在编辑的时候用退格和换行整理思路但生成PDF出来不影响美观、部分导师和刊物不接受Word排版的文章。 我要严厉警告和强烈声讨那些自以为是advanced LaTeX user的人。请你们不要为了自己那一点可怜可悲的虚荣心,去刻意渲染LaTeX有多么高端多么不容易学习,这和孔乙己炫耀茴香豆的茴字有四种写法有什么区别么?混账!LaTeX到底有多“难”你们自己清楚好么?同理的还有很大一部分的VI user,还有Linux user,还有Fallout player。卧槽,一个软件而已,有什么好显摆的。别人想学LaTeX,好,你随手给人家丢一个几百页的英文Manual,显得自己很高端吗?你自己看过了吗?你推荐给别人的时候真的有希望别人看完吗?只是装逼的话就是混账! 我写这一篇教程的动机,正是因为网络上能够找到的简要速成的LaTeX教程完全没有。我能找得到的最简短或是说在我看来最具有指导意义的,就是那篇《一份不太简短的LaTeX介绍》。然而对于希望迅速对LaTeX有所了解的人,那一篇“不太简短的介绍”也仍旧稍嫌略长,我当初在入门时也研究了整晚。在LaTeX社区群里聊得久了,大家都是朋友,既然缺了这一块我又有闲情,那么就补上了。因此我写了这一篇教程,完全是以教会新人上手为目的,把华而不实的内容统统略去,确保能够在三十分钟内跟着这个教程走完全步骤就可以基本算是“玩转

LaTeX入门教程v2

计算机与IT入门实验讲义LaTeX入门实验实验手册 大连理工大学软件学院 实训基地 2016年7月

t h e b e n g a r e g o o d f o 1LaTeX 简介 LaTeX (L A T E X ,音译“拉泰赫”)是一种基于ΤΕΧ的排版系统,由美国计算 机学家莱斯利·兰伯特(Leslie Lamport )在20世纪80年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由TeX 所提供的 强大功能,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生 成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。这个系统同样适用于生成从简单的信件到完整书 籍的所有其他种类的文档。 LaTeX 编辑器有很多,这里我们使用WinEdt ,它是CTeX 自带的一款,功能比较齐全,也是我的入门编辑器。入门首推这款,下载CTeX 即可,也可以单独安装。 2WinEdt 指南 首先我们来简单了解WinEdt 的使用,打开WinEdt ,新建空白文件,软件 的基本界面如图所示。工具栏中蓝色框内为编译模式选项,本次实验中我们选择选择PDFLaTeX 。编译后我们可以使用该下拉菜单下的PDFTeXify 选项查看生成的PDF 。

3LaTeX案例讲解 本次实验我们以example.pdf文档的编写为例讲解LaTex编写文档的过程, 涉及到中文支持,图片插入,公式编辑,表格编辑,算法编辑等。文档对应的. tex源文件为example.tex。 3.1 LaTeX宏定义及中文支持 LaTex宏定义主要设置了文档的基本格式和以及源文档编译时会用到的包。如案例文档的源文件中,设置了如下的宏定义: \documentclass指定了要编写的文档类型为普通的文章。3-4行设定了文档 中的段落要首行缩进两个空格,最后两行设定了文档的页边距,即上下左右均 留出1.0cm的空白。 LaTeX在默认情况下不能支持中文字符,因此为了支持文档中的中文,我 们需要导入相应的中文包,其中最常用的方法是导入CJK包,具体的命令如上 图第二行所示,\usepackage{CJK}。 3.2 LaTeX文档结构 LaTeX的文档包括宏定义和正文两个大部分,其中正文部分要写在一组 \begin{}和\end{} 标签,如下所示 由于本案例中需要使用中文,要额外添加一对标签\begin{CJK*} \end{CJK*},

latex,article,最简单的模板

竭诚为您提供优质文档/双击可除latex,article,最简单的模板 篇一:latex教程--新手入门 20xx.5.19于百度文库搜寻到,将作者文中提到的文章 全部搜寻集中,放置于百度文库,方便自己在我初学latex 时,我自己有着很强烈的感受,对于新人来说,latex其实 不缺少长篇的系统论述的manual,但是缺少简短的stepbystep的一个example接一个example的有操作价值的tutorial。 我想大多数人接触latex的原因都和我一样,只是论文需要,并不是有多么想去当一个杂志编辑。 因此这一篇tutorial的起点为零,终点到满足写一个proposal就为止了。同时这一篇tutorial的内容只涉及信 息的撰写和录入,不涉及排版美化。我提倡的是新人们先开始跟着这个教程用latex来写起来,在把内容放进去之后,遇到怎么让版面更加规范美观的问题的时候,可以从容地去翻manual或者问google。 这篇教程中涉及的以及被我有意过滤掉的latex的功能,都是我仔细斟酌过的,我确保文章的内容对于新人来说完全

够用。 从proposal到paper当然还有一点距离,最重要的台阶是模板的应用,其次是做参考文献。 不过有了这篇文章垫底,至少能用latex编辑点东西了,也就不怕了,单独去google需要的部分的教材就可以了。 那么我个人对于即将接触latex的新人的教材建议是,先从这一篇出发,掌握这一篇里的内容之后,就可以开始着手撰写和编辑自己的latex文本了,比如自己的proposal 或者论文的提纲,一边写一边可以去看一下我学latex的时候觉得最简短有指导意义有操作价值的《一份不太短的 latex介绍》,那一篇教材里基本就涵盖了以写paper为目的全部latex功能需求了。 另外感谢朋友留言提醒了我另外一篇当初在我入门时 对我帮助非常大的教程,它名字很简单朴素叫做《latexnotes》。这个note和《不太短的》都是内容合理实用,没有多余的废话,没有职业编辑才可能用到的高端内容,而且充满了清爽的examples的教程。我也要强烈推荐出来。它可以通过搜索“latexnotes包老师”获得。我写的这一篇教程,从一定意义上说,可以算是那两个简短教程的再简短的节选。因为这篇文章中的内容,就是当我在初学latex的第一天,看着这两篇教程学会的,当时认为我最需要的技能。因此我将这些技能拿出来,带上我安排和精简过的例子,单

latex各种命令使用帮助

+---------------------------------+ |TeX各版本概述及基本约定,特殊字符| +---------------------------------+ tex提供300多条基本排版命令 由D.E.Knuth1978年开发 plain tex:在tex基础上新定义600多条复合命令 AMS-TEX:美国数学会开发(amsmath宏包)排版的数学公式 LATEX:https://www.wendangku.net/doc/8e13370231.html,mport(1985)编写,适合排版普通文章和书籍 LATEX2e:可加载amsmath宏包,目前最流行的TEX宏包 版本:LATEX2.09-->LATEX2e-->LATEX3(开发中) 中文排版: CCT:科学院张林波 TY(天元):华师大肖刚、陈志杰教授开发 CJK:德国W.Lemberg开发,处理中日韩三国文字。 发行版CTEX:集成了CCT,TY,CJK的MikTEX系统。 ChinaTEX:内容涵盖MiKTeX系统及中文支持、常用外围软件、TeX\LaTeX文档和模板选萃等 TeX中的长度 mm毫米 cm厘米 in英寸=2.54cm=72.27pt pt点 em大写字母M的宽度 ex小写字母x的高度 弹性长度:根据需要自动伸缩 正常值plus伸展值minus收缩值 实际长度可超过正常值和伸展值之和,但不能小于正常值和收缩值之差 \documentclass[11pt]{article}%11pt字体,普通文章 %导言区,全局命令 \usepackage{CJK}%使用CJK宏包 \begin{document}%主环境 \begin{CJK}{GBK}{song}%汉字必须放入CJK环境 %其它字体:song,kai,fs,hei,li,you %CJK的两种环境CJK和CJK* %GBK是采用的字符集:GB,GBK,Bg5,Gbt Hi,This is my first \LaTeX file 祝贺你,MikTex和CJK安装成功了 \end{CJK} \ent{document}

Latex常用命令

1. 段首缩进 中文习惯在段首缩进两格,在LaTeX中,\parindent表示段首缩进的长度,我们将它设置为当前字号的两个大写字母M的宽度,大约正好是两个汉字的宽度: \setlength{\parindent}{2em} LaTeX 默认每节的第一段的段首不缩进,这不符合中文排版习惯。我们希望正文的每一段都要缩进,使用indentfirst宏包就可办到: \usepackage{indentfirst} 2. 段距行距 LaTeX 用\baselineskip表示当前的行距,其默认值大约是当前字号的1.2倍,如果当前字号是10pt,那么\baselineskip是12pt。这对英文排版是合适的,对中文就显得太拥挤了,因为英文正文多为小写字母,字高与小写的x差不多(即1ex)。如果字号为10pt,那么1ex =4.3pt。我通常把行距设为字号的1.8倍: \setlength{\baselineskip}{1.8em} 这个值随时可以改,对更改点以后的文字有效。

LaTeX 用\parskip表示段距,我一般把它设为1ex: \setlength{\parskip}{1ex} 注意这些修改长度的命令最好都放在正文区(即\begin{document}之后)。 3. 页眉页脚 我通常用fancyhdr宏包来设置页眉和页脚。 \documentclass[10pt, a4paper]{book} \usepackage{fancyhdr} 我们在LaTeX中先把page style 设为fancy,再设置这个style 中的页眉和页脚。但是它默认每章的第一页的page style是plain,需要单独处理。 % 设置plain style 的属性 \fancypagestyle{plain}{% \fancyhf{} % 清空当前设置 % 设置页眉(head) \fancyhead[RE]{\leftmark} % 在偶数页的右侧显示章名 \fancyhead[LO]{\rightmark} % 在奇数页的左侧显示小节名\fancyhead[LE,RO]{~\thepage~} % 在偶数页的左侧,奇数页

Latex教程

Contents ?TEX/L A TEX是什么? ?为什么要用TEX/L A TEX? ?安装 ?开始使用 ?数学符号 o行内公式与行间公式 o上标与下标 o常见的数学公式 o行列式与矩阵 o方程组与分段函数 ?使用中文 ?文章的各个部分 ?表格 ?插图 ?罗列 ?分割长文档 ?学习资料 ?幻灯片制作简介 ?重要建议 ?Bibliography T E X/L A T E X是什么? T E X 是一个非常优秀的排版软件, L A T E X 是基于 T E X 之上的一个宏包集。因为 L A T E X 的出现,使得人们使用 T E X 更加容易,目前大部分人们使用的 T E X 系统都是 L A T E X 这个宏集。 为什么要用T E X/L A T E X? 我们为什么要用 T E X/L A T E X 来排版我们的论文、书籍呢?因为它 ?排版的效果非常整齐漂亮; ?排版的效率高 ; ?非常稳定,从95年到现在, T E X 系统只发现了一个 bug。由此可见它的稳定性; ?排版科技文献,尤其是含有很多数学公式的文献特别方便、高效。现今没有一个排版软件在排版数学公式上面能和 T E X/L A T E X 相媲美; 安装

我们可以从https://www.wendangku.net/doc/8e13370231.html, 上下载最新的中文 T E X 套装,Windows 用户请下载 CT E X 套装,Linux 用户可以下载TeXlive 来安装。安装过程就不用我多说了吧! 开始使用 好了,安装了,是不是很想试试身手了?那么准备好: ?打开一个编辑器。哦,你用的是 CT E X 套装吗?那就是那个 WinEdt ,在桌面上画了一支钢笔的那个东东。如果没有这个,也无所谓,你就打开一个记事本也行。 ?输入以下的代码: \documentclass{article} \usepackage{amsmath,amssymb} \usepackage{latexsym} \usepackage{CJK} \begin{document} \begin{CJK*}{GBK}{song} 测试一下我的数学公式\[\int_a^b f(x)dx\] \end{CJK*} \end{document} 上面的代码需要说明一下,我们将 \begin{document} 这个命令以前的部分叫做导言区,这部分主要用来声明使用什么宏包,重新定义命令,规划文章的总体布局等。所以,如果你的两篇文章大体上是一样的格式,你就可以把一篇文章的导言区拿到后面的文章里面去用,这样的话,用起来就方便得多。 ?保存该文件。将这个保存为 test.tex,文件名你可以另外取了,但是要记住,它的后缀必须是 .tex,这样系统才认得它。 ?编译。用的是 WinEdt 吗?那么就很简单了。你到它的工具条上找到L A T E X 这个按纽(工具条上,挨着狮子头的那个按纽),按下它就行了。在 Linux 下用 Kile?一样的了,只是那个按纽改成了一个齿轮而已了。 刚才不是说用记事本也行的嘛?那该怎么办呢?那,我先假设你把你的文件保存在了D盘的tex目录下面,这样做: o打开一个Dos窗口,点击“开始 附件 命令行”;

(完整版)LaTeX新人教程,一小时从完全陌生到基本入门(一种排版软件)

LaTeX新人教程,一小时从完全陌生到基本入门作者:董楠 LaTeX新人教程,一小时从完全陌生到基本入门 by Nan 对于真心渴望迅速上手LaTeX的人,可以只看正文。 曾经在缝缝补补中变得长长的“前言”被我丢到了正文后面当“后记”。 后记部分可以跳过不看或只看粗体。 原本这个版本的流程内容是30分钟。 后来应小伙伴呼声,加入了图片引用、公式引用和参考文献内容。 因此如果要走完这个流程的话,大致需要一个小时。 ============================================= 下面是教程正文。(正文最后应大家要求增添了附录) 注:文章里的代码我自己测试是可以直接复制进winedt编译成功的。但是有朋友反馈说编译不成功,检查后的结果大概是在人人网发帖的时候,人人网自己神奇的排版系统自主“智能”增添了一些换行符制表符类似物。因此如果直接复制编译不成功的时候,请尝试手打一遍。代码内容已经十分精简,相信手打起来也不会有太大压力。 https://www.wendangku.net/doc/8e13370231.html,TeX软件的安装和使用 方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinE dt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 方法B(打包):在https://www.wendangku.net/doc/8e13370231.html,下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt) 哈哈这一部分当然不包含在标题的一小时里。 新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。在真正开始跑步之前没有必要纠结该买NIKE跑鞋还是ADI跑鞋,跑起来再说。不要瞻前顾后,just try it. 2.第一个文档 打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。

latex使用教程升级版

%EXTERNAL FILES: %Name of language file: \cfile=. %Name of included files: \jfile=physjour,.mbs. head,\MBopta} \from{physjour.mbs}{\MBopta} \from{merlin.mbs}{tail,\MBopta}} \def\MBopta{% %<>INTERNAL LANGUAGE SUPPORT (if no external language file) %<