Figures

To insert a figure in a LaTeX document, you write lines like this:

\begin{figure}
\centering
\includegraphics[width=3.0in]{imagefile1}
\caption{Caption for figure}
\label{fig:sample_figure}
\end{figure}

The whole block is enclosed between \begin{figure} and \end{figure}. The command\includegraphics does the actual insertion of the image. Here the file name of the inserted image isimagefile1. If you are using LaTeX to process your document, .eps extension is appended automatically to the file name. If you are using pdfLaTeX, it appends .pdf, .png, or .jpg when searching for the image file.

By default, figures are looked for in the current directory (the one in which your .tex file is located). If you want to specify a path for the \includegraphics command, remember to use forward slashes (/) as directory separators, not backslashes. For example, if your figures are in a sub-directory named “figures” inside the current directory, you write something like this: \includegraphics[width=3.0in]{figures/imagefile1}.

You can also specify the width of the image. The height of the figure is scaled proportionally so the image doesn’t get distorted. Specify the width as a parameter (enclosed in brackets [ ]) to the \includegraphicscommand. Acceptable measurement units are for example in, mm, and cm. You can make the figure’s width equal to the width of paragraph text lines by using [width=\linewidth], or, for example, three quarters of the text width by using [width=0.75\linewidth].

Here we have used a \centering command to center the figure in the column. The \caption command gives a caption for the figure. We have also added a \label, which is useful when you want to refer to the figure in your text (see References).

Remember to always keep the commands in this order: First \includegraphics, then \caption, and finally \label. This way you get figure references right and captions underneath figures. Additionally, keep the \label and \caption commands always inside the \begin{figure}\end{figure} structure.

You can specify the locations where the figure (or table) is allowed to be placed by using placement parameters. For example, to put a figure at the bottom of page, you type \begin{figure}[b]. To allow a figure to be placed only at the top of page, write \begin{figure}[t]. To allow both locations, use [tb]. Other options are described, for instance, in Chapter 9 of Online tutorials on LaTeX.

If you don’t yet know how to create EPS images for LaTeX documents, read the Creating figures tutorial.

Subfigures

If you want to divide a figure into many smaller parts, use the \subfigure command. First, you have to add this in the beginning of your .tex file:

\usepackage{subfigure}

Let’s add three small figures in place of one normal figure:

\begin{figure}
\centering
\subfigure[First caption]
{
\includegraphics[width=1.0in]{imagefile2}
\label{fig:first_sub}
}
\\
\subfigure[Second caption]
{
\includegraphics[width=1.0in]{imagefile2}
\label{fig:second_sub}
}
\subfigure[Third caption]
{
\includegraphics[width=1.0in]{imagefile2}
\label{fig:third_sub}
}
\caption{Common figure caption.}
\label{fig:sample_subfigures}
\end{figure}

The result is:

Write as many \subfigure commands as you need. \subfigure takes an argument (enclosed in brackets [ ]) which specifies the caption for that subfigure. You don’t need to write the labels (a), (b), (c), etc., because LaTeX adds them automatically. Then put the \includegraphics and \label commands between { and } of the subfigure. Here we use an image file named imagefile2.eps. We have also specified a width for each image using the optional width parameter of the \includegraphics command.

Note the \\ after the first subfigure. This command creates a line break. In this case, it separates the three subfigures into two rows. Without the \\ all the three subfigures may end up in just one row. You can try the \\ also in other places and see its effect.

Finally, we put one more \caption and \label. These are for the whole three-part figure element.

Tables

A table in LaTeX may look a bit scary bunch of code at first. But you can copy and paste the basic lines that are needed. Then inserting your own text into the table is a piece of cake. Here we go:

\begin{table}
\renewcommand{\arraystretch}{1.3}
\caption{Simple table}
\label{tab:example}
\centering
\begin{tabular}{c|c}
\hline
Heading One & Heading Two\\
\hline
\hline Three & Four\\
\hline Five & Six\\
\hline
\end{tabular}
\end{table}

The result will look like this (using IEEE’s style):

Hence it’s a table with two columns and three rows. Here is how you organize the text in a table: In each table cell write the the text that you want to appear in the cell. Then type & when you want to jump to the next column. A new table row begins when you type \\. You can insert horizontal lines using the command \hline.

Here we have specified the column format like this: \begin{tabular}{c|c}. Every letter cl, or r denotes a column and | represents a vertical line between columns. c creates a column with centered text, l is for left aligned text, and r for right aligned. Thus, c|c creates two columns with centered text and a vertical line between them.

To get double lines between columns, use || instead of single |. To get no line between columns, omit the |. More columns can be added by using more cl, or r letters. For example, this produces four columns with no vertical lines: lccc. Now the leftmost column is left aligned and the others are centered.

