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.

I'm trying to use pgfgantt to create a gantt chart for a project spanning many weeks, thus the following code would overflow through the right margin. I can't find a way to alter the size of the grid elements or time slots:

\begin{tikzpicture}[x=.5cm, y=1cm]
\begin{ganttchart}%
[vgrid, hgrid]{50} % 50 weeks
\gantttitle{Title}{12} \\
\ganttbar{Task 1}{1}{4} \\
\ganttbar{Task 2}{5}{6} \\
\ganttmilestone{M 1}{6} \\
\ganttbar{Task 3}{7}{11}
\ganttlink{4}{2}{5}{3}
\ganttlink[b-m]{6}{3}{6}{4}
\ganttlink[m-b]{6}{4}{7}{5}
\end{ganttchart}
\end{tikzpicture}

My former question above, however here's a new angle...

How can I make pgfgantt scale everything by limiting its size to specific parameters? ex. I want it to span the full textwidth of the page or the full width save for the margins.

share|improve this question
    
Could you turn your code snippet into a compilable document by adding the necessary preamble and \begin{document}? –  Jake Jun 8 '12 at 7:05
add comment

3 Answers

With command \resizebox{new width}{new height}{what you want to resize} you can change dimensions of any latex box. This means that everything (text, lines, simbols, ...) will be adjusted to new dimensions. In first or second parameter you can use ! in order to keep original aspect ratio. With this command,

\documentclass{article}
\usepackage{lipsum}
\usepackage{pgfgantt}

\begin{document}
\lipsum[1]

\noindent\resizebox{\textwidth}{!}{
\begin{tikzpicture}[x=.5cm, y=1cm]
\begin{ganttchart}%
[vgrid, hgrid]{50} % 50 weeks
\gantttitle{Title}{12} \\
\ganttbar{Task 1}{1}{4} \\
\ganttbar{Task 2}{5}{6} \\
\ganttmilestone{M 1}{6} \\
\ganttbar{Task 3}{7}{11}
%\ganttlink{4}{2}{5}{3}
%\ganttlink[b-m]{6}{3}{6}{4}
%\ganttlink[m-b]{6}{4}{7}{5}
\end{ganttchart}
\end{tikzpicture}
}

\lipsum[2]
\end{document}

your Gantt chart would look something like:

enter image description here

share|improve this answer
add comment

[fr] tu peux jouer sur l'échelle de la figure s'il y a des noeuds, il faudra aussi ajouter transform shape mais cela risque de ne plus être très joli

[en] you can play on the global scale of the figure if there are knots, it will also add transform shape but this may not be very pretty

\documentclass[A4]{article}
\usepackage{tikz}
\usepackage{lipsum}

\begin{document}


\noindent \begin{tikzpicture}[scale=\textwidth/8cm]
\draw (0,0) rectangle (8,3);
\end{tikzpicture}

\lipsum[1]

\noindent \begin{tikzpicture}[scale=\textwidth/8cm,transform shape]
\node [rectangle,minimum width=8cm,minimum height=3cm,draw]{aaa};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
add comment

One partial solution seems to use x unit and y unit to shrink the size of the time slots. This solves my first question.

I will wait for any potential answer for my second question. :)

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.