答案1
一个简单的tikzpicture
(不是真正的甘特图):
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
node distance = 0pt,
G/.style = {draw, fill=gray!30, text width=2*#1mm, align=center,
inner xsep=0pt, outer sep=0pt,
anchor=south west},
tck/.style = {font=\scriptsize, below}
]
\foreach \n/\i [remember=\i as \j (initialy 0),
evaluate=\i as \k using \i-\j] in {P_4/3, P_1/9, P_3/16, P_2/24}
{
\node[G=\k] at (\j/5,0) {$\n$};
\node[tck] at (\i/5,0) {\i};
\ifnum\j=0
\node[tck] at (0,0) {\j};
\fi
}
\end{tikzpicture}
\end{document}