I wanted to do this:
Crop jpeg into circular tikz node
but write with a variable width:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\def\mywidth{2cm}
\tikz\node[circle,draw,minimum size=1.2*\mywidth
text=white,
path picture={
\node at (path picture bounding box.center){
\includegraphics[width=1.2\mywidth]{frog}
};
}]{I'm watching you!};
\end{document}
Why does this not work? The includegraphics
command does not display the image in 1.2\mywidth
but some arbitrary size. The circle is the right size.
Second examples
Code 1
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\def\firstwidth{1cm}
\def\secondwidth{2\firstwidth}
\tikz\node[circle,draw,minimum size=\firstwidth,
path picture={
\node at (path picture bounding box.center){
\includegraphics[width=\firstwidth]{blackbox.png}
};
}]{};
\end{document}
Result 1
Code 2
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\def\firstwidth{1cm}
\def\secondwidth{2\firstwidth}
\tikz\node[circle,draw,minimum size=\firstwidth,
path picture={
\node at (path picture bounding box.center){
\includegraphics[width=0.5\secondwidth]{blackbox.png}
};
}]{};
\end{document}
Best Answer
It seems that the problem is how are defined lengths
\mywidth
,\firstwidth
and\secondwidth
. If insted of\def\mywidth{2cm}
etc use definitions:Your example will work as you expected (of course, if I correctly understand your problem):
Complete MWE is: