Moving figures around

A figure in LATEX needs a big block of text. Here’s an example from my Cand.scient thesis:

\begin{figure}
  \centering
  \includegraphics[width=0.6\textwidth]{figurar/kpno_magmp_fd_20011220_1716}
  \caption[Magnetogram av solskiva]{Magnetogram av solskiva, frå 20. 12. 2001. Svart tyder at
    synslinjekomponenten av det lokale magnetfeltet er retta mot
    sola, og kvitt tyder at komponenten er retta vekk frå sola.}
  \label{fig:magnetogram}
\end{figure}

Some disadvantages:

  1. It breaks the text flow when trying to read the document source. Even with a decent editor, it’s tricky to skip over the figure block.
  2. It’s tricky to move figures around. It’s easy to miss a line when cut’n'pasting, and then nothing will compile. Figure blocks can be big.
  3. In a long chapter with many figures, it’s bothersome to track down the right one for tweaking.

A possible solution: Wrap the figure block in a \newcommand{}, and stuff it in the beginning of the file or in a separate file that you load with \input{}.

\newcommand{\figmagnetogram}{
  \begin{figure}
    \centering
    \includegraphics[width=0.6\textwidth]{figurar/kpno_magmp_fd_20011220_1716}
    \caption[Magnetogram av solskiva]{Magnetogram av solskiva, frå 20. 12. 2001. Svart tyder at
      synslinjekomponenten av det lokale magnetfeltet er retta mot
      sola, og kvitt tyder at komponenten er retta vekk frå sola.}
    \label{fig:magnetogram}
  \end{figure}
}

Then inserting the figure into the text is as simple as
\figmagnetogram
And moving one line around isn’t nearly as hard as a block of 10-20 lines.

This entry was posted in LaTeX. Bookmark the permalink.

One Response to Moving figures around

  1. Silje says:

    Nice! :D
    Kanskje jeg tilogmed kan knabbe det til masteroppgaven min. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>