![\includepdf 的 addtotoc 中多行 \pbox 的目录对齐问题](https://linux22.com/image/313528/%5Cincludepdf%20%E7%9A%84%20addtotoc%20%E4%B8%AD%E5%A4%9A%E8%A1%8C%20%5Cpbox%20%E7%9A%84%E7%9B%AE%E5%BD%95%E5%AF%B9%E9%BD%90%E9%97%AE%E9%A2%98.png)
我正在插入许多 1 页的 PDF,并将其包含在目录中。
我遇到的唯一问题是我的条目与 PDF # 的目录计数器及其对应的页码的对齐问题。它们位于我在 中使用的多行的\pbox
中心。\includepdf
addtotoc
下面的代码说明了我的问题,我需要多行条目的页码和计数器与第一行对齐(如单行条目所示)。
\documentclass[12pt, a4paper]{article}
\usepackage[margin = 1in]{geometry}
\usepackage{pdfpages}
\usepackage{pbox}
\begin{document}
\tableofcontents
\includepdf[pagecommand={\thispagestyle{plain}}, addtotoc={1,subsubsection,3,\pbox{20cm}{\textbf{Abstract Author}, One line title with no alignment issues},chap:samplepdf1}]{}
\includepdf[pagecommand={\thispagestyle{plain}}, addtotoc={1,subsubsection,3,\pbox{20cm}{\textbf{Abstract Author}, Two line title with alignment issues\\ Two line title with alignment issues},chap:samplepdf2}]{}
\includepdf[pagecommand={\thispagestyle{plain}}, addtotoc={1,subsubsection,3,\pbox{20cm}{\textbf{Abstract Author}, Three line title with alignment issues\\ Three line title with alignment issues \\ Three line title with alignment issues},chap:samplepdf3}]{}
\end{document}
也许有某种方法可以插入多个换行符?也许软件包仍然有缺陷,并且没有已知的修复方法?宁愿不要从头开始!
任何帮助深表感谢。
答案1
我更喜欢varwidth
。pbox
顶部对齐的框是必要的,当框包含多行时,需要对多余的深度进行一些补偿。
\documentclass[12pt, a4paper]{article}
\usepackage[margin = 1in]{geometry}
\usepackage{pdfpages}
\usepackage{varwidth}
\DeclareRobustCommand{\vw}[1]{%
\begin{varwidth}[t]{\textwidth}\strut#1\unskip\nobreak\strut\par
\end{varwidth}%
}
\begin{document}
\begingroup\setlength\lineskip{0pt}
\tableofcontents
\endgroup
\includepdf[
pagecommand={\thispagestyle{plain}},
addtotoc={
1,
subsubsection,
3,
\vw{\textbf{Abstract Author}, One line title with no alignment issues},
chap:samplepdf1
}
]{pyk}
\includepdf[
pagecommand={\thispagestyle{plain}},
addtotoc={
1,
subsubsection,
3,
\vw{\textbf{Abstract Author}, Two line title with alignment issues\\
Two line title with alignment issues},
chap:samplepdf2}
]{pyk}
\includepdf[
pagecommand={\thispagestyle{plain}},
addtotoc={
1,
subsubsection,
3,
\vw{\textbf{Abstract Author}, Three line title with alignment issues\\
Three line title with alignment issues \\
Three line title with alignment issues},
chap:samplepdf3
}
]{pyk}
\end{document}