Я хотел бы получить (подробный) список файлов, которые я включил в PDF-файл, который определен в \includeonly{}
.
Мой подход вообще не работает, так как для каждого включаемого файла требуется много ручной работы, missing \item
в itemize
среде есть и это методологически неверно, так как bools
всегда установлено true
в каждом файле; неважно, включен он или нет.
Вот мой 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}