\includepdf 的 addtotoc 中多行 \pbox 的目录对齐问题

\includepdf 的 addtotoc 中多行 \pbox 的目录对齐问题

我正在插入许多 1 页的 PDF,并将其包含在目录中。

我遇到的唯一问题是我的条目与 PDF # 的目录计数器及其对应的页码的对齐问题。它们位于我在 中使用的多行的\pbox中心。\includepdfaddtotoc

在此处输入图片描述 下面的代码说明了我的问题,我需要多行条目的页码和计数器与第一行对齐(如单行条目所示)。

\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

我更喜欢varwidthpbox顶部对齐的框是必要的,当框包含多行时,需要对多余的深度进行一些补偿。

\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}

在此处输入图片描述

相关内容