In TikZ, there are draw=none
and fill=none
options to turn off stroking and filling operations. However, there doesn't appear to be a corresponding text=none
option. If I try \tikz \node[text=none] {X};
, I get the error message "Package xcolor Error: Undefined color `none'." (The text=red
option does work as expected.)
- Is there indeed no
text=none
option? - What are alternatives? Is it reasonable to use
text opacity=0
, or is there something better?
I'm asking because I would like to create an "empty" node of the same size as a given image or text. By referencing the anchors of this "empty" node, I can then animate the image or text moving in to occupy the same space. The following is an example of what I'm trying to accomplish. It uses text opacity=0
based on @percusse's suggestion.
\documentclass{minimal}
\usepackage{animate}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{animateinline}[autoplay,loop]{10}
\multiframe{11}{iframe=0+1}{
\begin{tikzpicture}[every node/.style={draw}]
\node[text opacity=0] (source) {Text};
\node[text opacity=0] (target) at (2,2) {Text};
\node at ($(source)!\iframe/10!(target)$) {Text};
\end{tikzpicture}
}
\end{animateinline}
\end{document}
- Given this ultimate goal, is it preferable to use something like
\node {\phantom{Text}};
?
Best Answer
If you don't need the text then it shouldn't be there anyway. Either you enlarge the node with
minimum width,height,inner sep
etc. or you can use thetext opacity
key comfortably.If you also need some placeholder for a text, you can go slightly esoteric and get the width depth height info beforehand e.g. just for the width;