# pgfgantt, wrap text in label

I have task explanations that are pretty long and because of that it is pushing my gantt chart off of the page. Is there anyway to be able to wrap the text so that it continues below the task title? I want to eventually be able to fill out all of the Objectives and Tasks and have them be nice rectangular packets next to the chart.

Here is my code:

\documentclass[11pt,a4paper,oneside]{article}
\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{pgf}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}
\usepackage{rotating}

\begin{document}
\pagebreak
\begin{rotate}{270}
\begin{ganttchart}[y unit title=0.6cm,
y unit chart=0.7cm,
vgrid,
title height=.85,
hgrid=true,
canvas/.style={fill=yellow!25, draw=blue, solid, very thick},
bar/.style={fill=gray, rounded corners=3pt},
bar left shift=.05,
bar right shift=-.05,
bar top shift=.3,
bar height=.3,vgrid={*1{blue, dashed}},
bar label font=\normalsize\color{black!50},
bar label anchor/.append style={align=left, text width=8mm},
group right shift=0,group top shift=.6,group height=.3,group peaks={}{}{0}]{23}
\gantttitle{2012}{5}
\gantttitle{2013}{12}
\gantttitle{2014}{6}\\
\gantttitlelist{8,...,12}{1}
\gantttitlelist{1,...,12}{1}
\gantttitlelist{1,...,6}{1}\\

\ganttgroup[group label anchor/.style={left=3.5cm}
]{Objective 1: Continuous news coverage of 911 events presented by Worldnet (Voice of America). Please Note: This news program was recorded by the non-profit Television Archive. The video is available as a "loan" only: This means it may be streamed but not downloaded. Network URL: http://www.ibb.gov}{1}{4}\\
\ganttbar{\textbf{Task a} International Union, United Automobile Workers of America
This is from the UAW-AFL faction that split with Homer Martin from the majority UAW-CIO HD6350.A8}{4}{2} \\

\ganttgroup{Objective 2:}{4}{6} \\

\ganttgroup{Objective 3}{4}{6} \\

\ganttgroup{Objective 4}{4}{6} \\

\ganttgroup{Objective 5}{4}{6} \\
\end{ganttchart}

\end{rotate}
\end{document}

-
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. – Marco Daniel Aug 6 '12 at 16:16

After several (fruitless) attempts using \parboxes and modifying the maximum length allowed for the text, I think that given the length of the text for the objectives and tasks, it would be appropriate to use a different approach.

One option would be to use tooltips so the Gantt chart only displays a little amount of text (the labels) and the information for a given objective or task will only be visible when hovering over that element.

The facytooltips package helps to achieve this task.

You need to create a PDF file containing the text for the tooltips (one tooltip per page). This PDF document can be produced using LaTeX; in this example I used a file (called tasktips.tex) having the following aspect:

\documentclass{article}
\usepackage{url}
\usepackage[framemethod=tikz]{mdframed}
\usepackage[createtips]{fancytooltips}

\newcommand\MyTip[2]{%
\keytip{#1}%
\begin{mdframed}[
innerlinewidth=1mm,linecolor=olive!50,
backgroundcolor=yellow!20,roundcorner=5pt,rightmargin=.25\textwidth]
#2
\end{mdframed}%
\newpage%
}

\begin{document}

\MyTip{obje1}{Continuous news coverage of 911 events presented by Worldnet (Voice of America). Please Note: This news program was recorded by the non-profit Television Archive. The video is available as a "loan" only: This means it may be streamed but not downloaded. Network URL: \url{http://www.ibb.gov}}

\MyTip{task1a}{ International Union, United Automobile Workers of America
This is from the UAW-AFL faction that split with Homer Martin from the majority UAW-CIO HD6350.A8}

\end{document}


The \MyTip command generates the tooltip text and its <key>; this <key> is to be used in the main document (the one containing the Gantt chart). The syntax for \MyTip is;

\MyTip{<key>}{<text>}


In the example, each tooltip text will be placed inside a framed colored box produced with the help of the mdframed package, but of course you can change the style according to your needs. Processing tasktips.tex (using pdflatex) you get a file tasktips.pdf containing the tooltips.

Now in your main file, all you have to do is to use the name of the PDF created in the previous step as the value for the package option filename, when loading fancytooltips:

\usepackage[filename=tasktips,mouseover,noextratext]{fancytooltips}


and then in the body of your document you use the \tooltip command:

\tooltip{<text>}{<key>}


to associate <text> with the tooltip corresponding to <key>. Here's the file with the Gantt chart and the \tooltip commands:

\documentclass[11pt,a4paper,oneside]{article}
\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{pgf}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}
\usepackage{rotating}

\begin{document}
\pagebreak
\begin{rotate}{270}
\begin{ganttchart}[y unit title=0.6cm,
y unit chart=0.7cm,
vgrid,
title height=.85,
hgrid=true,
canvas/.style={fill=yellow!25, draw=blue, solid, very thick},
bar/.style={fill=gray, rounded corners=3pt},
bar left shift=.05,
bar right shift=-.05,
bar top shift=.3,
bar height=.3,vgrid={*1{blue, dashed}},
bar label font=\normalsize\color{black!50},
bar label anchor/.append style={align=left, text width=1.5cm},
group right shift=0,group top shift=.6,group height=.3,group peaks={}{}{0}]{23}
\gantttitle{2012}{5}
\gantttitle{2013}{12}
\gantttitle{2014}{6}\\
\gantttitlelist{8,...,12}{1}
\gantttitlelist{1,...,12}{1}
\gantttitlelist{1,...,6}{1}\\

\ganttgroup{\tooltip{Objective 1}{obje1}}{1}{4} \\

\ganttgroup{Objective 2:}{4}{6} \\

\ganttgroup{Objective 3}{4}{6} \\

\ganttgroup{Objective 4}{4}{6} \\

\ganttgroup{Objective 5}{4}{6} \\

\end{ganttchart}

\end{rotate}
\end{document}


Some images:

and the tooltips once you hover over the text:

The downside is that you need to use AcrobatReader to properly display the tooltips.

-
Ok, the \tooltip command looks great on the screen. However, I need to be able to print this out. It will be a portion of a report when it is finalized. It would be ideal to have the Objective 1 the way it is and then have the text box that displays when you hover over it displayed below it. I'm not sure this might be an impossible or entirely too difficult a task. – Pete Aug 6 '12 at 19:23
@Pete I don't know if you can control the position of the tooltips with just the fancytooltips package; the package author has a Fancy-preview Perl-script here that could help with this (I wouldn't know; I haven't used it). Another idea is to leave the chart with just the labels and then in a new page give the description of objectives and tasks (using a description environment, perhaps). – Gonzalo Medina Aug 7 '12 at 0:26
I make the research proposal for my higher studies, now I am interested to make the timeframe/gantt style chart in the end of my research prposal to explain them how I start my research work and explain them. – Micky K Aug 1 at 6:25
@Pete facing the Error "\ProcessKeyvalOptions{Hyp}" what should I do next? I am trying to adjust this ganntt chart in my research proposal – Micky K Aug 1 at 9:03
@MickyK Without further information, nothing can be done. Please feel free to open a new question, providing there a MWE allowing us to reproduce the problem. – Gonzalo Medina Aug 1 at 14:15