Monday, March 29, 2010

Latex: Commenting out a Figure

Sometimes it is helpful to typeset your documents without including the figures. For instance,
1. You want to share your .tex with someone but don't want to send them all of your eps figures.
2. You have one million figures in your document and this will allow you to compile it faster.

One solution is the following. You can use the ifthen package to comment out figures, by setting a global boolean at the head of your document.

Here are some latex details.

%Document Preamble
\usepackage{epsfig,graphicx, ifthen}

\newboolean{includefigs}
\setboolean{includefigs}{false} %true = show graphs or false = don't
\newcommand{\condcomment}[2]{\ifthenelse{#1}{#2}{}}

%Usage Example
\condcomment{\boolean{includefigs}}{
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.4]{Fig.eps}
\end{center}
\vskip -0.2in
\caption{Fun with graphics}
\end{figure}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.