我想将月份范围(1-3个月、4-6个月......等等)作为我的甘特图的标题,但是当我这样做时:
\documentclass{standalone}
\usepackage{pgfgantt}
\def\printrange#1#2{%
\pgfmathparse{int(1+#1*#2)}\pgfmathresult%
-%
\pgfmathparse{int((1+#1)*#2)}\pgfmathresult}
\begin{document}
\begin{ganttchart}[vgrid,hgrid]{1}{12}
\gantttitlelist[title list options=%
{var=\y, evaluate=\y as \x%
using "Months \printrange{\y}{3}"
%using "Months \y"
}
]{0,...,3}{3}\\
\end{ganttchart}
\end{document}
我收到错误Incomplete \iffalse
。我不确定为什么,因为如果我\printrange{2}{3}
在甘特图之外执行此操作,我就会得到正确的打印范围。
我究竟做错了什么?
答案1
我不使用 pgf 或 ganttchart,我找不到错误。建议Expl3
\documentclass[border=3mm]{standalone}
\usepackage{pgfgantt}
\ExplSyntaxOn
\NewDocumentCommand{\printrange}{m m}
{
\int_eval:n { 1+#1*#2 } - \int_eval:n { (1+#1)*#2 }
}
\ExplSyntaxOff
\begin{document}
\begin{ganttchart}[vgrid,hgrid]{1}{12}
\gantttitlelist[title list options=%
{var=\y, evaluate=\y as \x%
using "\printrange{\y}{3}"
}
]{0,...,3}{3}
\end{ganttchart}
\end{document}