You may wonder about the strange line \renewcommand{\arraystretch}{1.3}. This is needed for adjusting the white space around text in the table cells. The value 1.3 produces quite a pleasing look.

If you want to have the caption underneath the table, move the \caption and \label lines after the\end{tabular} line. Remember that the \caption command must be before \label.

Double column figures and tables

If you are writing a two column document and you would like to insert a wide figure or table that spans the whole page width, use the “starred” versions of the figure and table constructs. Like this:

\begin{figure*}
\centering
\includegraphics[width=\textwidth]{imagefile1}
\caption{This is a wide figure}
\label{fig:large}
\end{figure*}

You can use also subfigures inside figure*. An adequate width specifier for a double column figure iswidth=\textwidth. This makes the figure wide enough to span the whole body width (all columns) of the page.

A double column table is created in a similar way by using \begin{table*} and \end{table*}. Write the contents of the table in the usual way.

Note that double column figures and tables have some limitations. They can’t be placed at the bottom of pages. Additionally, they will not appear on the same page where they are defined. So you have to define them prior to the page on which they should appear.

Equations

Short mathematical expressions can be inserted within paragraph text by putting the math between $ signs. For example:

... angle frequency $\omega = 2\pi f$ ...

This is called an inline equation. The result is: .

In equations, the normal text symbols are written as such, for example 2 and f. Greek symbols are named for example \alpha\beta and so on. You don’t need to remember these because in WinEdt and TeXnicCenter you can use symbol toolbars, which have buttons for Greek letters and other math symbols.

Numbered equations are separate from paragraph text and LaTeX numbers them automatically. The contents are written using the same ideas as inline equations but now we write \begin{equation} and\end{equation} instead of $ signs. For example:

\begin{equation}
\label{eq:kinetic_energy}
E_{k} = \frac{1}{2}mv^{2}
\end{equation}

The result is:

Here we learn some structures which are often used in equations: The \frac command creates a fraction. Write the contents of the numerator and denominator inside the curly braces. Subscripts and superscripts are created using _{} and ^{}. (If the content of the subscript or superscript is a single symbol, you can omit the curly braces like this: E_k and v^2.)

Remember that an empty text line produces a paragraph break. Thus, omit empty lines before and after your equations, unless you really need a paragraph break there. This way you can easily explain the meaning of the variables (“where m is the mass and v is…”) so that the word “where” won’t start a new paragraph and won’t become indented.

You can freely type spaces in equations. LaTeX ignores extra spaces and determines automatically where (and how wide) space is needed (for example, on both sides of the = sign). However, line breaks are not allowed. Spaces are needed also to separate LaTeX commands. For instance, if you want to print , you must type \beta A, not \betaA. The latter one won’t compile because LaTeX is looking for a command named betaA.

Occasionally spaces in equations may need some fine adjustment. For example, consider the following two equations:

Equation (1) has been created by simply typing f_{res} = 500 MHz. It seems to have several problems:

  • The unit “MHz” and the subscript “res” have an incorrect spacing between letters. This is a common problem in variable names, subscripts, and units that consist of several letters. LaTeX understands “res” as a product of variables r, e, and s. Thus it adds a small space between each multiplicand. To fix the problems, write \mathrm{res} and \mathrm{MHz} . The “mathrm” stands for math “roman” (upright) font style.
  • The unit “MHz” and the subscript “res” should be typed with upright font, not italic. The aforementioned\mathrm command fixes this problem. If you, instead, want to use italic font, replace \mathrm with\mathit.
  • In equation (1), there is hardly any space between the number and the unit. LaTeX has thought that you want to multiply 500 times “MHz” and thus it removes all spaces you write here. To force a visible space, use command \,.

Here is the final fixed content of the equation, which produces the result (2) as shown above:

f_{\mathrm{res}} = 500 \, \mathrm{MHz}

If you have problems with a long equation that is wider than the space available on the page, you can split your math on several lines like this: First put \usepackage{amsmath} in the beginning of your LaTeX file. Then use \begin{split}...\end{split}:

\begin{equation}
\label{eq:long_equation}
\begin{split}
F &= a + b + c + d + e + f + g \\
&+ h + i + j + k + l + m \\
&= a + \ldots + m \\
&= 0
\end{split}
\end{equation}

The result looks like this:

To start a new line in your equation, add \\ to the end of the line. Additionally, put an & before the signs that should be aligned in a straight vertical line. Here we have aligned the = and + symbols.

Like shown above, amsmath can often provide a LaTeX solution to more demanding math problems. See the documentation of amsmath at TeX Catalogue Online or at CTAN.

from:http://www.electronics.oulu.fi/latex/examples/example_3/index.html

http://www.binghe.org/2010/04/figures-tables-and-equations-in-latex/

