Graphics, Figures & Tables ⇒ Conditional Compilation of Figures
Conditional Compilation of Figures
I have figures in the paper that I am writing. Compiling the .tex file to a .pdf with figures takes time and I wanted to reduce that by conditionally compiling the figures. That is, I wanted to compile the figures after I was done with writing the text, but I still want the code to include the figures to be in its place. Is there a simple way? I tried google but couldn't understand most of the links.
-sgsawant
-sgsawant
Last edited by sgsawant on Mon Oct 10, 2011 12:55 am, edited 3 times in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Conditional Compilation of Figures
First of all you should clarify whether you are including external image files or drawing your figures with graphics packages like pgf/tikZ or PSTricks (or others).
Thorsten
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Conditional Compilation of Figures
Yeah, sorry about that. I am including external image files from the adjacent folder. Say for example fig1.png.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Conditional Compilation of Figures
Then simply set the »draft« option either globally for the document class or only for the graphicx package. This will replace the images with boxes of the same size which contain the path and name of the included file.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Conditional Compilation of Figures
Thanks! 
I am editing this reply because I have one more question - how to compile just a single figure, while the graphicx package has been set to the "draft" option? Is there a way?
-sgsawant

I am editing this reply because I have one more question - how to compile just a single figure, while the graphicx package has been set to the "draft" option? Is there a way?
-sgsawant
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Conditional Compilation of Figures
You can give the »draft« option also locally to the \includegraphics command to exclude certain images.
It goes without saying that you now have to drop the option for the document class or the package, respectively.
Code: Select all
\includegraphics[draft,scale=0.5]{filename}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Conditional Compilation of Figures
Thanks a lot mate!
... though I wish there was an option for a local inclusion of the keyword final.

... though I wish there was an option for a local inclusion of the keyword final.

Code: Select all
\includegraphics[final,width=8cm]{fig1.png}