3

I don't know if this is possible, but I have a document that contains multiple gantt charts that are "nested" and I'm wondering if I can link them using \href?

\documentclass[12pt,letterpaper]{report}
\usepackage[utf8]{inputenc}

\usepackage{pgfgantt}
\usepackage{xcolor}

\ganttset{
  group/.append style={orange},
  milestone/.append style={red},
  progress label node anchor/.append style={text=red},
}

\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor={blue!50!black},
    citecolor={red!50!black},
    urlcolor={blue!80!black}
}

\begin{document}

\chapter{Project}
     % Ganttchart specs
     \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
%     title/.style={fill=none},
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
%   progress label text={},
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.2},
     inline]{1}{24}
    % 
    %-------------------------------------------------------
    \gantttitle{Title}{24}\\
    %
    \gantttitle[]{Year 1}{12}
    \gantttitle[]{Year 2}{12} \\
    %
    \gantttitle{Q1}{3}
    \gantttitle{Q2}{3}
    \gantttitle{Q3}{3}
    \gantttitle{Q4}{3}
    \gantttitle{Q1}{3}
    \gantttitle{Q2}{3}
    \gantttitle{Q3}{3} 
    \gantttitle{Q4}{3}\\
    %
    %-------------------------------------------------------
    % Task 1
    %\ganttgroup[inline=false]{Task 1}{1}{5}\\
    \ganttgroup[inline=false]{\href{task1}{Task 1}}{1}{5}\\
    \ganttbar[progress=60,inline=false]{Planning}{1}{4}\\
    \ganttmilestone[inline=false]{Milestone 1}{9} \\

    % Task 2
    %\ganttgroup[inline=false]{Task 2}{10}{15}\\
    \ganttgroup[inline=false]{\href{task1}{Task 2}}{10}{15}\\
    \ganttbar[progress=10,inline=false]{Building}{10}{13}\\
    \ganttmilestone[inline=false]{Milestone 1}{16} \\


\end{ganttchart}


\chapter{Task 1}\label{task1}
     \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
%     title/.style={fill=none},
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
%   progress label text={},
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.2},
     inline]{1}{20}
    % 
    %-------------------------------------------------------
    \gantttitle{Task}{20}\\
    %
    \gantttitle{W1}{4}
    \gantttitle{W2}{4}
    \gantttitle{W3}{4}
    \gantttitle{W4}{4}
    \gantttitle{W5}{4}\\
    %
    %-------------------------------------------------------
    \ganttgroup[inline=false]{Group 1}{1}{5}\\
    \ganttbar[progress=80,inline=false]{A}{1}{4}\\
    \ganttmilestone[inline=false]{Milestone}{9} \\

    \ganttgroup[inline=false]{Group 2}{6}{20} \\ 
    \ganttbar[progress=60,inline=false]{B1}{6}{14} \\
    \ganttmilestone[inline=false]{Milestone}{13} \\
    \ganttbar[progress=15,inline=false]{B2}{12}{16} \\
    \ganttmilestone[inline=false]{Milestone}{16} \\       

\end{ganttchart}

\chapter{Task 2}\label{task2}
     \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
%     title/.style={fill=none},
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
%   progress label text={},
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.2},
     inline]{1}{24}
    % 
    %-------------------------------------------------------
    \gantttitle{Task}{24}\\
    %
    \gantttitle{W1}{4}
    \gantttitle{W2}{4}
    \gantttitle{W3}{4}
    \gantttitle{W4}{4}
    \gantttitle{W5}{4}
    \gantttitle{W6}{4}\\
    %
    %-------------------------------------------------------
    \ganttgroup[inline=false]{Group 1}{1}{9}\\
    \ganttbar[progress=10,inline=false]{A}{1}{8}\\
    \ganttmilestone[inline=false]{Milestone}{13} \\

    \ganttgroup[inline=false]{Group 2}{6}{16} \\ 
    \ganttbar[progress=20,inline=false]{B}{9}{15} \\
    \ganttmilestone[inline=false]{Milestone}{13} \\

    \ganttgroup[inline=false]{Group 3}{15}{24} \\ 
    \ganttbar[progress=20,inline=false]{C}{15}{18} \\
    \ganttmilestone[inline=false]{Milestone}{22} \\

\end{ganttchart}

\end{document}

Basically, I want to be able to click on each task, then the reference brings me to the section where the details on that task are presented.

