I'm working on a large document which contains several figures. Due to the figures it takes a long time to compile.
I would like to comment out all the figures while I'm working and then put them back in at the end. To do this, I added something like
\renewenvironment{figure}{\begin{comment}}{\end{comment}}
which I could then comment out when needed. However, this just doesn't work and gives all sorts of problems. Specifically, I tried to compile this –
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{comment}
%\renewenvironment{figure}{\begin{comment}}{\end{comment}}
\begin{document}
\begin{figure}
\begin{center}
\includegraphics{image.png}
\end{center}
\end{figure}
\end{document}
With the % everything compiled perfectly. If I remove the %, I get an error
Excluding 'comment' comment.)
Runaway argument?
! File ended while scanning use of \next.
Best Answer
If you only include stand-alone images, then you can easily "turn of" the
\includegraphics
command by loading the document class (orgraphicx
) with thedraft
option:A similar approach would be to redefine
\includegraphics
to do whatever you want:However, if you create your graphics on-the-fly (using something like a
tikzpicture
orpspicture
), then you need to be more creative. One way to achieve this would be to capture the entire environment and gobble its contents:The same could be done using the
figure
(float) environment, but then you'd lose all references to\caption
(however, you could consider it).The environment-gobble mechanism could be made more advanced by actually writing the picture environment inside
\phantom
, thereby creating the required size/shape of the output. However, this would incur the same amount of compilation overhead/time.