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. git命令详情

    1.安装 yum install git 2.创建版本库 git init 3.添加文件 git add file.txt 4.提交文件 git commit -m “新增文件” 5.仓库当前状态 g ...

  2. 16:django 有条件的视图处理(Last-Modified和ETag)&&加密签名

    有条件的视图处理 上一节我们介绍了缓存来减轻服务器的负担,这里的有条件的视图处理也从一定程度上减轻了服务器的负担,在正式介绍之前,先来看两个概念:Last-Modified和ETag Last-Mod ...

  3. HTTP资源合集

    (1)MoZILLA开发者web技术文档之HTTP 未完待续...

  4. SEO优化:WordPress发布文章主动推送到百度,加快收录保护原创

    工作实在太忙,也没时间打理网站.最近公司额外交待了一些网站 SEO 方面的优化任务让我关注(这就是啥都要会.啥都要做的苦逼运维的真实写照了...). 于是抽空看了下百度站长平台,至少看到了2个新消息: ...

  5. css - 字体图标的制作

    很多的时候我们在开发过程中一般都是直接使用图片,尤其在移动页面频繁请求图片对性能不是很好 ,所以图标字体的应用也越来越广泛.一般情况下直接用的是font awesome字体,但是有时候需要制作自己风格 ...

  6. AC日记——Sagheer and Crossroads codeforces 812a

    812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include ...

  7. python多线程编程(6): 队列同步

    原文请看:http://www.cnblogs.com/holbrook/archive/2012/03/15/2398060.html 前面介绍了互斥锁和条件变量解决线程间的同步问题,并使用条件变量 ...

  8. SublimeCodeIntel代码自动补全配置

    主要使用python3,所有配置以python3为例.其他语言同理.利用sublimeCodeIntel插件可以实现自动提示python3代码.跳转追踪自定义函数.查看系统函数等.功能还是相当强大的. ...

  9. CUPOJ6242: LHC的二进制升级版

    6242: LHC的二进制升级版 时间限制:1秒 内存限制:128MB Special Judge 提交:6 正确:3 题目描述 在发现了3的二进制特殊性质后,LHC认为形如1.3.7.15..... ...

  10. VB查询数据库之登陆窗体——机房收费总结(一)

    机房收费系统已经做了很长一段时间了,虽然到目前为止,仍然没有结束,但已经结节尾声了.我感觉现在有必要回首总结一下整个机房收费系统. 除了结账做了一半,报表接触一点之外,其他的都基本上差不多了.从做过的 ...