答案1
获得此类内容的一种方法是使用pgffgantt
。不过,我不得不“破解”它。要添加时间线项目,您只需说
\ganttbar{<label>}{<start>}{<end>} \\
为了您的方便,我以一种风格存储了钥匙。
\documentclass{article}
\usepackage{pgfgantt}
\newcounter{bars}
\newcounter{cheat}
\ganttset{Monya/.style={bar label font=\color{blue!60!black}\sffamily,
canvas/.style={shape=rectangle,draw=none,alias=frame,
append after command={
foreach \X in {1,...,\number\value{bars}} {
([yshift=5pt]X\X.south-|frame.west) node{$\setcounter{cheat}{\X}\Alph{cheat}$}}}
},inline,bar top shift=0.55,bar height=0.85,
bar/.style={draw=none,/utils/exec=\stepcounter{bars},
alias=X\number\value{bars},path picture={
\draw[|-|,thick] ([yshift=3.5pt]path picture bounding box.south west)
-- ([yshift=3.5pt]path picture bounding box.south east);}}}}
\begin{document}
\setcounter{bars}{0}
\begin{ganttchart}[Monya]{-2}{14}
\ganttbar{delete(1)}{0}{4} \\
\ganttbar{getOrElseUpdate(1,0):3}{1}{3} \\
\ganttbar{update(1,2)}{2}{8} \\
\ganttbar{getOrElseUpdate(1,0)}{3.5}{7} \\
\ganttbar{getOrElse(1,-1):2}{4.5}{6} \\
\ganttbar{getOrElse(1,-1):0}{10}{12} \\
\end{ganttchart}
\end{document}