我整天都在尝试垂直对齐我的标签,就像这张图一样:
但没有成功。我尝试过实现这个代码,但是也没有成功...
这是我的代码:
\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}
看起来文本宽度无法正常工作。可能是其他原因...
多谢 !
答案1
您尝试修改的样式是错误的,它应该是bar label node
。bar label node/.append style={align=left,text width=22em}
标签沿其左边缘对齐。22em
是通过反复试验获得的。
避免猜测所需宽度的一种方法是使用width("<longest label>")
,正如我在下面的例子中所做的那样。
\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}