Lista de archivos incluidos en el pdf en la portada.

Lista de archivos incluidos en el pdf en la portada.

Me gustaría tener una lista (detallada) de los archivos que he incluido en el pdf que está definido en \includeonly{}.

Mi enfoque no funciona en absoluto, ya que se necesita mucho trabajo manual para cada archivo incluido, hay un missing \itemen el itemizeentorno y es metodológicamente incorrecto ya que boolssiempre están configurados trueen cada archivo; no importa si está incluido o no.

Aquí está mi 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}

Respuesta1

La \includeonlymacro crea una lista separada por comas de los archivos llamados \@partlist. Entonces, todo lo que tenemos que hacer es crear una macro para procesar esa lista y generarla de la forma que desee. El orden de la lista será exactamente el mismo orden que el del \includeonlycomando. Ordenar la lista requeriría más gastos generales.

Aquí hay un ejemplo (actualizado para abordar los guiones bajos en los nombres de archivos).

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

salida de código

información relacionada