如何减少甘特图中的垂直空间?

如何减少甘特图中的垂直空间?

如何减少所有标签之间的垂直间距?

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{eurosym}
\usepackage{lastpage}
\usepackage{xspace}
\usepackage[margin=15mm,includehead,includefoot]{geometry}
\usepackage{fancyhdr}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{array}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{csquotes}
\usepackage{pgfgantt}
\usepackage[nohyperlinks,nolist]{acronym}
\usepackage[stable]{footmisc}
\begin{document}
\begin{figure}[!htbp]
\begin{center}

\begin{ganttchart}[
canvas/.append style={fill=none, draw=black!5, line width=.75pt},
hgrid style/.style={draw=black!5, line width=.75pt},
vgrid={*1{draw=black!5, line width=.75pt}},
title/.style={draw=none, fill=none},
title label font=\bfseries\footnotesize,
title label node/.append style={below=7pt},
include title in canvas=false,
bar label font=\small\color{black!70},
bar label node/.append style={left=2cm},
bar/.append style={draw=none, fill=black!63},
bar progress label font=\footnotesize\color{black!70},
group left shift=0,
group right shift=0,
group height=.5,
group peaks tip position=0,
group label node/.append style={left=.6cm},
group progress label font=\bfseries\small
  ]{1}{24}
  \gantttitle[
    title label node/.append style={below left=7pt and -3pt}
  ]{Month:\quad1}{1}
  \gantttitlelist{2,...,24}{1} \\
  \ganttgroup{Work Package}{1}{24} \\
  \ganttgroup{Deliverable}{24}{24} \\
  \ganttgroup{Milestone}{5}{5} \\
  \ganttgroup{Secondment}{20}{23} \\
  \ganttgroup{Short stay}{16}{16} \\
  \ganttgroup{Training}{5}{5} \\
  \ganttgroup{Dissemination}{23}{24} \\
  \ganttgroup{Communication}{12}{12} \\
  \ganttgroup{Other}{18}{21}
 \end{ganttchart}

\end{center}
\caption{Example Gantt Chart}
\end{figure}

\end{document}

使用y unit chart=0.5cm,没有太大帮助。

在此处输入图片描述

答案1

添加 y unit chart= <dimension>在此处输入图片描述

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{eurosym}
\usepackage{lastpage}
\usepackage{xspace}
\usepackage[margin=15mm,includehead,includefoot]{geometry}
\usepackage{fancyhdr}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{array}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{csquotes}
\usepackage{pgfgantt}
\usepackage[nohyperlinks,nolist]{acronym}
\usepackage[stable]{footmisc}
\begin{document}
    \begin{figure}[!htbp]
        \begin{center}
            
            \begin{ganttchart}[
                y unit chart=0.5cm, % added <<<<<<<<<<<<<<<<<
                canvas/.append style={fill=none, draw=black!5, line width=.75pt},
                hgrid style/.style={draw=black!5, line width=.75pt},
                vgrid={*1{draw=black!5, line width=.75pt}},
                title/.style={draw=none, fill=none},
                title label font=\bfseries\footnotesize,
                title label node/.append style={below=7pt},
                include title in canvas=false,
                bar label font=\small\color{black!70},
                bar label node/.append style={left=2cm},
                bar/.append style={draw=none, fill=black!63},
                bar progress label font=\footnotesize\color{black!70},
                group left shift=0,
                group right shift=0,            
                group height=.5,
                group peaks tip position=0,
                group label node/.append style={left=.6cm},
                group progress label font=\bfseries\small
                ]{1}{24}
                \gantttitle[
                title label node/.append style={below left=7pt and -3pt}
                ]{Month:\quad1}{1}
                \gantttitlelist{2,...,24}{1} \\
                \ganttgroup{Work Package}{1}{24} \\
                \ganttgroup{Deliverable}{24}{24} \\
                \ganttgroup{Milestone}{5}{5} \\
                \ganttgroup{Secondment}{20}{23} \\
                \ganttgroup{Short stay}{16}{16} \\
                \ganttgroup{Training}{5}{5} \\
                \ganttgroup{Dissemination}{23}{24} \\
                \ganttgroup{Communication}{12}{12} \\
                \ganttgroup{Other}{18}{21}
            \end{ganttchart}
            
        \end{center}
        \caption{Example Gantt Chart}
    \end{figure}    
    
\end{document}

为了节省一些墨水使用group height=.08,

更新

还添加了两个\ganttmilestone。我认为重新缩放没有任何问题。

黑线之间的间隔将受到组标签字体大小的限制。

G

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{eurosym}
\usepackage{lastpage}
\usepackage{xspace}
\usepackage[margin=15mm,includehead,includefoot]{geometry}
\usepackage{fancyhdr}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{array}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{csquotes}
\usepackage{pgfgantt}
\usepackage[nohyperlinks,nolist]{acronym}
\usepackage[stable]{footmisc}
\begin{document}
    \begin{figure}[!htbp]
        \begin{center}
            
            \begin{ganttchart}[
                y unit chart=0.4cm, % added <<<<<<<<<<<<<<<<<
                y unit title=1.2cm,
                vgrid,
                hgrid,
                canvas/.append style={fill=none, draw=black!5, line width=.75pt},
                hgrid style/.style={draw=black!5, line width=.75pt},
                vgrid={*1{draw=black!5, line width=.75pt}},
                title/.style={draw=none, fill=none},
                title label font=\bfseries\footnotesize,
                title label node/.append style={below=7pt},
                include title in canvas=false,
                bar label font=\small\color{black!70},
                bar label node/.append style={left=0cm},
                bar/.append style={draw=none, fill=black!63},
                bar progress label font=\footnotesize\color{black!70},
                group label node/.append style={anchor=east},
                group label font = \bfseries\footnotesize\color{black!70},
                milestone label font = \footnotesize\itshape,
                milestone label node/.append style={anchor=east},
                milestone height= 0.8,  %   
                group left shift=0,
                group right shift=0,            
                group height=.08,
                group label text={\footnotesize\raisebox{-2.6ex}{\smash{\strut#1}}}, %vertical correction
                group peaks tip position=0,
                group peaks height=.35,
                group peaks width = .15,
                group label node/.append style={left=.2cm},
                group progress label font=\bfseries\small
                ]{1}{24}
                \gantttitle[
                title label node/.append style={below left=7pt and -3pt}
                ]{Month:\quad1}{1}
                \gantttitlelist{2,...,24}{1} \\
                \ganttgroup{Work Package}{1}{24} \\
                \ganttgroup{Deliverable}{24}{24} \\
                \ganttgroup{Milestone}{5}{5} \\
                \ganttmilestone{Milestone 1}{16}\\
                \ganttgroup{Secondment}{20}{23} \\
                \ganttgroup{Short stay}{16}{16} \\
                \ganttgroup{Training}{5}{5} \\
                \ganttgroup{Dissemination}{23}{24} \\
                \ganttgroup{Communication}{12}{12} \\
                \ganttgroup{Other}{18}{21}\\
                \ganttmilestone{Milestone 2}{21}
            \end{ganttchart}                
        \end{center}
        \caption{Example Gantt Chart}
    \end{figure}   

\end{document}

相关内容