04 April 2015

\begin{figure} -- Including Figures


\usepackage[hang, small,font=sf,labelfont=bf,up,rm,textfont=it,up]{caption} % Custom captions under/above floats in tables or figures  (Internal link here.)
\usepackage{graphicx(Internal link here.)
\usepackage{float} % Required for tables and figures in the multi-column environment - they need to be placed in specific locations with the [h] (e.g. \begin{table}[h])  (Internal link here.)
...
 
\begin{figure}[!htb] %(Lname2000_Fig7b.png)
            \centering
            \includegraphics[width=4 in]{./img/Lname2000_Fig7b}\\
            \captionof{figure}{Caption text.  May include math mode, e.g., $T_m = 414 \pm 3 K$, and commands such as \emph{emphasized text} and \ldots, as well as citations.{~\cite[Fig.~7b]{Lname2000}}}
            \label{fig:Lname2000_Fig7b}             
\end{figure}

_______________________

Using \begin{figure} \centering is preferable to another format such as \begin{center} This opens the environment.  (Internal link here.)

 The options [!htb]:       (Internal link here.)
    ! overrides the standard float options.
    h, here (in text)
    t, top (of page)
    b, bottom (of page)
    p, page (for floats), meaning a page that only has float element(s) such as figure(s).  This is a good option for large figures that would overwhelm a regular page of text.  I've not used [p] and I need to read more about it before I'm comfortable with it.
    H, "somewhat equivalent to h!" seems to be more pushy than 'h'

I've seen both ! first before other options and last after the others.  I've found nothing definitive that indicates whether order matters.

I use comment the \begin figure with %(Lname2000_Fig7b.png) for my own sanity.  I use LastnameYear to reference articles, and the _Fig7b is the figure as numbered in that article that I'm including.  (This is a literature review / summary I edit on a weekly basis in preparation for weekly meetings with my adviser.)

I keep all of my images in a folder titled 'img' inside my TeX folder for that project, so ./img/filename tells LaTeX to look for the 'img' folder within the current folder, and then find the named file in there.  This keeps my TeX folder tidier.

\includegraphics[width=4 in]{./img/Lname2000_Fig7b}
\includegraphics[width=0.67\linewidth]{./img/Lname2000_Fig7b}

Note one version has an absolute measurement, and the other has a fraction (0.67) of the \linewidth.  Both are valid.  One might be easier than the other, depending on your document.

\captionof{figure}{Caption text.} vs \caption{Caption text.} ... These have different purposes/effects. 
\captionof{table} or other elements work in this manner.  (Internal link here.)


\emph{emphasized text} vs. \textit{italicized text} -- If your captions are already italicized, \textit won't show any effect.  \emph can be nested such that an emphasized phrase within an italicized phrase will look like this.  (Internal link here.)


{~\cite[Fig.~7b]{Lname2000}}  ~ is a non-breaking space.  [Fig.~7b] is an [option] to include a specific element or page number from the reference.  (Internal link here.)

\label{fig:Lname2000_Fig7b} "fig" is a user-set class.  I also use "tbl" for tables.  "Lname2000_Fig7b" is user set too, but I recommend you adopt a naming algorithm that makes labels and citations easy to remember.

\label MUST be on the line immediately following \caption to work.  (Internal link here.)


\end{figure} closes the environment.

No comments:

Post a Comment