我正在尝试使用 pgfgantt 在我的 tex 文档中包含甘特图。当我使用包 pgfplots 时,我收到以下错误:
! 软件包 pgf 错误:抱歉,请求的图层“background”不属于图层列表。请确认您提供了 \pgfsetlayers,并且 background ' 属于此列表。
当我注释掉 \usepackage{pgfplots} 行时,就会生成甘特图。我需要包含它的原因是我使用 matlab2tikz 包来绘制图形,而这需要 pgfplots 包。
重现错误的代码:
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{pgfgantt}
\usepackage{pdflscape}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\newpage
\begin{landscape}
\label{section:gantt}
\begin{ganttchart}[y unit title=0.5cm,
y unit chart=0.5cm,
x unit=0.22cm,
progress=today,
today=24,
today rule/.style={Black, thick},
vgrid={draw=none, dotted},
hgrid,
link/.append style={thick},
title label anchor/.style={below=-1.6ex},
title height=1,
bar/.style={fill=OliveGreen},
bar incomplete/.append style={fill=YellowGreen},
progress label text={},
bar height=0.4
]{1}{84}
\gantttitle{Project Timeline}{84} \\
\gantttitle{2014}{6}
\gantttitle{2015}{24}
\gantttitle{2016}{24}
\gantttitle{2017}{24}
\gantttitle{2018}{6} \\
\gantttitle{Q4}{6}
\gantttitle{Q1}{6}
\gantttitle{Q2}{6}
\gantttitle{Q3}{6}
\gantttitle{Q4}{6}
\gantttitle{Q1}{6}
\gantttitle{Q2}{6}
\gantttitle{Q3}{6}
\gantttitle{Q4}{6}
\gantttitle{Q1}{6}
\gantttitle{Q2}{6}
\gantttitle{Q3}{6}
\gantttitle{Q4}{6}
\gantttitle{Q1}{6} \\
%tasks
\ganttbar{Task 1} {1}{8} \\ %0
\ganttbar{Task 2} {4}{20} \\ %1
%relations
\ganttlink{elem0}{elem1}
\end{ganttchart}
\end{landscape}
\end{document}
知道为什么会发生这种情况吗?我尝试添加
\pgfdeclarelayer{background}
\pgfsetlayers{background}
到序言,尽管这可以消除错误,但甘特图不会显示任何条形图。
日志文件链接:https://www.dropbox.com/s/5zhibboktzboutv/testgantt.log?dl=0