[Tex/LaTex] Draft option in TikZ like graphicx

tikz-pgf

We know the use of [draft] in graphicx package

\usepackage[draft]{graphicx}

Do we have any option like [draft] in tikz? Sothat we need not compile the tikz picture for every run and need not look at the picture…Is it possible to have something like this?

\usepackage[draft]{tikz}

or do i have any other method to do it?

Best Answer

You can use \tikzexternalize which is intended to speed up compile times. It converts each tikzpicture into a separate external graphic which is then imported with \includegraphics. And in [draft] mode graphics that are included from external sources do not get displayed.

Here is an example of enabling \tikzexternalize when in [draft] mode. With \documentclass[draft]{article} the MWE produces:

enter image description here

References:

Code:

\documentclass{article}
\usepackage{ifdraft}

\usepackage{tikz}
\ifoptionfinal{}{%
    \usetikzlibrary{external}\tikzexternalize
}

\begin{document}
\begin{tikzpicture}
    \draw[fill=yellow] (0,0) -- (3,0) -- (3,3) -- cycle;
\end{tikzpicture}
\end{document}
Related Question