Can I have two sets of milestones in one gantt chart? Each with a different style (such as colour, shape, etc.)?
3 Answers
You can use the usual pgf styling mechanisms to set up different styles, here Mile1 and Mile2, that you can pass to the optional argument of \ganttmilestone:

\documentclass{article}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[Mile1/.style={milestone/.append style={fill=red}},
Mile2/.style={milestone/.append style={fill=blue,shape=rectangle}}]{1}{12}
\gantttitle{2011}{12} \\
\gantttitlelist{1,...,12}{1} \\
\ganttgroup{Group 1}{1}{7} \\
\ganttbar{Task 1}{1}{2} \\
\ganttlinkedbar{Task 2}{3}{7}
\ganttnewline
\ganttmilestone[Mile1]{Milestone}{7}
\ganttnewline
\ganttbar{Final Task}{8}{12}
\ganttlink{elem2}{elem3}
\ganttlink{elem3}{elem4}
\ganttnewline
\ganttmilestone[Mile2]{Milestone}{10}
\ganttnewline
\ganttmilestone[Mile1]{Milestone}{12}
\end{ganttchart}
\end{document}
- 95,762
Sure you can do it. You can use the starred version of \newganttchartelement. Refer to Section 2.7 Defining Custom Chart Elements of the package documentation. A little example defining a second type of milestone, which I called mymilestone with different shape, colors, fonts:
\documentclass{article}
\usepackage{pgfgantt}
\newganttchartelement*{mymilestone}{
mymilestone/.style={
shape=isosceles triangle,
inner sep=0pt,
draw=cyan,
top color=white,
bottom color=cyan!50
},
mymilestone incomplete/.style={
/pgfgantt/mymilestone,
draw=yellow,
bottom color=yellow!50
},
mymilestone label font=\slshape,
mymilestone left shift=0pt,
mymilestone right shift=0pt
}
\begin{document}
\begin{ganttchart}[
milestone/.append style={fill=orange}]{1}{12}
\gantttitle{2011}{12} \\
\gantttitlelist{1,...,12}{1} \\
\ganttgroup{Group 1}{1}{7} \\
\ganttbar{Task 1}{1}{2} \\
\ganttlinkedbar{Task 2}{3}{7} \ganttnewline
\ganttmilestone{Milestone}{7} \ganttnewline
\ganttmymilestone{New milestone}{8} \ganttnewline
\ganttbar{Final Task}{9}{12}
\ganttlink{elem2}{elem3}
\ganttlink{elem3}{elem4}
\ganttlink{elem4}{elem5}
\end{ganttchart}
\end{document}

- 505,128
-
Perfect! Thanks. I got two answers basically doing the same thing. Sorry I just preferred the other style a tiny bit better, since it is done within the ganttchart element. -- Best – val Mar 13 '14 at 09:01
-
@Gonzalo Medina http://tex.stackexchange.com/questions/185865/need-help-in-pgfgantt – Micky K Jun 21 '14 at 12:25
Using Fontawesome 5 Symbols as Milestones
\documentclass[margin=1cm]{standalone}
\usepackage{pgfgantt}
\usepackage{fontawesome5}
\newganttchartelement{checkin}{
checkin/.style={font={\faSignIn}}
}
\newganttchartelement{checkout}{
checkout/.style={font={\faSignOut}}
}
\begin{document}
\begin{ganttchart}{1}{12}
\gantttitle{2022}{12} \
\gantttitlelist{1,...,12}{1} \
\ganttgroup{Group 1}{1}{7} \
\ganttbar{Task 1}{1}{2} \
\ganttlinkedbar{Task 2}{3}{7} \ganttnewline
\ganttcheckin{}{4}
\ganttmilestone{Milestone}{7}
\ganttcheckout{}{10}\ganttnewline
\ganttbar{Final Task}{8}{12}
\ganttlink{elem2}{elem3}
\ganttlink{elem3}{elem6}
\end{ganttchart}
\end{document}
Notes
The LaTeX package fontawesome5 provides symbols via a single symbol name (in the example
\faIcon{sign-in-alt} or \faSignIn*). On fontawesome.com you might encounter aliases which you cannot use. Forsign-in-altexists the aliasright-to-bracket. Check first the documentation of the LaTeX package to clarify which one you can use in LaTeX when you encounter errors like this:Package fontawesome5 Error: The requested icon right-to-bracket was not found.Another reason can be that the symbol has been added in a later version.
- 5,300
- 5
- 33
- 63
