pgfgantt 创建一个空白页

pgfgantt 创建一个空白页

我有此使用包创建甘特图的代码pgfgantt。我有两个问题:

  1. 此代码创建两个页面(第一个是空白的)
  2. 有未翻译的单词(例如今天)

代码如下:

\documentclass{article}
%\usepackage[pdftex,active,tightpage]{preview}
%\setlength\PreviewBorder{2mm}
\usepackage[frenchb]{translator}
\usepackage[frenchb]{babel}
\usepackage{pgfgantt}
\usepackage{lscape}
\definecolor{barblue}{RGB}{153,204,254}
\definecolor{groupblue}{RGB}{51,102,254}
\definecolor{linkred}{RGB}{165,0,33}
\sffamily
\begin{document}
\begin{landscape}
\begin{tikzpicture} % optional
   \begin{ganttchart}[x unit=2mm, 
                      y unit chart=1cm, 
                      time slot format=isodate, 
                      %compress calendar,
                      vgrid=*{5}{dotted},
                      today=2014-04-27,
                      newline shortcut=true,
                      title/.append style={fill=blue!20, drop shadow},
                      title label font=\sffamily\bfseries\color{white},
                      title label node/.append style={below=-1.6ex},
                      title left shift=.05,
                      title right shift=-.05,
                      title height=1,
                      bar/.append style={draw=none, fill=black!63},
                      bar label node/.append style={align=center, font=\tiny},
                      bar incomplete/.append style={fill=barblue},
                      bar height=.4,
                      bar label font=\normalsize\color{black!50},
                      link/.style={-latex, draw=red, fill=red},
                     ]
                      {2014-04-14}{2014-07-11}
   \gantttitlecalendar{month=name} \\ 

    \ganttbar[progress=100]{Mise en place\ganttalignnewline de environnement\ganttalignnewline du travail}{2014-04-14}{2014-04-15} \\

    \ganttbar[progress=100]{Spécifications}{2014-04-15}{2014-04-17} \\

    \ganttbar[progress=70]{Comprendre et\ganttalignnewline analyser le\ganttalignnewline code existant}{2014-04-18}{2014-05-03} \\

    \ganttbar[progress=60]{Analyse des \ganttalignnewline besoins de la\ganttalignnewline plate-forme MEANS}{2014-04-18}{2014-05-07} \\

    \ganttbar[progress=30]{Conception des \ganttalignnewline services web}{2014-04-21}{2014-05-24} \\

    \ganttbar[progress=80]{Conception de \ganttalignnewline l'API Java}{2014-04-25}{2014-05-07} \\

    \ganttbar[progress=0]{Implémentation des\ganttalignnewline services web}{2014-05-26}{2014-06-15} \\

    \ganttbar[progress=0]{Tests des\ganttalignnewline services web}{2014-05-26}{2014-06-17} \\

    \ganttbar[progress=0]{Implémentation de\ganttalignnewline l'API Java}{2014-06-03}{2014-06-20}\\

    \ganttbar[progress=0]{Tests de\ganttalignnewline l'API Java}{2014-06-03}{2014-06-21} \\

    \ganttbar[progress=0]{Rédaction de\ganttalignnewline la documentation}{2014-06-22}{2014-06-25} \\

    %\ganttbar[]{Maintenance}{2014-06-26}{2014-07-11}

    \ganttlink[link type=f-s]{elem4}{elem6}
    \ganttlink[link type=f-s]{elem1}{elem2}
     \ganttlink[link type=s-s]{elem6}{elem7}
      \ganttlink[link type=s-s]{elem8}{elem9}


   \end{ganttchart}
\end{tikzpicture}
\end{landscape}

\end{document} 

我是新来的pgfgantt,我会很感激任何建议。

答案1

处理文档时,您会收到两个警告:

Overfull \hbox (39.01761pt too wide) in paragraph at lines 73--74
[][]

Overfull \vbox (39.19604pt too high) has occurred while \output is active

这表明您的图表对于当前页面布局来说太大;具体来说,由于它太高,因此会移至第二页。防止这种情况的一种方法是稍微更改 xunit 和 y unit 图表的值。我发现使用

x unit=1.8mm, 
y unit chart=0.87cm,

解决了问题。

还有第三个警告,与讨论的问题无关,关于不使用OT1字体编码frenchlb;您需要切换到 Cork 编码

\usepackage[T1]{fontenc}

我猜你没有将其包含在你的 MWE 中,因为它对于所讨论的问题并不重要。

关于“TODAY”的问题,用于键的字符串today由键控制today label(默认值=TODAY),因此您可以使用today labeland/ortoday label font键来获得具有所需格式的所需字符串;在我的示例代码中我使用了

today label=aujourd'hui,
today label font=\scshape,

您还必须使用此代码更改链接标签的文本:

\setganttlinklabel{s-s}{Début \`a d\'ebut (DD)}
\setganttlinklabel{f-s}{Fin \`a d\'ebut (FD)}

并将此代码添加到ganttchart选项中:

progress label text = {\pgfmathprintnumber[precision=0, verbatim]{#1}\% fait}

您可以根据需要更改这些设置。

完整代码:

\documentclass{article}
%\usepackage[pdftex,active,tightpage]{preview}
%\setlength\PreviewBorder{2mm}
\usepackage[frenchb]{translator}
\usepackage[frenchb]{babel}
\usepackage{pgfgantt}
\usetikzlibrary{shadows}
\usepackage{lscape}
\definecolor{barblue}{RGB}{153,204,254}
\definecolor{groupblue}{RGB}{51,102,254}
\definecolor{linkred}{RGB}{165,0,33}
\sffamily

\setganttlinklabel{s-s}{Début \`a d\'ebut (DD)}
\setganttlinklabel{f-s}{Fin \`a d\'ebut (FD)}

\begin{document}
\begin{landscape}
\begin{tikzpicture} % optional
   \begin{ganttchart}[x unit=1.8mm, 
                      y unit chart=0.87cm, 
                      time slot format=isodate, 
                      %compress calendar,
                      vgrid=*{5}{dotted},
                      today=2014-04-27,
                      today label=aujourd'hui,
                      today label font=\scshape,
                      newline shortcut=true,
                      title/.append style={fill=blue!20, drop shadow},
                      title label font=\sffamily\bfseries\color{white},
                      title label node/.append style={below=-1.6ex},
                      title left shift=.05,
                      title right shift=-.05,
                      title height=1,
                      bar/.append style={draw=none, fill=black!63},
                      bar label node/.append style={align=center, font=\tiny},
                      bar incomplete/.append style={fill=barblue},
                      bar height=.4,
                      bar label font=\normalsize\color{black!50},
                      link/.style={-latex, draw=red, fill=red},
                      progress label text = {\pgfmathprintnumber[precision=0, verbatim]{#1}\% fait},
                     ]
                      {2014-04-14}{2014-07-11}
   \gantttitlecalendar{month=name} \\ 

    \ganttbar[progress=100]{Mise en place\ganttalignnewline de environnement\ganttalignnewline du travail}{2014-04-14}{2014-04-15} \\

    \ganttbar[progress=100]{Spécifications}{2014-04-15}{2014-04-17} \\

    \ganttbar[progress=70]{Comprendre et\ganttalignnewline analyser le\ganttalignnewline code existant}{2014-04-18}{2014-05-03} \\

    \ganttbar[progress=60]{Analyse des \ganttalignnewline besoins de la\ganttalignnewline plate-forme MEANS}{2014-04-18}{2014-05-07} \\

    \ganttbar[progress=30]{Conception des \ganttalignnewline services web}{2014-04-21}{2014-05-24} \\

    \ganttbar[progress=80]{Conception de \ganttalignnewline l'API Java}{2014-04-25}{2014-05-07} \\

    \ganttbar[progress=0]{Implémentation des\ganttalignnewline services web}{2014-05-26}{2014-06-15} \\

    \ganttbar[progress=0]{Tests des\ganttalignnewline services web}{2014-05-26}{2014-06-17} \\

    \ganttbar[progress=0]{Implémentation de\ganttalignnewline l'API Java}{2014-06-03}{2014-06-20}\\

    \ganttbar[progress=0]{Tests de\ganttalignnewline l'API Java}{2014-06-03}{2014-06-21} \\

    \ganttbar[progress=0]{Rédaction de\ganttalignnewline la documentation}{2014-06-22}{2014-06-25} \\

    %\ganttbar[]{Maintenance}{2014-06-26}{2014-07-11}

    \ganttlink[link type=f-s]{elem4}{elem6}
    \ganttlink[link type=f-s]{elem1}{elem2}
     \ganttlink[link type=s-s]{elem6}{elem7}
      \ganttlink[link type=s-s]{elem8}{elem9}


   \end{ganttchart}
\end{tikzpicture}
\end{landscape}

\end{document}

输出:

在此处输入图片描述

相关内容