7

I want pdflatex to produce a PDF with the images shown as empty rectangles.

pdflatex thesis.tex 

Will compile my thesis normally with pictures, but it takes about 5 min to compile

pdflatex -draftmode thesis.tex 

Will compile my thesis, showing that pdflatex has interpreted all of my commands, but it won't show a PDF so that I can see that it has actually done what I want. It takes about 20 sec to run.

\includeonly{Chapter4} 

Is faster, but gives a lot of errors making it harder to work out if my new bit of formatting code has done what I want. Also it isn't much faster.

I want something like

pdflatex -noimages thesis.tex

Which will create a PDF with empty rectangles where the images go, so that I can quickly check that the figures are in the right place, and any formatting, without having to wait 5 min between each attempt at formatting.

Any help is appreciated.

John1923
  • 163
  • 1
  • 7
  • 2
    Are the figures included with \includegraphcis, if so the draft option will do the trick. How are you including the pictures? – StrongBad May 28 '13 at 10:14
  • This is peripheral to your question, but may be of interest: here's a way of removing all tikzpicture's in your document. – jub0bs May 28 '13 at 10:46

2 Answers2

8

What about

\usepackage[draft]{graphicx}

in your .tex file?

  • This is exactly what I want, and works perfectly.

    Thank you

    – John1923 May 28 '13 at 10:20
  • There's also the \usepackage[demo]{graphicx} option, which will give you ugly black boxes instead. (Not sure what the advantage of that is, but it's there if you want it!) – John Wickerson May 28 '13 at 10:20
  • 4
    The options dvips and pdftex should not be passed to graphicx; the package detects by itself what driver to use for output. – egreg May 28 '13 at 10:24
  • @JohnWickerson the draft and demo options are very different. The draft option requires the image to exist and gets the bounding box size correct. The demo option works without the file existing and just makes up a bounding box. – StrongBad May 28 '13 at 10:26
  • @DanielE.Shub Ah, I see, that makes sense. Thanks for explaining that. – John Wickerson May 28 '13 at 10:27
  • 2
    You might also give the draft option as a class option instead (compared to the package option given in the answer). It might save some additional time depending on the other packages used. As the other packages then also use their draft mode (if they support one), this might change the document. – Patrick Häcker May 28 '13 at 10:33
  • @MMM

    What is a class option, and what is the code to add it?

    – John1923 May 28 '13 at 10:54
  • 2
    @John1923 instead of doing \usepackage[draft]{graphicx} do \documentclass[draft]{article}, or whatever class you are using, this way all packages get the draft option. – StrongBad May 28 '13 at 11:07
  • @DanielE.Shub Thanks, that is better than the original answer because I am using the CUEDthesisPSnPDF class which conforms to Cambridge university's thesis guidelines. The command \usepackage{graphicx} is buried in the class file, so I have to go into that each time I want to make it a draft. However the class itself is called at the top of my thesis.tex master document so I can just change \documentclass[oneside,12pt]{Classes/CUEDthesisPSnPDF} to \documentclass[oneside,12pt,draft]{Classes/CUEDthesisPSnPDF} – John1923 May 28 '13 at 12:04
  • @John1923 if you only want to pass the draft option to the graphicx package you can add \RequirePackage[draft]{graphicx} before the \documentclass line in you main file. – StrongBad May 28 '13 at 12:24
  • 1
    @egreg Some drivers are detectable (pdftex, xetex, vtex), others are not. Thus a package cannot detect dvips, for example. The user might run dvipdfm afterwards. IMHO it is perfectly ok, if someone specifies a DVI driver option that is not detectable. – Heiko Oberdiek May 28 '13 at 14:04
  • Adding \RequirePackage[draft]{graphicx} before the \documentclass{foo} in my main thesis.texcauses an option clash when the class file defines graphicx with \usepackage[pdftex]{graphicx} Is there a command that will allow 'graphicx' to be fed options at multiple points in the code? – John1923 May 28 '13 at 14:04
  • 3
    @John1923 @DanielEShub Options can be given to a package loaded by the document class by \PassOptionsToPackage before \documentclass. In this case \PassOptionsToPackage{draft}{graphicx}. Package graphicx also provides an alternative, option draft can also be changed after package loading: \setkeys{Gin}{draft}. – Heiko Oberdiek May 28 '13 at 14:09
  • @Heiko Oberdiek \PassOptionsToPackage{draft}{graphicx} Works perfectly, thanks. – John1923 May 28 '13 at 14:12
  • @HeikoOberdiek I mentioned pdftex and dvips; specifying pdftex would make it impossible to switch the document to use XeLaTeX without changing the option. Other drivers, as you say, are not automatically detected. – egreg May 28 '13 at 14:17
3

The other answer suggests

\usepackage[draft]{graphicx}

which is perfect for simple tex documents. However many of us use custom class files provided by universities or journals, and these files often contain

\usepackage[foo,bar,baz]{graphicx}

and we would rather not edit the provided class file.

There are two alternative solutions.

1) Call the custom class file with the draft class option

\documentclass[draft]{CustomClass}

This will send the draft option to every package declared in the file, causing many changes, but the graphics will be replaced by white boxes.

2) Send the draft option to the graphicx package. This must be done before the custom class is called.

\PassOptionsToPackage{draft}{graphicx}
\documentclass{CustomClass}    

Thank you to Daniel.E.Shub, MMM and Heiko Oberdiek for saying this in the comments to the other question.

John1923
  • 163
  • 1
  • 7