让我们看一下文档中的一个甘特图示例:
\documentclass{standalone}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[vgrid, hgrid, inline]{12}
\gantttitle{Title}{12} \\
\ganttbar{Task 1}{1}{3}
\ganttbar[bar label inline anchor/.style=above]{Task 2}{5}{10} \\
\ganttbar[bar label shape anchor=left,%
bar label inline anchor/.style=right]{Task 3}{2}{7}
\ganttbar[inline=false]{Final task}{11}{12}
\end{ganttchart}
\end{document}
看起来像这样:
我怎样才能将任务 2 的标签稍微上移一点?
答案1
根据手册中列出的命令——pgfgantt Package Wolfgang Skala,v4.0,2013/06/01,第 25 页。有两个用于标签位置的命令。
bar inline label anchor =<anchor> --- east, west, north, south
bar inline label node/.style=<options> --- above, below, right, left, or = xxpt
x 条标签形状锚点=左,——这会导致最新版本出现错误。
代码
\documentclass[border=10pt]{standalone}
\usepackage{pgfgantt}
%\usetikzlibrary{positioning}
\begin{document}
\begin{ganttchart}[vgrid, hgrid, inline,]{1}{12}
\gantttitle{2014}{12} \\
\ganttbar{Task 1}{1}{3}
\ganttbar[bar inline label node/.style={above=3pt}, %< -- adjust the 3pt
]{Task 2}{5}{10} \\
\ganttbar[
bar inline label node/.style={left}]{Task 3}{2}{7}
\ganttbar[inline=false]{Final task}{11}{12}
\end{ganttchart}
\end{document}