## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ tikZ | Font Scaling in new Command Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

### tikZ | Font Scaling in new Command

Hello,

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.

Last edited by php1ic on Mon Sep 24, 2012 11:17 pm, edited 1 time in total.

Stefan Kottwitz
Posts: 9609
Joined: Mon Mar 10, 2008 9:44 pm
Generally, it can be good to add the option transform shape, when scaling:

\begin{tikzpicture}[scale=2, transform shape]   ...\end{tikzpicture}

In this case, I would not use the \fontsize commands with absolute values in the TikZ picture.

Stefan

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm
Thanks Stefan,

Using the standard font sizes solved the scaling issue.
%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.76) node[anchor=mid] {#4}+(0.5,0.25) node[anchor=mid] {\LARGE #5};}

I have read the pgf manual but can't find the section that explains the logic of the rounded corners, any tips? As with the fonts it seems to be an absolute value that doesn't scale.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm
By trail and error, a unit square can be converted to a circle by using rounded corners=10*sqrt(2). From there is was a simple case of reading about pgfmath and implementing

Working example is below, only \nsize and \nround need to be changed in the pre-amble

Thanks for looking, thinking and commenting.