pgfgantt:为什么右边的图比 \textwidth 短?

pgfgantt:为什么右边的图比 \textwidth 短?

我不是 Latex 专业人士,试图让下面的图表正好是\textwidth宽的,但不知何故它显示得比右侧的文本短。我不明白为什么它expand chart=\textwidth不能像我预期的那样工作。有人能帮忙吗?

谢谢。

编辑:添加了\usepackage{showframe}\fbox{两次编译后我的输出的图片。

这是代码:

\documentclass[11pt,a4paper,fleqn]{article}
\usepackage{lipsum}
\usepackage{pgfgantt}
\usepackage{geometry}
\usepackage{showframe} %Edit: added

\newgeometry{vmargin={15mm}, hmargin={20mm,20mm}}   % set the margins

\begin{document}
    \lipsum[1]
        \begin{figure*}[!htb]
            \centering%
            \fbox{ %Edit: added
            \begin{ganttchart}[%
                y unit chart=.7cm,%
                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,%
                include title in canvas=false,%
                bar height=0.3,%
                bar label font=\mdseries\footnotesize\color{black!70},%
                bar label node/.append style={left=0.2cm},%
                bar/.append style={draw=none, fill=cyan},%
                group height=0.3,%
                group label node/.append style={left=0.2cm},%
                group label font=\bfseries\small\color{black},%
                group/.append style={draw=none, fill=blue},%
                expand chart=\textwidth,%
                ]{1}{28}%
                \gantttitle[title label node/.append style={below left=7pt and 10pt}]{KW}{1}%
                \gantttitlelist[title label node/.append style={below left=7pt and 10pt}]{9,...,37}{1} \\%
                \ganttgroup{\textbf{WP1:} Activity A}{1}{5} \\%
                \ganttbar{Activity A11}{1}{3} \\%
                \ganttbar{Activity A12}{2}{5} \\%
                \ganttmilestone{Milestone}{20} \ganttnewline[grid]%
                \ganttgroup{\textbf{WP4:} Activity D}{18}{22} \\%
                \ganttbar{Activity A41}{18}{20} \\%
            \end{ganttchart}%
        }%Edit: added
        \caption{Time schedule.}%
        \end{figure*}
    
    \lipsum[2]
\end{document}

这是我在 ganttchart 环境中使用 \showframe 和 \fbox 得到的:

上述代码生成的文档

相关内容