The example above compiles and seems to create the links, but they are not clickable. In other words, I click on "task 1" but it doesn't bring me to that section of the document.

1

It should be \hyperref[task1]{Task 1} or even easier: \nameref{task1} which does not need to remember the name of the relevant chapter.

\href is meant for links to other documents rather.

I have shown both methods in the example.

\documentclass[12pt,letterpaper]{report}
\usepackage[utf8]{inputenc}

\usepackage{pgfgantt}
\usepackage{xcolor}

\ganttset{
  group/.append style={orange},
  milestone/.append style={red},
  progress label node anchor/.append style={text=red},
}

\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor={blue!50!black},
  citecolor={red!50!black},
  urlcolor={blue!80!black}
}

\begin{document}

\chapter{Project}
     % Ganttchart specs
     \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
%     title/.style={fill=none},
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
%   progress label text={},
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.2},
     inline]{1}{24}
    % 
    %-------------------------------------------------------
    \gantttitle{Title}{24}\\
    %
    \gantttitle[]{Year 1}{12}
    \gantttitle[]{Year 2}{12} \\
    %
    \gantttitle{Q1}{3}
    \gantttitle{Q2}{3}
    \gantttitle{Q3}{3}
    \gantttitle{Q4}{3}
    \gantttitle{Q1}{3}
    \gantttitle{Q2}{3}
    \gantttitle{Q3}{3} 
    \gantttitle{Q4}{3}\\
    %
    %-------------------------------------------------------
    % Task 1
    %\ganttgroup[inline=false]{Task 1}{1}{5}\\
    \ganttgroup[inline=false]{\hyperref[task1]{Task 1}}{1}{5}\\
    \ganttbar[progress=60,inline=false]{Planning}{1}{4}\\
    \ganttmilestone[inline=false]{Milestone 1}{9} \\

    % Task 2
    %\ganttgroup[inline=false]{Task 2}{10}{15}\\
    \ganttgroup[inline=false]{\nameref{task2}}{10}{15}\\
    \ganttbar[progress=10,inline=false]{Building}{10}{13}\\
    \ganttmilestone[inline=false]{Milestone 1}{16} \\


\end{ganttchart}
\chapter{Task 1}\label{task1}
     \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
%     title/.style={fill=none},
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
%   progress label text={},
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.2},
     inline]{1}{20}
    % 
    %-------------------------------------------------------
    \gantttitle{Task}{20}\\
    %
    \gantttitle{W1}{4}
    \gantttitle{W2}{4}
    \gantttitle{W3}{4}
    \gantttitle{W4}{4}
    \gantttitle{W5}{4}\\
    %
    %-------------------------------------------------------
    \ganttgroup[inline=false]{Group 1}{1}{5}\\
    \ganttbar[progress=80,inline=false]{A}{1}{4}\\
    \ganttmilestone[inline=false]{Milestone}{9} \\

    \ganttgroup[inline=false]{Group 2}{6}{20} \\ 
    \ganttbar[progress=60,inline=false]{B1}{6}{14} \\
    \ganttmilestone[inline=false]{Milestone}{13} \\
    \ganttbar[progress=15,inline=false]{B2}{12}{16} \\
    \ganttmilestone[inline=false]{Milestone}{16} \\       

\end{ganttchart}

\chapter{Task 2}\label{task2}
     \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
%     title/.style={fill=none},
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
%   progress label text={},
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.2},
     inline]{1}{24}
    % 
    %-------------------------------------------------------
    \gantttitle{Task}{24}\\
    %
    \gantttitle{W1}{4}
    \gantttitle{W2}{4}
    \gantttitle{W3}{4}
    \gantttitle{W4}{4}
    \gantttitle{W5}{4}
    \gantttitle{W6}{4}\\
    %
    %-------------------------------------------------------
    \ganttgroup[inline=false]{Group 1}{1}{9}\\
    \ganttbar[progress=10,inline=false]{A}{1}{8}\\
    \ganttmilestone[inline=false]{Milestone}{13} \\

    \ganttgroup[inline=false]{Group 2}{6}{16} \\ 
    \ganttbar[progress=20,inline=false]{B}{9}{15} \\
    \ganttmilestone[inline=false]{Milestone}{13} \\

    \ganttgroup[inline=false]{Group 3}{15}{24} \\ 
    \ganttbar[progress=20,inline=false]{C}{15}{18} \\
    \ganttmilestone[inline=false]{Milestone}{22} \\

\end{ganttchart}

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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