タイトルページの PDF に含まれるファイルのリスト

タイトルページの PDF に含まれるファイルのリスト

で定義されている PDF に含めたファイルの (項目別) リストを取得したいと思います\includeonly{}

私のアプローチはまったく機能していません。インクルードされたファイルごとに多くの手作業が必要であり、環境missing \itemにがあり、各ファイルでが常に に設定されるitemizeため、方法論的に正しくありません。インクルードされているかどうかは関係ありません。boolstrue

これが私の MWE です:

\documentclass{scrbook}
\usepackage{filecontents,etoolbox}
\newbool{chapter01}
\newbool{chapter02}
\newbool{chapter03}

\usepackage{blindtext}

\begin{filecontents}{chapter01.tex}
    \chapter{This is chapter 01}
    \booltrue{chapter01}
    \blindtext[3]
\end{filecontents}
\begin{filecontents}{chapter02.tex}
    \chapter{This is chapter 02}
    \booltrue{chapter02}
    \blindtext[3]
\end{filecontents}
\begin{filecontents}{chapter03.tex}
    \chapter{This is chapter 03}
    \booltrue{chapter03}
    \blindtext[3]
\end{filecontents}

\includeonly{%
 chapter01,
% chapter02,
 chapter03
}
\begin{document}
\begin{titlepage}
    This PDF contains:
    \begin{itemize}
     \ifbool{chapter01}{\item Chapter 01}{}
     \ifbool{chapter02}{\item Chapter 02}{}
     \ifbool{chapter03}{\item Chapter 03}{}
    \end{itemize}
\end{titlepage}
\include{chapter01}
\include{chapter02}
\include{chapter03}
\end{document}

答え1

マクロ\includeonlyは、 というファイルのコンマ区切りリストを作成します\@partlist。したがって、必要なのは、そのリストを処理して好きなように出力するためのマクロを作成することだけです。リストの順序は、コマンド内の順序とまったく同じになります。\includeonlyリストを並べ替えるには、さらにオーバーヘッドが必要になります。

以下に例を示します (ファイル名のアンダースコアを処理するように更新されています)。

\documentclass{report}
\begin{filecontents}{\jobname_1.tex}
\chapter{First Chapter}
\end{filecontents}
\begin{filecontents}{\jobname_2.tex}
\chapter{Second Chapter}
\end{filecontents}
\begin{filecontents}{\jobname_3.tex}
\chapter{Third Chapter}
\end{filecontents}
\includeonly{\jobname_1, \jobname_2}
\usepackage{titling}
\usepackage{etoolbox}
\usepackage{url}
\DeclareUrlCommand{\filename}{\urlstyle{rm}}
\makeatletter
\newcommand{\listincluded}{%
\begin{enumerate}
\renewcommand*{\do}[1]{\item \filename{##1.tex}}
\expandafter\docsvlist\expandafter{\@partlist}
\end{enumerate}
}
\makeatother
\renewcommand{\maketitlehookd}{%
\begin{center}
\bfseries List of Included Files
\end{center}
\listincluded
}
\title{A title}
\author{An author}
\date{}

\begin{document}
\maketitle
\tableofcontents
\include{\jobname1}
\include{\jobname2}
\include{\jobname3}


\end{document}

コードの出力

関連情報