我喜欢为 pgfgantt 手册中此示例代码的 foobar 元素添加用于黑白打印的阴影图案。
\documentclass[a2paper, 10pt, parskip=full, listof=toc, bibliography=numbered, draft=false]{scrartcl}
\usepackage{pgfgantt}
\usetikzlibrary{shapes,arrows,patterns}
\begin{document}
\definecolor{foobarblue}{RGB}{0,153,255}
\definecolor{foobaryellow}{RGB}{234,187,0}
\newganttchartelement{foobar}{
foobar/.style={
shape=rounded rectangle,
inner sep=0pt,
draw=foobarblue!50!black,
very thick,
top color=white,
bottom color=foobarblue!50
},
foobar incomplete/.style={
/pgfgantt/foobar,
draw=foobaryellow,
bottom color=foobaryellow!50
},
foobar label font=\slshape,
foobar left shift=-.1,
foobar right shift=.1
}
\begin{ganttchart}[
vgrid,
progress=today,
progress label text=\relax,
today=6
]{1}{12}
\gantttitlecalendar{day} \\[grid]
\ganttfoobar{Foobar 1}{1}{2} \\
\ganttfoobar{Foobar 2}{3}{7} \\
\ganttlinkedfoobar{Foobar 3}{9}{12}
\end{ganttchart}
\end{document}
在这个问题中
pgfgantt 的 ganttbars 中的模式?解释了如何对单个条目执行此操作,但由于我有很多条目,我更愿意将其添加到 newganttchartelement 定义中,但我还没有找到这样做的方法。这可能吗?如果可以,您能举个例子吗?
答案1
该方法实际上与您提到的问题没有太大区别,即在样式pattern=north east lines
中添加例如foobar
。唯一的问题是填充覆盖了图案,但如果您设置,fill opacity=0.5
图案就会通过填充变得可见。
\documentclass[a2paper, 10pt, parskip=full, listof=toc, bibliography=numbered, draft=false]{scrartcl}
\usepackage{pgfgantt}
\usetikzlibrary{shapes,arrows,patterns}
\begin{document}
\definecolor{foobarblue}{RGB}{0,153,255}
\definecolor{foobaryellow}{RGB}{234,187,0}
\newganttchartelement{foobar}{
foobar/.style={
shape=rounded rectangle,
inner sep=0pt,
draw=foobarblue!50!black,
very thick,
top color=white,
bottom color=foobarblue,
fill opacity=0.5,
pattern=north west lines
},
foobar incomplete/.style={
/pgfgantt/foobar,
draw=foobaryellow,
bottom color=foobaryellow,
pattern=north east lines
},
foobar label font=\slshape,
foobar left shift=-.1,
foobar right shift=.1
}
\begin{ganttchart}[
vgrid,
progress=today,
progress label text=\relax,
today=6
]{1}{12}
\gantttitlecalendar{day} \\[grid]
\ganttfoobar{Foobar 1}{1}{2} \\
\ganttfoobar{Foobar 2}{3}{7} \\
\ganttlinkedfoobar{Foobar 3}{9}{12}
\end{ganttchart}
\end{document}