0

I need a hand with scaling a tikz generated picture.

I have an example of using tikz I found in one of the websites (not my own work). I am trying to scale and fit it into a6 layout. I read library graphics defines two commands resizebox{}{}{} and scalebox{}{}, which apparently tikz also includes. However, the commands generate series of errors: ! Undefined control sequence.

The reason why I am trying to scale the whole picture is scale=0.5 while defining environment tizkpicture also does not work.

The example:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[landscape,margin=0.5cm,a6paper]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,calendar}
\usetikzlibrary{decorations.markings}

\newcommand{\calrow}[1]{\nodeanchor=base east{l}; \nodebase right=of lun{m}; \nodebase right=of mar{m}; \nodebase right=of mer{g}; \nodebase right=of gio{v}; \nodebase right=of ven{s}; \nodebase right=of sab{d}; \node[darkgreen,above=of gio]{\textbf{#1}};}

\newcommand{\calperiod}[1]{\calendar[dates=\the\year-#1-01 to \the\year-#1-last] if(Sunday) [black!50] \holidays;}

\newcommand{\holidays}{% holidays in Italy if (equals=01-01) [black!50]% if (equals=01-06) [black!50]% if (equals=04-04) [black!50]% if (equals=04-05) [black!50]% if (equals=04-25) [black!50]% if (equals=05-01) [black!50]% if (equals=05-01) [black!50]% if (equals=06-02) [black!50]% if (equals=08-15) [black!50]% if (equals=11-01) [black!50]% if (equals=12-08) [black!50]% if (equals=12-25) [black!50]% if (equals=12-26) [black!50]% }

\colorlet{darkgreen}{green!50!black}

\begin{document}

\null \vfill

\resizebox{\textwidth}{!}{% \begin{tikzpicture}[every calendar/.style={week list}] \sffamily \matrix[row 1/.style={darkgreen, node distance=.3ex}, row 3/.style={darkgreen, node distance=.3ex}, column sep=1ex, draw=darkgreen,thick,rounded corners=5pt, postaction={decorate,decoration={markings,mark=at position 0.51 with {\node[fill=white,text=darkgreen,font={\bfseries\Large}] (year) {\the\year};}}}] {% % first row: week day and month \calrow{January} & \calrow{February} & \calrow{March} & \calrow{April} & \calrow{May} & \calrow{June} \

        % second row: calendar
        \calperiod{01} & \calperiod{02} & \calperiod{03} &
        \calperiod{04} & \calperiod{05} & \calperiod{06} \\[1ex]

        % third row: week day and month
        \calrow{July} & \calrow{August} & \calrow{September} &
        \calrow{October} & \calrow{November} & \calrow{December} \\
        % forth row: calendar
        \calperiod{07} & \calperiod{08} & \calperiod{09} &
        \calperiod{10} & \calperiod{11} & \calperiod{12} \\
    };
\end{tikzpicture}

}

\vfill

\end{document}

Celdor
  • 9,058
  • Welcome to TewX.SX! I think that you are following Martin Scharrer's answer from https://tex.stackexchange.com/questions/562483/error-using-resizebox-and-tikz. He actually gives three alternatives, the last of which is to use adjustbox. Using this solves your problem: \begin{adjustbox}{width=\textwidth}\begin{tikzpicture}...\end{tikzpicture}\end{adjustbox} –  Sep 13 '20 at 12:50
  • Hi. Yes, using adjustbox environment works for me, which scales everything inside the tikz, which is what I needed. Thanks! – Celdor Sep 13 '20 at 13:13

0 Answers0