# Resetting text width in a nested tikzpicture

I'm nesting a tikzpicture inside a tikzpicture, and having problems with the 'text width' parameter leaking through from the outer tikzpicture to the inner. (The nesting is pretty much unavoidable -- in my actual use case the tikzpicture s are defined in different macros.)

MWE:

\documentclass[a4paper,11pt,landscape]{article}
\usepackage{tikz,nopageno}

\begin{document}

\newcommand{\cost}{%
\begin{tikzpicture}
\node[fill=red!85!black,shape=circle,inner sep=0.3mm,draw=black,text=white] {\raisebox{0pt}[\height][0pt]{\bf 1}};
\end{tikzpicture}}

\cost

\begin{tikzpicture}
\node[text width=10mm] {\cost};
\end{tikzpicture}

\end{document}


How should I modify 'cost' so that it behaves as if text width was not set?

-

Package tikz maps the value of key text width to the macro content of \tikz@text@width. The default is empty, thus you can reset the key text width by option setting text width={}:

\documentclass[a4paper,11pt,landscape]{article}
\usepackage{tikz,nopageno}

\begin{document}

\newcommand{\cost}{%
\begin{tikzpicture}
\node[
text width={},
text height={}, % dito
fill=red!85!black,
shape=circle,
inner sep=0.3mm,
draw=black,
text=white,
] {\raisebox{0pt}[\height][0pt]{\bf 1}};
\end{tikzpicture}%
}

\cost

\begin{tikzpicture}
\node[text width=10mm] {\cost};
\end{tikzpicture}

\end{document}


-