I've created a new command that uses tikZ to draw a box at of a certain colour at x,y and add centered text of non-standard (bigger than
\Huge
) size. I made the following MWE using the random scale=5
but when I change it the fonts and rounded corners are 'wrong'.I cannot seem to get round the fact that the
\fontsize
is outside of the tikzpicture
environment so doesn't scale with everything else. I tried using transform canvas={scale=??}
but that didn't work.I basically want everything to scale if I change the value. Any ideas?
For context I have a code that will create between 1 and 4500 instance of the box so would like to easily set the scale for a small, 1/3rd page, portrait picture or a full landscape one.
Code: Select all
\documentclass{article}
\usepackage{tikz}
\usepackage{fix-cm}
\usepackage[T1]{fontenc}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{0.5em}
%Set scale factor
\newcommand{\nsize}[0]{5}
%Set how round the corners are (0=square)
\newcommand{\rc}[0]{40}
%Setup command to draw box and text
\newcommand{\nucleus}[5]{
\filldraw[draw=black,thick,fill=#1,rounded corners=\rc] (#2,#3) rectangle +(1,1)
+(0.5,0.75) node {\fontsize{40}{48} \selectfont #4}
+(0.5,0.4) node {\fontsize{72}{96} \selectfont #5};
}
\begin{document}
\begin{tikzpicture}[scale=\nsize]
\nucleus{green}{0}{0}{208}{Pb}
%\draw[step=0.1,gray,very thin] (-0.05,-0.05) grid (1.05,1.05);
\end{tikzpicture}
\end{document}