LaTeX pgfgantt 移动栏上方的内联标签不起作用

LaTeX pgfgantt 移动栏上方的内联标签不起作用

我尝试将已经内联的标签移到栏上方,并尝试将bar inline label node /.style=northbar inline label anchor=north或添加bar inline label anchor/.styles = north到其他问题中指定的选项中。这些都没有产生预期的效果。以下是 MWE:

\documentclass[10 pt]{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                       Packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz}                       %Diagrams
\usetikzlibrary{calc, automata}         %Diagrams
\usetikzlibrary{shapes,arrows, patterns}%Diagrams
\tikzset{>=latex'}                      %Arrow head style

\usepackage{pgfplots}                   %Diagrams
\pgfplotsset{compat=1.12}

\usepackage{pgfgantt}                   %Gantt Charts

\usepackage{lscape}                     %allow certain pages to be formatted in landscape orientation
\usepackage[paper=A4,pagesize]{typearea}
\usepackage{afterpage}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                   Gantt Chart Styles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{newbarblue}{RGB}{0,153,255}

\definecolor{newYLyellow}{RGB}{234,187,0}

\definecolor{RoyalBlue}{RGB}{0,35,102}

\def\pgfcalendarweekdayletter#1{%
    \ifcase#1M\or T\or W\or T\or F\or S\or S\fi%
}

\newganttchartelement{newbar}{
                            newbar/.style={
                                shape=rounded rectangle,
                                inner sep=0pt,
                                draw=newbarblue!50!black,
                                very thick,
                                top color=white,
                                bar inline label node /.style=north, %Line which I thought would work
                                bottom color=newbarblue!50
                                },                              
                            newbar label font=\slshape,
                            newbar left shift=-.1,
                            newbar right shift=.1
                         }

\newganttchartelement{newYL}{newYL/.style=  {
                                            shape=rounded rectangle,
                                            inner sep=0pt,
                                            draw=newbarblue!50!black,
                                            very thick,
                                            top color=white,
                                            bar inline label node /.style=north,  %Line which I thought would work
                                            bottom color=newYLyellow!50
                                        },
                            newbar label font=\slshape,
                            newbar left shift=-.1,
                            newbar right shift=.1
                        }

\pgfdeclarepatternformonly{weekendstripes}{\pgfpoint{-1mm}{-1mm}}{\pgfpoint{40mm}{11mm}}{\pgfpoint{19.80mm}{10mm}}%
{
  \pgfpathmoveto{\pgfqpoint{3.4cm}{0cm}}
  \pgfpathlineto{\pgfqpoint{3.4cm}{1cm}}
  \pgfpathlineto{\pgfqpoint{4.0cm}{1cm}}
  \pgfpathlineto{\pgfqpoint{4.0cm}{0cm}}
  \pgfpathlineto{\pgfqpoint{3.4cm}{0cm}}
  \pgfusepath{fill}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                   Start of Document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}


\afterpage{% Insert after the current page
\clearpage
\KOMAoptions{paper=A3,paper=landscape,pagesize}
\recalctypearea
\newgeometry{
         top = 1in, left = 1.5in, right = 1in, bottom = 1in}

\resizebox{2.4\hsize}{!}{   
\begin{ganttchart}[canvas/.style=%
                {pattern=weekendstripes, pattern color=gray!20},
                x unit= 4mm,
                vgrid={*{6}{dotted},*{1}{black}},
                hgrid,
                inline,
                time slot format=little-endian,
                group/.append style={draw=black, fill=RoyalBlue!70},
                milestone/.append style={draw=black, fill=RoyalBlue!70},
                milestone inline label node/.append style={left=5mm}            
              ] {12-01-2015}{14-05-2015}

\gantttitlecalendar[title/.style={fill=RoyalBlue},
                title left shift=.1,
                title right shift=-.1,
                title label font=\color{white}\bfseries]        {month=shortname}\\

\gantttitlecalendar[title/.style={fill=RoyalBlue!80},
                title left shift=.1,
                title right shift=-.1,
                title label font=\color{white}\bfseries]        {week=1}\\

\gantttitlecalendar[title/.style={fill=RoyalBlue!60},
                title left shift=.05,
                title right shift=-.05,
                title label font=\color{white}\bfseries
               ]                                                {weekday=letter}\\


\ganttgroup{Group1}                             {16-02-2015}{06-03-2015} \\ 

\ganttnewbar{Task1}                             {12-01-2015}{22-01-2015} \\ 

\ganttgroup{Group1}                             {16-01-2015}{06-03-2015} \\ 
\ganttnewbar{Task2}                             {16-01-2015}{06-02-2015} \\ 
\ganttnewbar{Task3}                             {02-02-2015}{13-02-2015} \\
\ganttnewbar{Task4}                             {16-02-2015}{06-03-2015} \\ 
\ganttnewbar{Task5}                             {20-01-2015}{06-03-2015} \\ 

\ganttgroup{Group2}                             {23-03-2015}{10-04-2015}\\
\ganttnewbar{Task6}                             {23-03-2015}{10-04-2015} \\   

\ganttgroup {Group3}                            {02-03-2015}{20-03-2015} \\ 
\ganttnewbar{Task7}                             {02-03-2015}{20-03-2015} \\ 
\ganttnewYL {Task8}                             {23-03-2015}{10-04-2015} \\ 
\ganttnewYL {Task9}                             {02-03-2015}{06-03-2015} \\ 
\ganttnewYL{Task10}                             {09-03-2015}{10-04-2015} \\

\ganttnewbar{Task11}                            {13-04-2015}{24-04-2015} \\

\ganttnewbar{Task12}                            {27-04-2015}{14-05-2015} \\

\ganttnewbar{Task13}                            {12-01-2015}{14-05-2015} \\

\ganttmilestone{Milestone}                      {14-05-2015} \\

\ganttlink{elem10}{elem11}
\ganttlink{elem11}{elem14}

\ganttlink{elem16}{elem17}
\end{ganttchart}
}

\clearpage
\KOMAoptions{paper=A4,pagesize}
\recalctypearea
}
\pagebreak

\end{document}

这使:

提供的代码的输出

需要澄清的是,我希望前面提到的几行能够将标签放在条形图上方,请告诉我为什么不这样做,并就如何纠正提供建议。

答案1

我找到了解决方案。原来是我把命令放错了位置。通过将移入,bar inline label node /.style=north如下\begin{ganttchart}[options]所示:

\begin{ganttchart}[canvas/.style=%
                {pattern=weekendstripes, pattern color=gray!20},
                x unit= 2.9mm,
                y unit chart= 8mm,
                vgrid={*{6}{dotted},*{1}{black}},
                hgrid, 
                inline,
                time slot format=little-endian,
                newbar inline label node/.style={above=3pt}, %This line !!
                newYL inline label node/.style={above=3pt},  %and this one
                group/.append style={draw=black, fill=RoyalBlue!70},
                milestone/.append style={draw=black, fill=RoyalBlue!70},
                milestone inline label node/.append style={left=5mm}            
              ] {12-01-2015}{14-05-2015}

newbar 和 newYL (我知道这个名字不太好) 对应于原始问题中所示的用户设置的条形样式。

相关内容