h- 和 v- 幻影 tikzpicture

h- 和 v- 幻影 tikzpicture

我尝试隐藏 tikzpicture:

根据布尔值,我想查看或不查看文档的 tikzpicures(在显示屏上显示它们,但在纸上隐藏它们),以便学生绘制它们。隐藏的 tikzpicture 会留下空白空间。

\vpanthom否则\hphantom不起作用。

答案1

您可以结合every picture风格和execute at end picture

\documentclass{article}
\usepackage{tikz}
\newif\ifhidepics
\hidepicsfalse
%\hidepicstrue % uncomment to hide tikzpicture

\ifhidepics
\tikzset{every picture/.append style={
execute at end picture={
\fill [white] (current bounding box.south west) rectangle (current bounding box.north east);
}}}
\fi

\begin{document}
Something here.

\begin{tikzpicture}
\node at (0,0) {A};
\node at (2,5) {B};
\end{tikzpicture}

More text.

\begin{tikzpicture}
\node at (0,0) {A};
\node at (2,2) {B};
\end{tikzpicture}

Test.

\end{document}

相关内容