甘特图 - 将描述的宽度设置为在各个图表中相同

甘特图 - 将描述的宽度设置为在各个图表中相同

您好,感谢您花时间阅读我的问题。

我有一个 \pgfgantt 图表,由于它太长,我需要将其拆分成几个(我使用的是昨天安装的最新版本的 \pgfgantt)。我想按边框对齐图表;我认为插入“虚拟文本”也许可行,但我不知道该怎么做。您有什么建议吗?如果代码中有什么让您感到困惑(除了 August 独自闲逛一天),请告诉我,我还在不断学习。在此处输入图片描述

再次感谢。

\documentclass[12pt, a4paper]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{pgfgantt}
    \usepackage{lscape}

\begin{document}
    \begin{landscape}   
        \centering

        %%%%%%%%%%%%%%%%            Gantt 1             %%%%%%%%%%%%%%%
        \begin{ganttchart}%
            [time slot format = {isodate},% Specify the date format (yyyy-mm-dd)
            x unit = 2.1 mm,
            y unit title = 10 mm,
            y unit chart = 4 mm
            ]%
            {2021-03-01}% Specify start date
            {2021-05-16} % Specify end date 1
            \gantttitlecalendar{month=name, week}%\\
            \ganttnewline
            \ganttbar{Something quite long that's going on}{2021-03-08}{2021-03-14}\\
            \ganttnewline
            \ganttmilestone{Do another relatively wordy thing}{2021-03-08}\\
        \end{ganttchart}
    
        \vfill
        
        %%%%%%%%%%%%%%%%            Gantt 2             %%%%%%%%%%%%%%%
        \begin{ganttchart}%
            [time slot format = {isodate},% Specify the date format (yyyy-mm-dd)
            x unit = 2.1 mm,
            y unit title = 10 mm,
            y unit chart = 4 mm
            ]%
            {2021-05-17}% Specify start date
            %       {2021-05-16} % Specify end date 1
            {2021-08-01} % End date 2
            %   {2021-11-26}% Specify end date
            \gantttitlecalendar{month=name, week}%\\
            \ganttnewline
            \ganttbar{Thing 3}  {2021-05-17}{2021-07-11}
        \end{ganttchart}
    
    \end{landscape}
\end{document}

答案1

  • 替代解决方案。
  • 使用\makebox标签的有效宽度为零!
  • 我添加了showframe显示页面边框。
  • 如果您设法缩小图表范围,那么它可能会看起来不错。

\documentclass{article} 
\usepackage{pgfgantt}
\usepackage{showframe}

\begin{document}

% http://www-hermes.desy.de/latex/ltx-262.html
% \makebox[width][position]{text}

\begin{figure}
\centering
% Chart 1
    \begin{ganttchart}%
        [time slot format = {isodate},
        x unit = 1.8mm,
        y unit title = 10mm,
        y unit chart = 4mm
        ]%
        {2021-03-01}
        {2021-05-16}
        \gantttitlecalendar{month=name, week}%\\
        \ganttnewline
        \ganttbar{\makebox[0mm][r]{text text}}{2021-03-08}{2021-03-14}\\
        \ganttnewline
        \ganttmilestone{\makebox[0mm][r]{text}}{2021-03-08}\\
    \end{ganttchart}\\
% Chart 2
    \begin{ganttchart}%
        [time slot format = {isodate},
        x unit = 1.8mm,
        y unit title = 10mm,
        y unit chart = 4mm
        ]%
        {2021-05-17}
        {2021-08-01}
        \gantttitlecalendar{month=name, week}%\\
        \ganttnewline
        \ganttbar{\makebox[0mm][r]{text text text}}{2021-05-17}{2021-07-11}
    \end{ganttchart}
\caption{Caption}
\end{figure}

\end{document}

在此处输入图片描述

答案2


\documentclass{article} 
\usepackage{pgfgantt}
\usepackage{rotating}

\newsavebox{\myLargestImage}

% https://tex.stackexchange.com/questions/204299
% https://tex.stackexchange.com/questions/106353
% https://tex.stackexchange.com/questions/239128
% https://tex.stackexchange.com/questions/122314

\begin{document}

\begin{figure}
\centering
    % Step 1
    \savebox{\myLargestImage}{%
    \begin{rotate}{90}
    \begin{ganttchart}%
        [time slot format = {isodate},
        x unit = 2.1 mm,
        y unit title = 10 mm,
        y unit chart = 4 mm
        ]%
        {2021-03-01}
        {2021-05-16}
        \gantttitlecalendar{month=name, week}%\\
        \ganttnewline
        \ganttbar{Something quite long that's going on}{2021-03-08}{2021-03-14}\\
        \ganttnewline
        \ganttmilestone{Do another relatively wordy thing}{2021-03-08}\\
    \end{ganttchart}
    \end{rotate}
    }
    % Step 2
    \usebox{\myLargestImage}
\hspace{25mm}
\raisebox{\dimexpr\ht\myLargestImage-\height}{%
    %
    \begin{rotate}{90}
    \begin{ganttchart}%
        [time slot format = {isodate},
        x unit = 2.1 mm,
        y unit title = 10 mm,
        y unit chart = 4 mm
        ]%
        {2021-05-17}
        {2021-08-01}
        \gantttitlecalendar{month=name, week}%\\
        \ganttnewline
        \ganttbar{Thing 3}  {2021-05-17}{2021-07-11}
    \end{ganttchart}
    \end{rotate}
    %
    }
\caption{Caption}
\end{figure}

\end{document}

相关内容