LaTeX:Figures, Tables, and Equations 插入图表和公式的更多相关文章

  1. Markdown插入图表

    链接:https://www.jianshu.com/p/3cf83d22dd3d Markdown图表语法 本文介绍如何用Markdown的mermaid等语法插入时序图.流程图.甘特图 如果是想学 ...

  2. 使用Free Spire.XLS插入图表

    使用Free Spire.XLS插入图表 前言 最近在研究Office中间件,上网搜索了下,比较出名的有两个:Aspose和Spire,两者功能齐全,对Office的支持趋近完善,但售价不菲.仔细搜索 ...

  3. 在线编辑Word——插入图表

    在Word中可插入图表,配合使用表格能够更加全方位的展示数据的可信度并增加数据的可读性.本文将通过使用在线编辑器 Spire.Cloud Word 演示如何来插入图表,并设置相关格式化操作.具体步骤如 ...

  4. word中插入myth type公式行距变大的问题

    在写文章时,我遇到了在word中插入myth type公式时,行距明显变大的问题,我通过改变段落中的行距没有解决问题,在网上查了一下,找到一些解决方法,仅供参考. 解决办法

  5. LaTeX插入图表方法 Lists of tables and figures

    Lists of tables and figures A list of the tables and figures keep the information organized and prov ...

  6. 利用openxml在Excel中插入图表

    using System.Collections.Generic; using System.Linq; using DOD = DocumentFormat.OpenXml.Drawing; usi ...

  7. LaTeX Hierarchical Tables

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/52692655 简单整理一下表格中的分级 ...

  8. MathType插入带序号公式的两种方法

    方法一: 由于我之前使用表格15% 70% 15%来布局的,所以最开始相的就是如何录入公示后插入公式序号,如下图所示 先设置序号格式 录好公式后点“Insert Number”就好了,这样的话需要紧挨 ...

  9. 解决latex数学公式渲染不正确及行内公式中文渲染乱码问题

    问题 之前数学OCR渲染数学公式用的 katex 来渲染,前端解决方案,我们的进行公式编写的时候是需要输入中文的,如: Fe_{2}O_{3} + 3 C O \stackrel{高温}{=} 2 F ...

随机推荐

  1. mycncart 前台代码跟踪

    1.进入根目录的入口文件,index.php require_once(DIR_SYSTEM . 'startup.php');//最为重要的一步 start('catalog');//执行了这个方法 ...

  2. linux命令(33):tail命令

    1.命令格式; tail[必要参数][选择参数][文件] 2.命令功能: 用于显示指定文件末尾内容,不指定文件时,作为输入信息进行处理.常用查看日志文件. 3.命令参数: -f 循环读取 -q 不显示 ...

  3. 【Mac电脑】Jenkins的安装

    1.JDK自己下载安装喽, 2.下载Jenkins 下载路径:https://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/2.121.1/jenki ...

  4. ELK系列--实时日志分析系统ELK 部署与运行中的问题汇总

    前记: 去年测试了ELK,今年测试了Storm,最终因为Storm需要过多开发介入而放弃,选择了ELK.感谢互联网上各路大神,目前总算是正常运行了. logstash+elasticsearch+ki ...

  5. <<持续交付>>终点的精彩

    1,向敏捷转变的过程是一个很容易出乱子的过程, 尤其对项目的领导力来说.在实施敏捷的过程中,会突然释放出一些有用的信息,将原来隐蔽起来的真相推倒聚光灯下. 2,假如执行者忽略了技术实践(比如测试驱动开 ...

  6. 【前端必备】三、JS篇

    1.运算符与隐式类型转换 类型判断: typeof constructor.toString().indexOf() NaN是numberArray.Date.Null都是Objectfunction ...

  7. Eclipse内嵌的webservice客户端

    概述 Eclipse内嵌的webservice客户端,可用于发起请求,查看结果,展示请求和响应的报文. 详情 在Java EE视图,可以看到内嵌的webservice客户端浏览器登陆按钮 点击打开浏览 ...

  8. 【C++】函数缺省参数的作用

    用法:void func(int param1, int param2 = 1, int param = 3) {} func(10); //等同于func(10, 1 , 3) func(10,8) ...

  9. 设计模式-模板方法模式(the Template Method Pattern)

    本文由@呆代待殆原创,转载请注明出处:http://www.cnblogs.com/coffeeSS/ 模板方法模式简介 这是一个被用的相当广泛的一种设计模式,变体也特别多,他建立一个抽象类定义一个算 ...

  10. Codeforces 741B Arpa's weak amphitheater and Mehrdad's valuable Hoses

    [题目链接] http://codeforces.com/problemset/problem/741/B [题目大意] 给出一张图,所有连通块构成分组,每个点有价值和代价, 要么选择整个连通块,要么 ...