1

I would like to be able to create a list of attachments similar to the list of figures or tables. However, since it makes little sense to sort the attachments by page number, I would like to sort them alphabetically.

I can create the list of attachments itself, but I'm having trouble sorting it alphabetically. I saw that it was possible to do it here. However, this solution does not work for me (with PdfLatex it works, but with LuaLatex, which I use, the classification is wrong):
enter image description here enter image description here

So I was wondering if it was possible to use Lua directly or to use the power of Biber (outside the context of Biblatex) to alphabetize a list containing unicode characters. Wouldn't these tools be more efficient in this field?

Here is a MWE:

\documentclass{article}

\usepackage{hyperref, embedfile, hypgotoe, datatool}

\renewcommand*{\dtlsetUTFviiicharcode}[2]{% \ifstrequal{#1}{À}{#2=65\relax}% {\ifstrequal{#1}{É}{#2=69\relax}{\dtlsetdefaultUTFviiicharcode{#1}{#2}}}% }

\makeatletter \NewDocumentCommand{\declareattachedfile}{m m}{% \embedfile[ucfilespec={#2.pdf}]{#1}% \addtocontents{loaf}{% \protect\DTLnewrow{listofattachedfiles}% \protect\DTLnewdbentry{listofattachedfiles}{filename}{#1}%
\protect\DTLnewdbentry{listofattachedfiles}{filetitle}{#2}% }% }

\newcommand{\listofattachedfiles}{% \section{List of attached files}% \DTLnewdb{listofattachedfiles}% @starttoc{loaf}% \DTLsort{filetitle}{listofattachedfiles}% \DTLforeach{listofattachedfiles}{\theFiletitle=filetitle, \theFilename=filename}{% \vskip 12\p@ @plus\p@% \begingroup% \noindent\href[pdfnewwindow=true]{gotoe:embedded=\theFilename}{\theFiletitle}% \par% \endgroup% }% \newpage% } \makeatother

\declareattachedfile{example-image-letter-numbered.pdf}{Z} \declareattachedfile{example-image-a4-numbered.pdf}{A} \declareattachedfile{example-image.pdf}{1} \declareattachedfile{example-image-a.pdf}{É} \declareattachedfile{example-image-b.pdf}{N}

\begin{document} \listofattachedfiles

Expected sorting : \begin{itemize} \item 1 \item A \item É \item N \item Z \end{itemize} \end{document}

B Legrand
  • 521
  • 1
    you naturally could use biber. You would have to store your file names etc as bib-entries and write a suitable bibliography driver. To sort with lua see e.g. https://tex.stackexchange.com/a/344151/2388 – Ulrike Fischer May 11 '22 at 08:11

0 Answers0