我正在使用这个包pdf页面我在使用 addtolist 时遇到了麻烦。我测试了表格和 lstlisting(成功了),但出于奇怪的原因,它无法与图形一起使用:
分数维:
\documentclass[a4paper,12pt]{report}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage[toc,page]{appendix}
\usepackage[compact]{titlesec}
\usepackage{titletoc}
\usepackage{hyperref}% Just in case....
\providecommand{\phantomsection}{}
\makeatletter
\newcommand{\appendixlistingname}{Appendix Listings}
\newcommand{\listofappendixlistings}{%
% Applying the same trick as listings does with \lstlistoflistings: Modifying \@starttoc such that it can load only .apl files
\begingroup
\let\@starttoc@orig\@starttoc%
\renewcommand{\contentsname}{\appendixlistingname}
\renewcommand{\@starttoc}[1]{%
\@starttoc@orig{apl}%
}%
\phantomsection
\addcontentsline{toc}{section}{\appendixlistingname}
\tableofcontents% Calling \tableofcontents with the `.apl` file instead of `.toc`
\endgroup
}
\newcommand{\appendixFix}{%
\setcounter{lstlisting}{0}%
\@ifundefined{theHlstlisting}{%
}{%
\renewcommand{\theHlstlisting}{appendix}
}%
\write\@auxout{%
\string\let\string\latex@tf@lol\string\tf@lol% Store the original `\tf@lol` file handle
\string\let\string\tf@lol\string\tf@apl%
}%
}{}{}
\makeatother
\begin{document}
% Start partial lists
\startlist[appendices]{lof}% starts appendices list of figures
\startlist[appendices]{lot}% starts appendices list of tables
% renaming later
\newcommand\listfigurenameappendixes{\listfigurename}
\newcommand\listtablenameappendixes{\listtablename}
\appendixFix
\begin{appendices}
\begingroup
\let\clearpage\relax
% prints appendices list of figures
\printlist[appendices]{lof}{}{
\chapter*{\listfigurenameappendixes}
}
% prints appendices list of tables
\printlist[appendices]{lot}{}{
\chapter*{\listtablenameappendixes}
}
% prints appendices list of tables listings
\listofappendixlistings
\endgroup
\includepdf[
pages=1,
pagecommand=\chapter{Analyse Bibliographique}\label{annexe:AnalyseBiblio},
offset=0 -1cm,
scale=0.8
]{example-image-duck.pdf}
\includepdf[
pages=2-,
pagecommand={},
width=1.2\textwidth,
% To have items into list of figures / tables / listings
% WARNING : As explained by the doc, this option is experimental (it MAY change but I don't think so : many people used that)
% SECOND WARNING : the page number argument is the real position from starting point !!
addtolist={
8, table, {Les 5 types de données de la LOM}, tab:typeLOM,
15, table, {Éléments de base de notre norme}, tab:baseNorm,
16, table, {Éléments d'un mot-clé de notre norme}, tab:KeyElementsNorm,
16, table, {Quelques éléments additionnels de notre norme}, tab:ExtendedElementsNorm,
17, lstlisting, {Exemple d'une ressource information avec notre norme}, code:exampleJson
% Bug with figures : no idea why
%5, figure, {Les 15 éléments de la Dublin Core}, fig:dcListElements,
%6, figure, {Les 9 catégories d'éléments de la LOM}, fig:LOMTable,
%7, figure, {Représentation hiérarchique de la LOM}, fig:LOMChart,
%7, figure, {Correspondance des éléments entre la Dublin Core et la LOM}, fig:mappingDcLom,
%9, figure, {MLR - Spécification d’un élément de données}, fig:mlr,
%9, figure, {MLR - Exemple de spécification d’un élément de données}, fig:mlr2,
%10, figure, {Représentation simplifiée de la MLR}, fig:mlr3,
%11, figure, {Exemple de taxonomie pour les exercices de programmation}, fig:taxonomieEx,
%12, figure, {Liste des sous-domaines de l'informatique selon la CC2005}, fig:AllDomainInInfo,
%13, figure, {Exemple de hiérarchie de compétences}, fig:comptenceTree,
%13, figure, {Catégories d'exercices informatiques}, fig:CatExoList
}
]{example-image-duck.pdf}
\end{appendices}
% Stop partial lists
\stoplist[appendices]{lof}% stops main list of figures
\stoplist[appendices]{lot}% stops main list of tables
\end{document}
如果我取消注释所有数字(并且没有忘记在 lstlisting 后面加逗号),我会收到以下消息:
谢谢您的帮助
答案1
错误消息表明\ext@lstlisting
问题不在于图而在于列表:包中没有定义 pdfpages 所需的所有命令,因此它不知道在哪里写入条目。
\documentclass[a4paper,12pt]{report}
\usepackage{listings}
\usepackage{pdfpages}
\makeatletter
\def\ext@lstlisting{lol} %<------------ added
\makeatother
\begin{document}
\includepdf[
pages=2-20,
addtolist={
17, lstlisting, {Exemple d'une ressource information avec notre norme}, code:exampleJson
}
]{example-image-duck}
\end{document}