33

I would like to do some stuff that is only enabled when the draft option is given in \documentclass[draft]{article}.

How would I go about doing this?

lockstep
  • 250,273
romeovs
  • 9,102

2 Answers2

57

There is also the ifdraft package that does what you want.

It defines \ifdraft{Do in draft}{Do in final} and some others

Seamus
  • 73,242
17

The draft option sets \overfullrule to 5pt; so you can say

\makeatletter
\def\ifdraft{\ifdim\overfullrule>\z@
  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\makeatother

and say

\ifdraft{do this, we are in draft mode}{do that, we aren't in draft mode}

Note that \ifdraft is not a real conditional, so perhaps it should be named \@ifdraft but this would force you to use it in definitions between \makeatletter and \makeatother.

Of course, you shouldn't be setting \overfullrule yourself.

egreg
  • 1,121,712