| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: ltmeta.dtx |
| 4 |
%% Copyright (C) 2021-2025 |
| 5 |
%% Frank Mittelbach, 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 |
% https://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% |
| 15 |
%%% From File: ltmeta.dtx |
| 16 |
%<*driver> |
| 17 |
% \fi |
| 18 |
\ProvidesFile{ltmeta.dtx} |
| 19 |
[2025/03/01 v1.0d LaTeX Kernel (Document Metadata)] |
| 20 |
% \iffalse |
| 21 |
% |
| 22 |
\documentclass{l3doc} |
| 23 |
\GetFileInfo{ltmeta.dtx} |
| 24 |
|
| 25 |
\EnableCrossrefs |
| 26 |
\CodelineIndex |
| 27 |
\begin{document} |
| 28 |
\DocInput{ltmeta.dtx} |
| 29 |
\end{document} |
| 30 |
%</driver> |
| 31 |
% |
| 32 |
% \fi |
| 33 |
% |
| 34 |
% \providecommand\hook[1]{\texttt{#1}} |
| 35 |
% \providecommand\env[1]{\texttt{#1}} |
| 36 |
% |
| 37 |
% |
| 38 |
% |
| 39 |
% \title{The \texttt{ltmeta.dtx} code\thanks{This file has version |
| 40 |
% \fileversion\ dated \filedate, \copyright\ \LaTeX\ |
| 41 |
% Project.}} |
| 42 |
% \author{Frank Mittelbach} |
| 43 |
% |
| 44 |
% \maketitle |
| 45 |
% |
| 46 |
% |
| 47 |
% \begin{abstract} |
| 48 |
% This code defines the \cs{DocumentMetadata} interface. |
| 49 |
% \end{abstract} |
| 50 |
% |
| 51 |
% \tableofcontents |
| 52 |
% |
| 53 |
% |
| 54 |
% \section{Introduction} |
| 55 |
% |
| 56 |
% |
| 57 |
% In the past there was no dedicated location to declare settings |
| 58 |
% concerning a document as a whole. Settings are placed somewhere |
| 59 |
% in the preamble or with the class options or even with some |
| 60 |
% package options. For some settings this can be too late, for |
| 61 |
% example the pdf version can no longer be changed if a package has |
| 62 |
% used code which already opened the PDF. |
| 63 |
% |
| 64 |
% \cs{DocumentMetadata} as a new command unifies such settings in |
| 65 |
% one place. It must be used before \cs{documentclass} but can be |
| 66 |
% issued more than once there. |
| 67 |
% |
| 68 |
% At the moment most of the code run by \cs{DocumentMetadata} is |
| 69 |
% external to the format and subject to change. This includes the |
| 70 |
% supported key/values. |
| 71 |
% |
| 72 |
% For that reason all that happens right now in the format is to |
| 73 |
% look for suitable support files and if found, to redirect the |
| 74 |
% processing to them. |
| 75 |
% |
| 76 |
% \subsection{\cs{DocumentMetadata}} |
| 77 |
% |
| 78 |
% \begin{function}{\DocumentMetadata} |
| 79 |
% \begin{syntax} |
| 80 |
% \cs{DocumentMetadata}\Arg{key-value list} |
| 81 |
% \end{syntax} |
| 82 |
% \end{function} |
| 83 |
% |
| 84 |
% |
| 85 |
% |
| 86 |
% The keys defined for \cs{DocumentMetadata} |
| 87 |
% currently allow to set the PDF version, to set the PDF \texttt{/Lang}, |
| 88 |
% to uncompress a PDF, to set the language and to declare a few PDF standards |
| 89 |
% and some color profiles. |
| 90 |
% |
| 91 |
% \cs{DocumentMetadata} is also used to |
| 92 |
% activate the new PDF management code and it loads |
| 93 |
% a number of required files for the PDF management code. |
| 94 |
% As this forces the loading of the backend files, a backend |
| 95 |
% which can't be detected automatically like |dvipdfmx|, |
| 96 |
% must be set in the first \cs{DocumentMetadata} call (if there is more than one). |
| 97 |
% |
| 98 |
% The full set of keys currently supported is documented in \texttt{documentmetadata-support.pdf} |
| 99 |
% for now. |
| 100 |
% |
| 101 |
% |
| 102 |
% \StopEventually{\setlength\IndexMin{200pt} \PrintIndex } |
| 103 |
% |
| 104 |
% |
| 105 |
% \section{The Implementation} |
| 106 |
% |
| 107 |
% |
| 108 |
% |
| 109 |
% \begin{macrocode} |
| 110 |
%<*2ekernel|latexrelease> |
| 111 |
% \end{macrocode} |
| 112 |
% Not needed yet but \ldots |
| 113 |
% \begin{macrocode} |
| 114 |
%\ExplSyntaxOn |
| 115 |
% \end{macrocode} |
| 116 |
% |
| 117 |
% \begin{macrocode} |
| 118 |
%<latexrelease>\NewModuleRelease{2022/06/01}{ltmeta} |
| 119 |
%<latexrelease> {Document Metadata handling} |
| 120 |
% \end{macrocode} |
| 121 |
% We start by making the conditionals testing for the use of |
| 122 |
% \cs{DocumentMetadata} execute the the false branch. Then, inside |
| 123 |
% \cs{DocumentMetadata}, we change them to select the true branch. |
| 124 |
% \changes{v1.0d}{2025/03/01}{Provide T F variants of |
| 125 |
% \cs{IfDocumentMetadataTF} (gh/1522)} |
| 126 |
% \begin{macrocode} |
| 127 |
\let \IfDocumentMetadataTF \@secondoftwo |
| 128 |
\let \IfDocumentMetadataT \@gobble |
| 129 |
\let \IfDocumentMetadataF \@firstofone |
| 130 |
\protected\def\DocumentMetadata{% |
| 131 |
\InputIfFileExists{documentmetadata-support.ltx}% |
| 132 |
{% |
| 133 |
% \end{macrocode} |
| 134 |
% Support for \cs{DocumentMetadata} is available, so change the conditionals. |
| 135 |
% \begin{macrocode} |
| 136 |
\let \IfDocumentMetadataTF \@firstoftwo |
| 137 |
\let \IfDocumentMetadataT \@firstofone |
| 138 |
\let \IfDocumentMetadataF \@gobble |
| 139 |
}% |
| 140 |
% \end{macrocode} |
| 141 |
% The above file is changing \cs{DocumentMetadata} to a suitable |
| 142 |
% definition (or so we hope) so that it can be safely used several times |
| 143 |
% in the premable. |
| 144 |
% |
| 145 |
% If the file can't be found we say so and carry on without it. |
| 146 |
% \begin{macrocode} |
| 147 |
{% |
| 148 |
\@latex@error{No support files for |
| 149 |
\noexpand\DocumentMetadata found} |
| 150 |
{Is the 'LaTeX-lab' bundle installed?% |
| 151 |
\MessageBreak |
| 152 |
Without it, the declaration is ignored.}% |
| 153 |
% \end{macrocode} |
| 154 |
% No point in trying this more than once if there are several calls |
| 155 |
% in the document. |
| 156 |
% \begin{macrocode} |
| 157 |
\let\DocumentMetadata\@gobble |
| 158 |
}% |
| 159 |
\DocumentMetadata |
| 160 |
} |
| 161 |
% \end{macrocode} |
| 162 |
% |
| 163 |
% To allow package and class author to support for document links |
| 164 |
% we provide also the new interface commands of the hyperref package |
| 165 |
% for the creation of targets. |
| 166 |
% \changes{v1.0b}{2022/05/17}{Default definition for targets added} |
| 167 |
% \changes{v1.0c}{2024/09/21}{Added tagging support} |
| 168 |
% \begin{macro}{\MakeLinkTarget} |
| 169 |
% \begin{macro}{\LinkTargetOn} |
| 170 |
% \begin{macro}{\LinkTargetOff} |
| 171 |
% \begin{macro}{\NextLinkTarget} |
| 172 |
% \begin{macrocode} |
| 173 |
%<latexrelease>\IncludeInRelease{2024/11/01}% |
| 174 |
%<latexrelease> {\MakeLinkTarget}{Record target name for tagging support}% |
| 175 |
\ExplSyntaxOn |
| 176 |
\int_new:N\g__kernel_target_int |
| 177 |
\NewDocumentCommand\MakeLinkTarget{sO{}m}{% |
| 178 |
\ifvmode |
| 179 |
\special{}% |
| 180 |
\else |
| 181 |
\@savsf\spacefactor |
| 182 |
\smash{}% |
| 183 |
\spacefactor\@savsf |
| 184 |
\fi |
| 185 |
\IfBooleanTF {#1} |
| 186 |
{ |
| 187 |
\tl_gset:Ne \@currentHref {#3} |
| 188 |
} |
| 189 |
{ |
| 190 |
\int_gincr:N\g__kernel_target_int |
| 191 |
\tl_gset:Ne \@currentHref {target*.\int_use:N\g__kernel_target_int} |
| 192 |
} |
| 193 |
\UseTaggingSocket{recordtarget} |
| 194 |
} |
| 195 |
\ExplSyntaxOff |
| 196 |
%<latexrelease>\EndIncludeInRelease |
| 197 |
%<latexrelease>\IncludeInRelease{2022/06/01}% |
| 198 |
%<latexrelease> {\MakeLinkTarget}{Record target name for tagging support}% |
| 199 |
%<latexrelease>\NewDocumentCommand\MakeLinkTarget{sO{}m}{% |
| 200 |
%<latexrelease> \ifvmode |
| 201 |
%<latexrelease> \special{}% |
| 202 |
%<latexrelease> \else |
| 203 |
%<latexrelease> \@savsf\spacefactor |
| 204 |
%<latexrelease> \smash{}% |
| 205 |
%<latexrelease> \spacefactor\@savsf |
| 206 |
%<latexrelease> \fi} |
| 207 |
%<latexrelease>\EndIncludeInRelease |
| 208 |
\NewDocumentCommand\LinkTargetOn{}{} |
| 209 |
\NewDocumentCommand\LinkTargetOff{}{} |
| 210 |
\NewDocumentCommand\NextLinkTarget{m}{} |
| 211 |
% \end{macrocode} |
| 212 |
% \end{macro} |
| 213 |
% \end{macro} |
| 214 |
% \end{macro} |
| 215 |
% \end{macro} |
| 216 |
% |
| 217 |
% |
| 218 |
% We do not undo \cs{MakeLinkTarget} and friends if we roll back, in |
| 219 |
% case they are used in packages that themselves do not offer |
| 220 |
% rollback. This way a roll forward adds them, but the dummies remain |
| 221 |
% if you roll back and you don't get missing csname errors if they |
| 222 |
% are used. |
| 223 |
% \begin{macrocode} |
| 224 |
%<latexrelease>\IncludeInRelease{0000/00/00}{ltmeta}% |
| 225 |
%<latexrelease> {Undo Document Metadata handling} |
| 226 |
%<latexrelease> |
| 227 |
%<latexrelease>\let\DocumentMetadata\@undefined |
| 228 |
%<latexrelease> |
| 229 |
%<latexrelease>\EndModuleRelease |
| 230 |
% \end{macrocode} |
| 231 |
% Again for the future \ldots |
| 232 |
% \begin{macrocode} |
| 233 |
%\ExplSyntaxOff |
| 234 |
% \end{macrocode} |
| 235 |
% \begin{macrocode} |
| 236 |
%</2ekernel|latexrelease> |
| 237 |
% \end{macrocode} |
| 238 |
% |
| 239 |
% Restore module prefix (if any): |
| 240 |
% \begin{macrocode} |
| 241 |
%<@@=> |
| 242 |
% \end{macrocode} |
| 243 |
% |
| 244 |
% |
| 245 |
% |
| 246 |
% |
| 247 |
% |
| 248 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 249 |
\endinput |
| 250 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 251 |
% |