# How to scale a Gantt figure?

Sketch:

I was trying to scale a Gantt chart in order to fit in to a Beamer presentation.

Suppose I have some gantt chart bigger than the presentation rectangle:

 \begin{figure}
\begin{gantt}{20}{20}
\begin{ganttitle}
\numtitle{2012}{1}{2016}{4}
\end{ganttitle}

%% lots of activities
\ganttbar{1}{0}{3}
...
...
\ganttbar{1}{0}{19}
%% lots of activities
\end{gantt}
\end{figure}


Question: How can I scale this figure to fix in a beamer frame?

Example: If I was using some PNG image, surely I will make this:

\begin{figure}
\includegraphic[scale=0.5]{mypngpic.png}
\end{figure}


But in gantt environment there is no (at least I don't know yet) a way to scale.

-

Since the gantt is based on TikZ, forcing the scale externally also works. I didn't check the code carefully but maybe there is a possibility to supply the options directly to the gantt environment. It has it's own key system but it didn't recognize the scale options.

\documentclass{article}
\usepackage{gantt}
\begin{document}
\tikzset{every picture/.style={yscale=0.3,transform shape}}
\begin{gantt}{5}{12}
\begin{ganttitle}
\numtitle{2012}{1}{2014}{4}
\end{ganttitle}
%% lots of activities
\ganttbar{1}{0}{3}
\ganttbar{1}{0}{10}
%% lots of activities
\end{gantt}

\tikzset{every picture/.style={yscale=1,transform shape}}
\begin{gantt}{5}{12}
\begin{ganttitle}
\numtitle{2012}{1}{2014}{4}
\end{ganttitle}
%% lots of activities
\ganttbar{1}{0}{3}
\ganttbar{1}{0}{10}
%% lots of activities
\end{gantt}

\end{document}


Note also that there is another TikZ based package pgfgantt.

-
There's xunitlengt for the x component, but unfortunately I didn't see a y analogous. – Gonzalo Medina Aug 27 '12 at 0:22
@GonzaloMedina Indeed. There is an additional ganttx option hook but I don't know what it's for. – percusse Aug 27 '12 at 0:25

Put the contents between \begin{gantt}{20}{20}......\end{gantt} in a file, say myganttfig1.tex. Then in your main tex file use \resizebox like:

%=========================
\begin{figure}[htb]
\centering{
\resizebox{0.62\textwidth}{!}{\input{myganttfig1.tex}}}

You may change the width 0.62\textwidth and height ! to suit your needs. The parameter {!} ensures that the height is decided keeping the aspect ratio intact.