제목 페이지의 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}

코드 출력

관련 정보