# How to disable rendering of certain package content (draft mode)

I'm using the tikz-cd package for drawing commutative diagrams. Now I want to disable the rendering of the content produced by this package similar to the behaviour when importing the graphics package via the draft option. This is for the speed of compiling speed whilst I'm editing the file. Unfortunately the draft option doesn't seem to exist for the tikz-cd package, so does anyone have an idea how I can still achieve the above described behaviour?

• The easy solution is to use externalize or standalone. You could also create a flag (\newif\ifrender) and simply test it each time. May 16 at 15:28
• Try \tikzexternalize: tex.stackexchange.com/a/482560/29873
– DG'
May 16 at 18:44

I propose this solution:

\documentclass{article}
\usepackage{tikz-cd}

\usepackage{xifthen}
\newboolean{draftMode}
\setboolean{draftMode}{true}% turn on (true) or off (false)

\usepackage{verbatim}   % \comment and \endcomment
\ifthenelse{\boolean{draftMode}}{%
\renewenvironment{tikzcd}{\comment}{Draft\endcomment}
}

\begin{document}
$\begin{tikzcd} E \rar & \prod\limits_\alpha D_\alpha \arrow[r, shift left=0.75ex, "c"] \arrow[r, shift right=0.75ex, "d", swap] & \prod\limits_f D_{c(f)} \end{tikzcd}$
\end{document}


Important: The solution does not work if the commutative diagrams are written this way:

$\begin{tikzcd} E \rar & \prod\limits_\alpha D_\alpha \arrow[r, shift left=0.75ex, "c"] \arrow[r, shift right=0.75ex, "d", swap] & \prod\limits_f D_{c(f)} \end{tikzcd}$


So you need a newline before $ and $.

• This fails because for centering the tikz images I wrap the environment into $...$ May 16 at 19:32
• @Richard - There is \begin{center} ...\end{center}, {\centering ...}, \hfil...\par, and \noindent\makebox{\textwidth]{...}. All of these have fewer side effects than display style math. May 17 at 2:55
• ok, thanks a lot for the help! May 17 at 10:27