| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: ltdocinit.dtx |
| 4 |
% |
| 5 |
% Copyright (C) 2018-2026 The LaTeX Project |
| 6 |
% |
| 7 |
% It may be distributed and/or modified under the conditions of the |
| 8 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 9 |
% license or (at your option) any later version. The latest version |
| 10 |
% of this license is in the file |
| 11 |
% |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% This file is part of the "LaTeX PDF management bundle" (The Work in LPPL) |
| 15 |
% and all files in that bundle must be distributed together. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/latex3/pdfresources |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
%<*driver> |
| 26 |
\DocumentMetadata{tagging=on,pdfstandard=ua-2} |
| 27 |
\documentclass[full]{l3doc} |
| 28 |
\usepackage{latex-lab-testphase-l3doc} |
| 29 |
\usepackage{array,booktabs} |
| 30 |
\hypersetup{pdfauthor=The LaTeX Project,pdftitle=ltdocinit (LaTeX PDF management testphase bundle)} |
| 31 |
|
| 32 |
\begin{document} |
| 33 |
\DocInput{\jobname.dtx} |
| 34 |
\end{document} |
| 35 |
%</driver> |
| 36 |
% \fi |
| 37 |
% |
| 38 |
% \title{^^A |
| 39 |
% The \pkg{ltdocinit} module |
| 40 |
% } |
| 41 |
% |
| 42 |
% \author{^^A |
| 43 |
% The \LaTeX{} Project\thanks |
| 44 |
% {^^A |
| 45 |
% E-mail: |
| 46 |
% \href{mailto:[email protected]} |
| 47 |
% {[email protected]}^^A |
| 48 |
% }^^A |
| 49 |
% } |
| 50 |
% |
| 51 |
% \date{Version 0.97c, released 2026-05-26} |
| 52 |
% |
| 53 |
% \maketitle |
| 54 |
% \begin{documentation} |
| 55 |
% |
| 56 |
% \section{\pkg{ltdocinit} documentation} |
| 57 |
% This small module previously defined \cs{DocumentMetadata} but the definition |
| 58 |
% has been moved to latex-lab. The documentation can be found in |
| 59 |
% \texttt{documentmetadata-support-doc.pdf} |
| 60 |
% |
| 61 |
% \cs{DocumentMetadata} is also used to |
| 62 |
% activate the new PDF management code and it loads |
| 63 |
% a number of required files for the PDF management code. |
| 64 |
% As this forces the loading of the backend files, a backend |
| 65 |
% which can't be detected automatically like |dvipdfmx|, |
| 66 |
% must be set in the first \cs{DocumentMetadata}. |
| 67 |
% |
| 68 |
% |
| 69 |
% The module also defines commands to store document properties in a global container. |
| 70 |
% |
| 71 |
% This module will slowly disappear. |
| 72 |
% |
| 73 |
% |
| 74 |
% \subsection{Container for document properties} |
| 75 |
% |
| 76 |
% The module provides a container where classes, packages and users can store |
| 77 |
% properties of the document which are perhaps of interest |
| 78 |
% or use for other packages or the author. |
| 79 |
% |
| 80 |
% The properties are stored with a key |label/property|. The values can be |
| 81 |
% retrieved expandably. |
| 82 |
% |
| 83 |
% \begin{function}{\AddToDocumentProperties} |
| 84 |
% \begin{syntax} |
| 85 |
% \cs{AddToDocumentProperties}\oarg{label}\Arg{property}\Arg{value} |
| 86 |
% \end{syntax} |
| 87 |
% This stores \meta{value} under the key \meta{label}/\meta{property}. |
| 88 |
% By default \meta{label} is the current package name |\@currname|. If another |
| 89 |
% label is chosen, it should be one which avoids clashes with other packages |
| 90 |
% using the container. The label |document| is reserved. |
| 91 |
% \end{function} |
| 92 |
% |
| 93 |
% \begin{function}[updated=2025-06-21]{\GetDocumentProperty,\pdfmanagement_get_documentproperty:n} |
| 94 |
% \begin{syntax} |
| 95 |
% \cs{GetDocumentProperty}\Arg{label/property}\\ |
| 96 |
% \cs{pdfmanagement_get_documentproperty:n} \Arg{label/property} |
| 97 |
% \end{syntax} |
| 98 |
% Expands to the \meta{value} corresponding to \meta{label/property} |
| 99 |
% in the container. If \meta{label/property} is missing, |
| 100 |
% this has an empty expansion. |
| 101 |
% The result is returned within \cs{exp_not:n}, which means |
| 102 |
% that the \meta{value} does not expand further |
| 103 |
% when appearing in an x-type argument expansion. |
| 104 |
% The older names \cs{GetDocumentProperties} and \cs{pdfmanagement_get_documentproperties:n} |
| 105 |
% are still provided for compatibility. |
| 106 |
% \end{function} |
| 107 |
% |
| 108 |
% \begin{function}[updated=2025-06-21,TF]{\pdfmanagement_get_documentproperty:nN} |
| 109 |
% \begin{syntax} |
| 110 |
% \cs{pdfmanagement_get_documentproperty:nNTF} \Arg{label/property} \meta{tl var}\\ |
| 111 |
% ~~~~ \Arg{true code} \Arg{false code} |
| 112 |
% \end{syntax} |
| 113 |
% If the \meta{label/property} is not present in the document properties |
| 114 |
% container, leaves the \meta{false code} in the input stream. |
| 115 |
% The value of the |
| 116 |
% \meta{tl var} is not defined in this case and should |
| 117 |
% not be relied upon. If the \meta{label/property} is present in the |
| 118 |
% container, stores the corresponding \meta{value} in the |
| 119 |
% \meta{tl var} without removing it from the |
| 120 |
% container, then leaves the \meta{true code} in the input |
| 121 |
% stream. The \meta{tl var} is assigned locally. |
| 122 |
% The older name \cs{pdfmanagement_get_documentproperty:nN} |
| 123 |
% is still provided for compatibility. |
| 124 |
% \end{function} |
| 125 |
% |
| 126 |
% \begin{function}{\ShowDocumentProperties,\LogDocumentProperties} |
| 127 |
% \begin{syntax} |
| 128 |
% \cs{ShowDocumentProperties}\\ |
| 129 |
% \cs{LogDocumentProperties} |
| 130 |
% \end{syntax} |
| 131 |
% This shows/logs the current content of the container. |
| 132 |
% \end{function} |
| 133 |
% |
| 134 |
% \begin{thebibliography}{9} |
| 135 |
% |
| 136 |
% \bibitem{blueprint} Frank Mittelbach and Chris Rowley: |
| 137 |
% \emph{\LaTeX{} Tagged PDF\,---\,A blueprint for a large project}. |
| 138 |
% \url{https://latex-project.org/publications/indexbyyear/2020/} |
| 139 |
% |
| 140 |
% \end{thebibliography} |
| 141 |
% |
| 142 |
% \end{documentation} |
| 143 |
% |
| 144 |
% \begin{implementation} |
| 145 |
% |
| 146 |
% \section{\pkg{ltdocinit} implementation} |
| 147 |
% \begin{macrocode} |
| 148 |
%<@@=pdfmanagement> |
| 149 |
%<*header> |
| 150 |
\ProvidesExplPackage{ltdocinit}{2026-05-26}{0.97c} |
| 151 |
{Initialize document metadata} |
| 152 |
%</header> |
| 153 |
% \end{macrocode} |
| 154 |
% \begin{macrocode} |
| 155 |
%<*package> |
| 156 |
% \end{macrocode} |
| 157 |
% \subsection{Variables} |
| 158 |
% This variable definitions can be remove once latex-lab has been updated to |
| 159 |
% provide them too. |
| 160 |
% TODO: check if that is needed if the pdfmanagement is loaded as standalone. |
| 161 |
% \begin{variable}{\g_@@_firstaidoff_clist} |
| 162 |
% A list to store the firstaid code which should be disabled |
| 163 |
% \begin{macrocode} |
| 164 |
\clist_if_exist:NF \g_@@_firstaidoff_clist |
| 165 |
{ \clist_new:N \g_@@_firstaidoff_clist } |
| 166 |
% \end{macrocode} |
| 167 |
% \end{variable} |
| 168 |
% |
| 169 |
% |
| 170 |
% \subsection{Container for document Properties} |
| 171 |
% This should move into the kernel, so we test if the command is already defined. |
| 172 |
% \begin{macrocode} |
| 173 |
\cs_if_exist:NTF\AddToDocumentProperties |
| 174 |
{ |
| 175 |
% \end{macrocode} |
| 176 |
% \begin{macro}{\pdfmanagement_get_documentproperty:n} |
| 177 |
% \begin{macrocode} |
| 178 |
\cs_new:Npn\pdfmanagement_get_documentproperty:n #1 |
| 179 |
{ |
| 180 |
\prop_item:Nn \g__kernel_documentproperties_prop {#1} |
| 181 |
} |
| 182 |
% \end{macrocode} |
| 183 |
% \end{macro} |
| 184 |
% \begin{macro}{\pdfmanagement_get_documentproperty:nNTF} |
| 185 |
% \begin{macrocode} |
| 186 |
\prg_new_protected_conditional:Npnn |
| 187 |
\pdfmanagement_get_documentproperty:nN #1#2 { T , F , TF } |
| 188 |
{ |
| 189 |
\prop_get:NnNTF \g__kernel_documentproperties_prop {#1} #2 |
| 190 |
{ |
| 191 |
\prg_return_true: |
| 192 |
} |
| 193 |
{ |
| 194 |
\prg_return_false: |
| 195 |
} |
| 196 |
} |
| 197 |
% \end{macrocode} |
| 198 |
% \end{macro} |
| 199 |
% We provide the old commands as fallback: |
| 200 |
% \begin{macrocode} |
| 201 |
\cs_new_eq:NN\GetDocumentProperties\GetDocumentProperty |
| 202 |
\cs_new_eq:NN |
| 203 |
\pdfmanagement_get_documentproperties:n |
| 204 |
\pdfmanagement_get_documentproperty:n |
| 205 |
\prg_new_eq_conditional:NNn |
| 206 |
\pdfmanagement_get_documentproperties:nN |
| 207 |
\pdfmanagement_get_documentproperty:nN |
| 208 |
{ T , F , TF } |
| 209 |
}% else existence |
| 210 |
{ |
| 211 |
% \end{macrocode} |
| 212 |
% The container for the document properties is a prop |
| 213 |
% \begin{variable}{\g_@@_documentproperties_prop} |
| 214 |
% \begin{macrocode} |
| 215 |
\prop_new:N \g_@@_documentproperties_prop % |
| 216 |
% \end{macrocode} |
| 217 |
% \end{variable} |
| 218 |
% \begin{macro}{\AddToDocumentProperties} |
| 219 |
% \begin{macrocode} |
| 220 |
\NewDocumentCommand\AddToDocumentProperties{O{\@currname}mm} |
| 221 |
{ |
| 222 |
\exp_args:NNe |
| 223 |
\prop_gput:Nnn \g_@@_documentproperties_prop |
| 224 |
{ |
| 225 |
\tl_if_blank:eTF {#1}{top-level/}{#1/} #2 |
| 226 |
} |
| 227 |
{ #3} |
| 228 |
} |
| 229 |
% \end{macrocode} |
| 230 |
% \end{macro} |
| 231 |
% \begin{macro}[EXP]{\GetDocumentProperty,\GetDocumentProperties} |
| 232 |
% \begin{macrocode} |
| 233 |
\cs_new:Npn\GetDocumentProperty #1 |
| 234 |
{ |
| 235 |
\prop_item:Nn \g_@@_documentproperties_prop {#1} |
| 236 |
} |
| 237 |
\cs_new_eq:NN\GetDocumentProperties\GetDocumentProperty |
| 238 |
% \end{macrocode} |
| 239 |
% \end{macro} |
| 240 |
% For uses in modules (e.g. l3pdfmeta) |
| 241 |
% we provide an expl3 version without the xparse overhead: |
| 242 |
% |
| 243 |
% \begin{macro}[EXP]{\pdfmanagement_get_documentproperty:n} |
| 244 |
% \begin{macrocode} |
| 245 |
\cs_new:Npn\pdfmanagement_get_documentproperty:n #1 |
| 246 |
{ |
| 247 |
\prop_item:Nn \g_@@_documentproperties_prop {#1} |
| 248 |
} |
| 249 |
\cs_new_eq:NN |
| 250 |
\pdfmanagement_get_documentproperties:n |
| 251 |
\pdfmanagement_get_documentproperty:n |
| 252 |
% \end{macrocode} |
| 253 |
% \end{macro} |
| 254 |
% The following allows to retrieve the values with branching. |
| 255 |
% \begin{macro}[added=2025-06-21]{\pdfmanagement_get_documentproperty:nNTF} |
| 256 |
% \begin{macrocode} |
| 257 |
\prg_new_protected_conditional:Npnn |
| 258 |
\pdfmanagement_get_documentproperty:nN #1#2 { T , F , TF } |
| 259 |
{ |
| 260 |
\prop_get:NnNTF \g_@@_documentproperties_prop {#1} #2 |
| 261 |
{ |
| 262 |
\prg_return_true: |
| 263 |
} |
| 264 |
{ |
| 265 |
\prg_return_false: |
| 266 |
} |
| 267 |
} |
| 268 |
\prg_new_eq_conditional:NNn |
| 269 |
\pdfmanagement_get_documentproperties:nN |
| 270 |
\pdfmanagement_get_documentproperty:nN |
| 271 |
{ T , F , TF } |
| 272 |
% \end{macrocode} |
| 273 |
% \end{macro} |
| 274 |
% \begin{macro}{\ShowDocumentProperties} |
| 275 |
% \begin{macrocode} |
| 276 |
\msg_new:nnn { pdfmanagement } { show-properties } |
| 277 |
{ |
| 278 |
The~following~document~properties~have~been~stored: |
| 279 |
#1 |
| 280 |
} |
| 281 |
\NewDocumentCommand\ShowDocumentProperties {} |
| 282 |
{ |
| 283 |
\msg_show:nne {pdfmanagement}{show-properties} |
| 284 |
{ |
| 285 |
\prop_map_function:NN \g_@@_documentproperties_prop \msg_show_item:nn |
| 286 |
} |
| 287 |
} |
| 288 |
\NewDocumentCommand\LogDocumentProperties {} |
| 289 |
{ |
| 290 |
\msg_log:nne {pdfmanagement}{show-properties} |
| 291 |
{ |
| 292 |
\prop_map_function:NN \g_@@_documentproperties_prop \msg_show_item:nn |
| 293 |
} |
| 294 |
} |
| 295 |
% \end{macrocode} |
| 296 |
% \begin{macrocode} |
| 297 |
} % end of existence test |
| 298 |
% \end{macrocode} |
| 299 |
% \end{macro} |
| 300 |
% \begin{macrocode} |
| 301 |
%</package> |
| 302 |
% \end{macrocode} |
| 303 |
% |
| 304 |
% \end{implementation} |
| 305 |
% |
| 306 |
% \PrintIndex |