您好,感谢您花时间阅读我的问题。
我有一个 \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
- 我愿意不是有一个解决方案:也许其他人可以在其基础上进行构建。
- 我尝试合并以下帖子。
- 子字幕垂直对齐
- 旋转甘特图
- 副标题:两个垂直尺寸不同的图像的垂直对齐
- 图:使用 subfig 或 subfigure 有什么区别
- 但我没有成功。似乎 LaTeX 系统无法识别甘特图的大小。
\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}