Latex:figures, Tables, and equations inserting charts and formulas

Source: Internet
Author: User
Tags italic font

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. The file name of the inserted image is imagefile1 . If you were using LaTeX to process your document,. eps extension is appended automatically to the file name. If you is using Pdflatex, it appends. pdf,. png, or. jpg When searching for the image file.

By default, figures was 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 is 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 was scaled proportionally so the image doesn ' t get distorted. Specify the width as a parameter (enclosed in brackets []) to the \includegraphics command. Acceptable measurement units is 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 had used a command to center the figure in the \centering column. The \caption command gives a caption for the figure. We have also added a \label , which are useful when you want to refer to the figure in your text (see References).

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

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

If you don ' t yet know what 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 had to add the beginning of your. Tex file:

\usepackage{subfigure}

Let's add three small figures in place of the 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 a argument (enclosed in brackets []) which specifies the caption f or 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 the rows. Without the \ All the three subfigures could 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 is for the whole three-part figure element.

Tables

A table in LaTeX could look a bit scary bunch of code at first. But you can copy and paste the basic lines is needed. Then inserting your own text to 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 would look like this (using IEEE s style):

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

Here we have the specified the column format as this: \begin{tabular}{c|c} . Every letter c , l , or r denotes a column and | Represents a vertical line between columns. c creates a col Umn with centered text, was for left l aligned text, and for right r aligned. Thus, c|c creates, 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 is added by using c the more, l or r letters. For example, this produces four columns with no vertical lines: lccc . Now the leftmost column was left aligned and the others are centered.

Wonder about the strange line \renewcommand{\arraystretch}{1.3} . This was 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 has the caption underneath the table, move the and lines after the line \caption \label \end{tabular} . Remember that the \caption command must is before \label .

Double column figures and tables

If you are writing a, a, and would like to insert a wide figure or table that spans the whole page wid Th, 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* . A adequate width specifier for a double column, figure is width=\textwidth . This makes the wide enough to span the whole body width (all columns) of the page.

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

Note that double column figures and tables has some limitations. They can ' t is placed at the bottom of pages. Additionally, they won't appear on the same page where they is defined. So you had to define them prior to the page on which they should appear.

Equations

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

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

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

In equations, the normal text symbols is written as such, for example 2 and F. Greek symbols is named for example \alpha , And so on \beta . You don ' t need to remember these because in WINEDT and texniccenter you can use symbol toolbars, which has buttons for Gr Eek letters and other math symbols.

Numbered equations is separate from paragraph text and LaTeX numbers them. The contents is 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 is 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: and E_k .)

Remember that's the 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 can easily explain the meaning of the variables ("where m are the mass and v is ...") so that T He 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 was needed (for example, on both sides O f the = sign). However, line breaks is not allowed. Spaces is needed also to separate LaTeX commands. For instance, if you want to print, you are 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 and the equations:

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

  • The unit "MHz" and the subscript "res" has an incorrect spacing between letters. This was 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 is typed with a 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 are hardly any space between the number and the unit. LaTeX has thought the want to multiply "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}} = $ \, \mathrm{mhz}

If you had problems with a long equation that's wider than the space available on the page, you can split your math on s Everal lines like This:first put in the \usepackage{amsmath} 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 is 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 in amsmath 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 inserting charts and formulas

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.