focus on how to add figures, tables, and equations into your
document. Here are the complete source file and results in PDF
format:
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} end{figure}
The whole block is enclosed between begin{figure} and end{figure}.
The command includegraphics does the actual insertion of the image.
Here we insert a file named imagefile1.eps (or imagefile1.pdf when
using PdfLaTeX). LaTeX assumes a .eps file extension (and PdfLaTeX
assumes .pdf). You don't need to write it. You can also specify the
width of the image. Give it as a parameter (enclosed in brackets)
to the includegraphics command. Acceptable measurement units are
for example in, mm, and cm. Also the height of the figure is scaled
proportionally so the image doesn't get distorted.
The caption command gives a caption for the figure. We have also
added the label which is useful when you want to refer to the
equation in your paragraph text (see
References). Additionally, we have
used a centering command to center the figure in the column.
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{graphicx,subfigure}
You probably already have the graphicx package loaded so add only
the word subfigure here.
Let's add three small figures in place of one normal figure. Use
the subfigure command:
begin{figure} centering subfigure[First caption] {
includegraphics[width=1.0in]{imagefile2} label{fig_firstsub} }
subfigure[Second caption] {
includegraphics[width=1.0in]{imagefile2} label{fig_secondsub} }
subfigure[Third caption] { includegraphics[width=1.0in]{imagefile2}
label{fig_thirdsub} } caption{Common figure caption.}
label{fig_subfigures} end{figure}
The result is:
![[转载]在LATEX中如何实现双栏排版中键入跨栏图形和表格](http://www.electronics.oulu.fi/latex/examples/example_3/subfigs.png)
Write as many
subfigure commands as you have figures. subfigure takes an argument
(enclosed between [ and ]) which specifies the caption for that
subfigure. 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 command 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.
In the end, 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{table_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:
![[转载]在LATEX中如何实现双栏排版中键入跨栏图形和表格](http://www.electronics.oulu.fi/latex/examples/example_3/table1.png)
Hence it's a
table with two columns and two rows. Here is how you organize the
text in a table: Horizontal lines are separated by in the end of
line. That is, begins a new row. Then write hline to insert a
horizontal line (one or more). Write an & where you want a
vertical line.
The number of columns is specified like this: Here we used a line
like begin{tabular}{c|c}. The | represents a vertical line and c
makes the text of a column centered. Thus, c|c creates two columns
with centered text. Text can also be left and right aligned if you
use l or r instead of c. More columns can be added by using many |
symbols. For example, this produces four columns: l|c|c|c . 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.
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*}...end{figure*} or begin{table*}...end{table*}.
Write the contents in the usual way. You can use also subfigures
inside figure*.
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 $ and $. For example:
... angle frequency $omega = 2pi f$ ...
This is called an inline equation. The result is:
![[转载]在LATEX中如何实现双栏排版中键入跨栏图形和表格](http://www.electronics.oulu.fi/latex/examples/example_3/equation1.png)
.
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 the symbol toolbar which has buttons for
all the Greek letters and other math symbols.
Numbered equations are separate from paragraph text and they are
automatically numbered. The contents of the equation are written
using the same ideas as inline equations but now we write
begin{equation} and end{equation} instead of $s.
begin{equation} label{capacitor_impedance} X_{C} = frac{ 1 }{ omega
C } end{equation}
The result is:
![[转载]在LATEX中如何实现双栏排版中键入跨栏图形和表格](http://www.electronics.oulu.fi/latex/examples/example_3/equation2.png)
Here we learn
another structure which is often used in equations: the frac
command inserts a fraction whose numerator and denominator are
enclosed in braces.