制服巨乳

Help Desk

Information Technology

Graphics in LaTeX

If your thesis has a lot of figures, LaTeX might be preferable to a word processor for its stability and ability to store images separate from the document, saving space and memory. One thing that may be annoying is the way it handles "floats'' like tables and figures. LaTeX will try to find the best place to put your object based on the text around it and until you're really, truly done writing you should just leave it where it lies. There are some optional arguments to the figure and table environments to specify where you want it to appear; see the directions below.

Your graphic needs to be a pdf, jpeg, or png to work in LaTeX.

Inserting a Graphic

To use graphics in LaTeX, you must include the graphicx package using the declaration below. You should put it in the preamble, after the \documentclass declaration: \usepackage{graphicx}

If you need a graphic or tabular material to be part of the text, you can just put \includegraphics{subdivision} where you want the figure to go. It will not have a caption or any fancy formatting.

If you need it to appear in the list of figures or tables, it should be placed in a float environment (such as figure).

\begin{figure}[htbp]
\begin{centering}
\caption[optional figure title]{figure title. Also more of the caption.}
\includegraphics{subdivision}
Do not name the file's extension (.jpg, .pdf), and make sure the file name does not have any spaces.
\label{subd}
\end{centering}
\end{figure}

back to top

Positioning Graphics

You can control the position of the figure on the page or within the chapter by including letters between the brackets after the \begin{figure} declarations. The options are h = right here, t = top of the page, b = bottom of the page, and p = separate page of figures. You can also place the letters in order of your preference and you can add an exclamation mark to make it try hard: \begin{figure}[h!tbp]. With this example, LaTeX will try REALLY hard to place it at that exact point in the text. If that does not work, it will place it at the top of the next page. If that also does not work, it will attempt to place it at the bottom of the page. The last resort will be placing it on a separate page (even if it will not take up a whole page) right before the start of a new chapter or section.

back to top

Rotating and Scaling Graphics

You can also do some minor editing to your figures in LaTeX. The following example shows how you can rotate and scale your graphic:

\begin{figure}[htbp]
\begin{centering}
\includegraphics[scale=0.5,angle=180]{subdivision}
\end{centering}
\end{figure}

When rotating, the angle must be in degrees without any unit information, and will move the image counter-clockwise. To rotate the image clockwise, give the degree as a negative value.

Scaling does not use percentages but decimals. If you divide the percentage you want by 100, you will get the decimal value to use. For example, to scale the image down by 75%, give a scale value of 0.75. A value of 1 will keep the image the original size.

You can also scale an image down to a specified height or width. So if you want your image to be 3 inches tall, put height=3in" in the square brackets. The width of the image will be scaled in proportion to the height. Obviously, here you will need to specify a unit. You can specify dimensions in inches (in), centimeters (cm), millimeters (mm) and others.

back to top

Cropping

With some clever work you can crop a figure, which is handy if (for instance) your EPS or PDF is a little graphic on a whole sheet of paper. The viewport arguments are the lower-left and upper-right coordinates for the area you want to crop.

\begin{figure}[htbp]
\begin{centering}
\caption{A Figure}
\includegraphics[clip=true, viewport=.0in .0in 1in 1in]{subdivision}
\label{subd3}
\end{centering}
\end{figure}

You can also use Photoshop or other image editing programs to crop your image. Preview can even be used to quickly crop an image! Just use the rectangle select tool to choose what you want to save, then go to Tools->Crop Image. Save or export the image, making sure to keep it in the same folder as your .tex file. No matter what application you use to crop the graphic, be sure to save it as a pdf, jpg or png.

back to top

Adding Subfigures

There's no need to use the subfigure environment! Try these easier methods instead.

First off, you can simply have two \includegraphics[scale=0.1]{} commands in the same figure environment. You may need to adjust the scale of each graphic to get them side-by-side in the resulting PDF.

If you want to label the figures (e.g. a, b, c, etc.), use a table in the figure environment! Here's an example from a student's thesis (you can put an optional \hfill{0.5cm} before (c) to nudge it closer to the third figure):

\begin{figure}[htbp]
\centering
\begin{tabular}{l l}
{\large(a)} & {\large(b)} \\
\includegraphics[scale=0.08]{bx1-bpy-alone} & \includegraphics[scale=0.08]{bx1-bpy-interacting}
\end{tabular}
\begin{tabular}{l}
\hfill{0.5cm}
{\large(c)} \\
\includegraphics[scale=0.09]{bx1-bpy-ben}
\end{tabular}
\caption[SCXRD of \textbf{BX1-bpy}]{SCXRD structure of \textbf{BX1-bpy} as (a) a single boroxine adduct, (b) pi stacking between two boroxine adducts, (c) inclusion of benzene via pi stacking.}
\label{fig:bx1-bpy}
\end{figure}

back to top

The Most Common Modifications for Thesis Students

We get lots of questions about how to modify figures to thesising students' specifications. Here are the most frequent queries and their answers:

To get this Do this
Change the number of your figure to the form 0.x   Right before your first \begin{figure}: \renewcommand{\thefigure}{0.x\arabic{figure}}
Make the numbers start at value n Right before the first \begin{figure}: \addtocounter{figure}{ n}
Change what the Table of Figures says about a figure       Modify the caption: \caption [ what you want it to say]{Figure legend contents.}
Make the figure legend use a smaller font Modify the caption: \caption \footnotesize{{Figure legend contents.} }


Here is an example figure that uses every one of these modifications:

\renewcommand{\thefigure}{0.x\arabic{figure}}
\addtocounter{figure}{4}
\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.5]{results2}
\caption[Flower type and percent specialization]{\footnotesize{Interaction bar plot showing the degree of specialization for each flower type.}
\label{barplot}
\end{center}
\end{figure}

back to top