2

I tried all the day to align verticaly my labels like this pic:

image

but without success. I've tried to implement this code but no success too...

this is my code:

\usepackage{pgfgantt}
\begin{document} 

\noindent\resizebox{\textwidth}{!}{
\begin{ganttchart}[
y unit title=0.4cm,
y unit chart=0.5cm,
vgrid,hgrid, 
time slot format=isodate-yearmonth,
compress calendar,
newline shortcut=true,
title left shift=.05,
title right shift=-.05,
title height=1,
bar height=.6,
bar label anchor/.append style={align=left, text width=5em}
]{2013-01}{2013-12}
\gantttitlecalendar{year}  \\ 
\ganttbar{Advection Parcelle de texture}{2013-01-01}{2013-01-26} \\ 
\ganttbar{Mise à jour structure de parcelle}{2013-01-20}{2013-03-23} \\ 
\ganttbar{Moulage du maillage 1}{2013-03-22}{2013-07-31} \\ 
\ganttbar{Atlas de texture, prise 2}{2013-07-01}{2013-08-10} \\ 
\ganttbar{Advection Parcelle de texture sur une surface 3D}{2013-08-10}{2013-08-31} \\
 \ganttbar{Rédaction}{2013-09-16}{2013-10-26} \\ 
 \ganttbar{Transformation des parcelles}{2013-10-20}{2013-11-30} \\
 \ganttbar{Moulage 2.0}{2013-12-02}{2013-12-31} \\
 \end{ganttchart}}

\end{document}   

It looks that the text width doesn't works correctly. May be it's something else...

Thanks a lot !

1 Answer 1

2

You're trying to modify the wrong style, it should be bar label node. With bar label node/.append style={align=left,text width=22em} the labels are aligned along their left edge. 22em was obtained through trial and error.

One way of avoiding guessing the width needed, is to use width("<longest label>"), as I did in the example below.

enter image description here

\documentclass[border=2mm]{standalone}
\usepackage{pgfgantt}
\begin{document} 
\begin{ganttchart}[
  y unit title=0.4cm,
  y unit chart=0.5cm,
  vgrid,hgrid, 
  time slot format=isodate-yearmonth,
  compress calendar,
  newline shortcut=true,
  title left shift=.05,
  title right shift=-.05,
  title height=1,
  bar height=.6,
  bar label node/.append style={
     align=left,
     text width=width("Advection Parcelle de texture sur une surface 3D")}
  ]{2013-01}{2013-12}
\gantttitlecalendar{year}  \\ 
\ganttbar{Advection Parcelle de texture}{2013-01-01}{2013-01-26} \\ 
\ganttbar{Mise à jour structure de parcelle}{2013-01-20}{2013-03-23} \\ 
\ganttbar{Moulage du maillage 1}{2013-03-22}{2013-07-31} \\ 
\ganttbar{Atlas de texture, prise 2}{2013-07-01}{2013-08-10} \\ 
\ganttbar{Advection Parcelle de texture sur une surface 3D}{2013-08-10}{2013-08-31} \\
\ganttbar{Rédaction}{2013-09-16}{2013-10-26} \\ 
\ganttbar{Transformation des parcelles}{2013-10-20}{2013-11-30} \\
\ganttbar{Moulage 2.0}{2013-12-02}{2013-12-31} \\
\end{ganttchart}
\end{document}   
5
  • It works ! Thank you ! Do you know if it's possible to add a \ganttalignnewline in my labels ? I would like to cut the label to make many lines in labels. Thanks again !
    – Patoch
    Commented Jan 9, 2014 at 18:15
  • @Patoch You've added newline shortcut=true, which makes \\ work as \ganttalignnewline. Hence, just use \\ to start a new line in a label. Commented Jan 9, 2014 at 18:29
  • Yes i have found it before your answer but i couldn't edit my post. Thank you for all !
    – Patoch
    Commented Jan 9, 2014 at 19:08
  • Any idea why the \widthof macro would lead to Missing number, treated as zero error in TeXLive 2015?
    – Paul M.
    Commented Jun 10, 2016 at 15:26
  • 1
    @PaulM. Changes in TikZ, use width("text") instead (see e.g. Macro involving TikZ node does not work) Commented Jun 10, 2016 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .