Showing posts with label Figures. Show all posts
Showing posts with label Figures. Show all posts

05 April 2015

\usepackage {} -- Float (for Figures, Tables, and Captions)

 \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])  
\renewcommand{\textfraction}{0.20} % \textfraction ≥ 0.15
     % 0.20 is the default, meaning floats will not cover more than 80% of text page.
\renewcommand{\topfraction}{0.70} % \topfraction ≤ 1 - \textfraction
     % 0.70 is default; prevents float with height > 70% of \textheight placed at top of text page.
\renewcommand{\bottomfraction}{0.30} % \bottomfraction ≤ (1 - \textfraction) AND ≤  \topfraction
     % 0.30 is default; prevents float with height > 30% of \textheight placed at bottom of text page.
\renewcommand{\floatpagefraction}{0.50} % \floatpagefraction ≤ (\bottomfraction - 0.05)
     % 0.50 is default; minimum fraction of float page that must be occupied by floats.


__________
 
A 'float' makes a container for a figure or table with a caption, and ensures that neither the element nor the caption is broken across multiple pages.  LaTeX does its best to ensure nice layout, but it's not always good at keeping relevant items on the same page.  Beware of attempting to force float placements.  If LaTeX cannot place one, it will usually have issues with the following ones as well.  Float specifier [options].

The \renewcommand options need not be specified if no changes are made.  If used, they are placed in the preamble.  More on customizing floats in CTAN's epslatex.pdf. 

\usepackage{} -- graphicx vs. graphics vs. psfig/epsfig

Using \usepackage{graphicx} is preferable to \usepackage{graphics} because although "both packages have the same capabilities, ... the resulting syntax may be more cumbersome [with the graphics package]."  TUGboat, Volume 17 (1996), No. 1, "Tutorials" (p. 43) -- PDF,

With \usepackage{graphicx}, "you can incorporate graphics in pdf, jpg, png or tif (with one f) formats. If you don't specify the file extension, it will look for and use whichever one is available."  However you may need \usepackage{graphics} if you have .eps graphics.

% \usepackage{psfig} and \usepackage{epsfig} are obsolete. (Link here.)
% \usepackage{epsf} % Obsolete, low-level typesetting of Encapsulated PostScript (EPS) files.

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.

\label{} for internal referencing, e.g. Figure and Table numbering.

\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. 

\begin{figure} \centering vs. \begin{center}

\centering doesn't leave vertical space before and after it. 

\begin{center} is an environment.  Also, the \centering command does not start a new paragraph.

Using \begin{figure} \centering is thus preferable to \begin{center}.

\captionof{element}{Caption text.} vs \caption{Caption text.}

\captionof{figure}{Caption text.} vs \caption{Caption text.} ... _NEED REF_ These have different purposes/effects. 
\captionof{table} or other elements work in this manner.

A multi-TeX-file thesis template with some introduction to simpler elements.

University of Oregon's Thesis and Dissertation LaTeX site.

It might be a bit under-automated, or a bit over-divided, as I'm not sure the abstract and the dedication need separate files.

A marvelously detailed, well-commented thesis package (even if it is in one document): "Using LaTeX for thesis writing..."

Using LaTeX for thesis writing at the University of Washington.

The author mentions he set it up as a single file in order to make file-sharing simpler, but it doesn't seem entirely clear how to set it up in the multiple-TeX-file format he suggests.