我对甘特图中出现的额外空白水平网格线感到有些问题。这是代码:
\documentclass[a4paper, 11pt]{article}
\usepackage{pgfgantt}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{enumerate}
\usepackage{eurosym}
\usepackage[hidelinks, hyperfootnotes=false]{hyperref}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{fancyhdr}
%\usepackage{pagecounting}
\usepackage{float}
\usepackage{ifoddpage}
\usepackage[inner=25mm, outer=25mm, bottom=25mm, top=25mm]{geometry}
\usepackage{lastpage}
\usepackage{scrextend}
\usepackage{csquotes}
\usepackage[style=verbose-note,firstinits=true,doi=false, eprint=false, sorting=none, maxbibnames=99, maxcitenames=99]{biblatex}
\begin{document}
\begin{figure}[h]
%\hspace*{-20px}
\begin{ganttchart}[vgrid={*1{black}},hgrid={*1{black}}, x unit=0.6cm, y unit chart=0.5cm, bar top shift = -0.295mm,bar label node/.append style={align=left}]{1}{24}
{\fontsize{8}{10}\selectfont
\gantttitlelist{1,...,24}{1}\\
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{1}{1}{4}\\
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{2}{5}{5}\\
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{2}{6}{8}\\
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{4}{9}{10}
}
\end{ganttchart}
\end{figure}
\end{document}
这是我得到的输出:
我怎样才能删除底部多余的空白水平网格线?非常感谢您的帮助。
答案1
您“创建”了它,并通过 转移后看到了它bar top shift = -0.295mm,
。
为了看到它,我做了以下事情:
- 删除了这里不需要的所有包
- 将条形图作为宏(简写符号)进行比较
- (
%
最后的避免在“执行”时插入不需要的空格) - 注释掉你的甘特图选项,直到找到问题根源
- (为此我逐行放置它们以便
%
根据需要删除 - 显示没有和有的结果
bar top shift = -0.295mm,
\documentclass[a4paper, 11pt]{article}
\usepackage{pgfgantt}
% removed packages, which are not needed here
\newcommand\bars[0]{% for short-hand notation
{%
\fontsize{8}{10}%
\selectfont%
\gantttitlelist{1,...,24}{1}\\%
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{1}{1}{4}\\%
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{2}{5}{5}\\%
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{2}{6}{8}\\%
\ganttbar[bar height=0.24mm,bar/.append style={fill=gray!20}]{4}{9}{10}%
}%
}
\begin{document}
% without bar top shift
\begin{figure}[h]
%\hspace*{-20px}
\begin{ganttchart}[
vgrid={*1{black}},
hgrid={*1{black}},
x unit=0.6cm,
y unit chart=0.5cm,
% bar top shift = -0.295mm,% <<< without
bar label node/.append style={align=left}
]
{1}
{24}
\bars{}
\end{ganttchart}
\end{figure}
% with
\begin{figure}[h]
%\hspace*{-20px}
\begin{ganttchart}[
vgrid={*1{black}},
hgrid={*1{black}},
x unit=0.6cm,
y unit chart=0.5cm,
bar top shift = -0.295mm,% <<< with
bar label node/.append style={align=left}
]
{1}
{24}
\bars{}
\end{ganttchart}
\end{figure}
\end{document}