Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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}

enter image description here Note also that there is another TikZ based package pgfgantt.

share|improve this answer
    
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
add comment

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}}}
\caption{your caption \label{fig:mygantt1}
\end{figure}
%===========================

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.

As Gonzalo observes in his comments, in this particular case, it will be more suitable to use both height and width.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.