summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hyperxmp/hyperxmp.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/hyperxmp/hyperxmp.dtx')
-rw-r--r--macros/latex/contrib/hyperxmp/hyperxmp.dtx202
1 files changed, 168 insertions, 34 deletions
diff --git a/macros/latex/contrib/hyperxmp/hyperxmp.dtx b/macros/latex/contrib/hyperxmp/hyperxmp.dtx
index a2cc59e97f..1d2c332018 100644
--- a/macros/latex/contrib/hyperxmp/hyperxmp.dtx
+++ b/macros/latex/contrib/hyperxmp/hyperxmp.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
%
-% Copyright (C) 2011--2020 by Scott Pakin <scott+hyxmp@pakin.org>
-% ---------------------------------------------------------------
+% Copyright (C) 2011-2020 by Scott Pakin <scott+hyxmp@pakin.org>
+% --------------------------------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{hyperxmp}
%<*package>
- [2020/04/08 v5.1 Store hyperref metadata in XMP format]
+ [2020/05/12 v5.2 Store hyperref metadata in XMP format]
%</package>
%
%<*driver>
@@ -81,6 +81,7 @@
pdflang={en-US},
pdftrapped={False},
pdfstartpage={},
+ pdfsource={hyperxmp.dtx},
pdfurl={http://mirror.ctan.org/macros/latex/contrib/hyperxmp/hyperxmp.pdf},
baseurl={http://mirror.ctan.org/macros/latex/contrib/hyperxmp/}
}
@@ -111,7 +112,7 @@
%</driver>
% \fi
%
-% \CheckSum{2354}
+% \CheckSum{2425}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -168,6 +169,9 @@
% standards, as requested by Robin Schwab}
% \changes{v5.0}{2020/02/26}{Added support for \protect\acro{PDF/X}
% standards, as requested by Robin Schwab}
+% \changes{v5.2}{2020/04/29}{Introduced the \protect\optname{pdfidentifier}
+% package option, which enables an author to specify a unique identifier
+% for the document}
%
% ^^A \GetFileInfo{hyperxmp.dtx}
%
@@ -413,6 +417,7 @@
% \item trapping of colors (\xmpprop{pdf:trapped})
% \item type of document (\xmpprop{dc:type})
% \item type of parent publication (\xmpprop{prism:aggregationType})
+% \item unique identifier for the document (\xmpprop{dc:identifier})
% \item \acro{URL} of the document (\xmpprop{prism:url})
% \item \acro{URL}(s) of the primary author (\xmpprop[CiUrlWork]{Iptc4xmpCore:CreatorContactInfo})
% \item \acro{UUID} for the document (\xmpprop{xmpMM:DocumentID})
@@ -499,6 +504,7 @@
% \item \optname{pdfdocumentid}
% \item \optname{pdfdoi}
% \item \optname{pdfeissn}
+% \item \optname{pdfidentifier}
% \item \optname{pdfinstanceid}
% \item \optname{pdfisbn}
% \item \optname{pdfissn}
@@ -632,6 +638,27 @@
% In contrast, \moptname{baseurl} points one level up and is used to
% resolve relative \acro{URL}s.
%
+% \moptname{pdfidentifier} provides an alternative mechanism to uniquely
+% identify a document. Its advantage relative to \optname{pdfisbn},
+% \optname{pdfissn}, \optname{pdfdoi}, etc.\ is its flexibility; any of
+% a wide variety of identification types can be used.\footnote{See, for
+% example,
+% \url{https://www.iana.org/assignments/urn-namespaces/urn-namespaces.xhtml}
+% for the \texttt{urn:} \acro{URI} scheme and
+% \url{http://info-uri.info/registry/} for the \texttt{info:}
+% \acro{URI} scheme.} \optname{pdfidentifier}'s disadvantage is that
+% it allows only a single identifier per document. For example, a
+% document could use |pdfidentifier=urn:iso:std:32000:ed-1:v1:en| to
+% identify itself as version~1 of English-language \acro{ISO} standard
+% 32000-1, but then this same document could not also use
+% \optname{pdfidentifier} to identify itself by \acro{DOI}
+% (|info:doi/|\dots), \acro{ISBN} (|urn:ISSN:|\dots), etc. (It can
+% still use the options described in the previous paragraph, though.) If
+% \optname{pdfidentifier} is not specified explicitly,
+% \pkgname{hyperxmp} will use the first non-empty value out of the
+% \acro{DOI}, electronic \acro{ISSN}, print \acro{ISSN}, and \acro{ISBN}
+% or skip the identifier entirely if all of those are empty.
+%
% Already-published documents can further be identified by the
% publication in which they appear. \moptname{pdfpublication} specifies
% the title of the journal, magazine, or other parent document. The
@@ -761,7 +788,7 @@
% \optname{pdfuapart}=|1| asserts that the document respects
% \PDFstd{UA}{1}{}{}. \moptname{pdfxstandard} indicates
% the particular \acro{PDF/X} standard by which the document abides.
-% Unlike \optname{pdfpart} and \optname{pdfaconformance}, which accept a
+% Unlike \optname{pdfapart} and \optname{pdfaconformance}, which accept a
% number and a letter, respectively, \optname{pdfxstandard} expects a
% textual identification of a standard name. The following are the
% \acro{PDF/X} standard names that are considered acceptable at the time
@@ -863,6 +890,7 @@
% pdfmetalang={en},
% pdfurl={http://www.physik.uni-augsburg.de/annalen/history/einstein-papers/1905_17_132-148.pdf},
% pdfdoi={10.1002/andp.19053220607},
+% pdfidentifier={info:lccn/50013519},
% pdfbytes={\pdffilesize{\jobname.pdf}} % Requires pdflatex
% }
% \XMPLangAlt{de}{pdftitle={Über einen die Erzeugung und Verwandlung des
@@ -1778,9 +1806,17 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\ifdraft}
+% Use the \pkgname{ifdraft} package to determine if this is a draft or
+% final document.
+% \changes{v5.2}{2020/04/18}{Define \protect\cs{ifdraft} only locally, at
+% Niklas Beisert's request}
% \begin{macrocode}
+\begingroup
+\let\ifdraft=\relax
\RequirePackage{ifdraft}
% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\@pdfrendition}
% \changes{v5.0}{2020/02/27}{Added the \protect\optname{pdfrendition}
@@ -1792,10 +1828,11 @@
% |draft|.
% \begin{macrocode}
\ifdraft{%
- \def\@pdfrendition{draft}%
+ \gdef\@pdfrendition{draft}%
}{%
- \def\@pdfrendition{default}%
+ \gdef\@pdfrendition{default}%
}
+\endgroup
\define@key{Hyp}{pdfrendition}{\hyxmp@pdfstringdef\@pdfrendition{#1}}
% \end{macrocode}
% \end{macro}
@@ -1924,6 +1961,14 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@pdfidentifier}
+% Prepare to store an identifier that uniquely represents the document.
+% \begin{macrocode}
+\def\@pdfidentifier{}
+\define@key{Hyp}{pdfidentifier}{\hyxmp@pdfstringdef\@pdfidentifier{#1}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\@pdfsubtitle}
% Prepare to store the document's subtitle.
% \begin{macrocode}
@@ -2291,6 +2336,7 @@
\@pdfdatetime
\@pdfdoi
\@pdfeissn
+ \@pdfidentifier
\@pdfisbn
\@pdfissn
\@pdfissuenum
@@ -2344,6 +2390,7 @@
\gdef\@pdfapart{1}%
\gdef\@pdfaconformance{B}%
}%
+ {}%
\fi
% \end{macrocode}
%
@@ -2367,6 +2414,7 @@
compliance)%
}%
}%
+ {}%
}%
}
% \end{macrocode}
@@ -2993,7 +3041,8 @@
\def\hyxmp@try@today#1#2{%
\@ifmtargexp{\hyxmp@today@xmp}{%
\@ifundefined{#1}{}{#2}%
- }{}%
+ }%
+ {}%
}
% \end{macrocode}
% \end{macro}
@@ -3636,6 +3685,29 @@ ______<#3 xml:lang="#1">\hyxmp@xmlified</#3>^^J%
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\hyxmp@add@simple@pfx}
+% Given an \acro{XMP} tag~(|#1|), a---typically hard-wired---prefix
+% string~(|#2|), and a main string~(|#2|), if the main string is
+% nonempty, add a begin tag, both strings, and an end tag to the packet.
+% The ``|simple|'' in the macro name indicates that the string is output
+% without variations for different languages.
+% \changes{v5.2}{2020/04/29}{Added this macro}
+% \begin{macrocode}
+\newcommand*{\hyxmp@add@simple@pfx}[3]{%
+ \@ifnotmtargexp{#3}{%
+ \hyxmp@add@to@xml{\hyxmp@extra@indent______<}%
+ \xdef\hyxmp@xml{\hyxmp@xml#1}%
+ \hyxmp@pdfstringdef\hyxmp@iprefix{#2}%
+ \hyxmp@xmlify{\hyxmp@iprefix}%
+ \hyxmp@add@to@xml{>\hyxmp@xmlified}%
+ \hyxmp@xmlify{#3}%
+ \hyxmp@add@to@xml{\hyxmp@xmlified</}%
+ \xdef\hyxmp@xml{\hyxmp@xml#1>^^J}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
%
% \subsubsection{Providing metadata in multiple languages}
% \label{sec:lang-alt}
@@ -4151,6 +4223,52 @@ _______________________________________________________________^^J%
}
% \end{macrocode}
%
+% \begin{macro}{\hyxmp@assign@major@minor}
+% Assign |\hyxmp@major@minor| to be the \acro{PDF} version targeted by
+% the running \TeX\ engine.
+% \changes{v5.2}{2020/05/10}{Added this macro. \string\pkgname{hyperxmp}
+% now correctly specifies \string\xmpterm{pdf:PDFVersion} when
+% generating \string\acro{PDF}~2.0+. Thanks to Ulrike Fischer for
+% alerting me to \string\acro{PDF}~2.0's availability in the
+% \string\TeX\ ecosystem and informing me how to activate it}
+% \begin{macro}{\hyxmp@major@minor}
+% \begin{macrocode}
+\newcommand*{\hyxmp@assign@major@minor}{%
+ \@ifundefined{pdfvariable}{%
+ \@ifundefined{pdfminorversion}{%
+% \end{macrocode}
+% Case 1: Neither |\pdfvariable| nor |\pdfminorversion| is defined
+% (\XeLaTeX\ and regular \LaTeX).
+% \begin{macrocode}
+ }{%
+% \end{macrocode}
+% Case 2: |\pdfminorversion| is defined (\pdfLaTeX\ and pre-0.85 \LuaLaTeX).
+% \begin{macrocode}
+ \xdef\hyxmp@major@minor{\the\pdfminorversion}%
+ \@ifundefined{pdfmajorversion}{%
+% \end{macrocode}
+% Case 2(a): |\pdfmajorversion| is not defined (older versions of
+% \pdfLaTeX\ and \LuaLaTeX).
+% \begin{macrocode}
+ \xdef\hyxmp@major@minor{1.\hyxmp@major@minor}%
+ }{%
+% \end{macrocode}
+% Case 2(b): |\pdfmajorversion| is defined (\pdfLaTeX~1.40.21+).
+% \begin{macrocode}
+ \xdef\hyxmp@major@minor{\the\pdfmajorversion.\hyxmp@major@minor}%
+ }%
+ }%
+ }{%
+% \end{macrocode}
+% Case 3: |\pdfvariable| is defined (\LuaLaTeX~0.85+).
+% \begin{macrocode}
+ \xdef\hyxmp@major@minor{\the\pdfvariable majorversion.\the\pdfvariable minorversion}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\hyxmp@pdf@schema}
% Add properties defined by the Adobe \acro{PDF} schema to the |\hyxmp@xml|
% macro.
@@ -4181,27 +4299,8 @@ _______________________________________________________________^^J%
\hyxmp@add@simple@var{pdf:Producer}{@pdfproducer}%
\hyxmp@add@simple@var{pdf:Keywords}{@pdfkeywords}%
\hyxmp@add@simple{pdf:Trapped}{\@pdftrapped}%
-% \end{macrocode}
-% Specify the \acro{PDF} version.
-% \begin{macrocode}
- \@ifundefined{pdfvariable}{%
- \@ifundefined{pdfminorversion}{%
-% \end{macrocode}
-% Case 1: Neither |\pdfvariable| nor |\pdfminorversion| is defined
-% (\XeLaTeX\ and regular \LaTeX).
-% \begin{macrocode}
- }{%
-% \end{macrocode}
-% Case 2: |\pdfminorversion| is defined (\pdfLaTeX\ and pre-0.85 \LuaLaTeX).
-% \begin{macrocode}
- \hyxmp@add@simple{pdf:PDFVersion}{1.\the\pdfminorversion}%
- }%
- }{%
-% \end{macrocode}
-% Case 3: |\pdfvariable| is defined (\LuaLaTeX~0.85+).
-% \begin{macrocode}
- \hyxmp@add@simple{pdf:PDFVersion}{1.\the\pdfvariable minorversion}%
- }%
+ \hyxmp@assign@major@minor
+ \hyxmp@add@simple@var{pdf:PDFVersion}{hyxmp@major@minor}%
}
% \end{macrocode}
% \end{macro}
@@ -4351,6 +4450,24 @@ ______</dc:#2>^^J%
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\hyxmp@cond@dc@identifier}
+% Conditionally add a \xmpterm{dc:identifier} tag. Given a prefix
+% string~(|#1|) and a main string~(|#2|), wrap these in a
+% \xmpterm{dc:identifier} if the main string is nonempty and
+% |\hyxmp@xmlified| \emph{is} empty (implying the
+% \xmpterm{dc:identifier} has not yet been written).
+% \changes{v5.2}{2020/04/29}{Added this macro}
+% \begin{macrocode}
+\newcommand*{\hyxmp@cond@dc@identifier}[2]{%
+ \ifx\hyxmp@xmlified\@empty
+ \@ifnotmtargexp{#2}{%
+ \hyxmp@add@simple@pfx{dc:identifier}{#1}{#2}%
+ }%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\hyxmp@dc@schema}
% Add properties defined by the Dublin Core schema to the |\hyxmp@xml|
% macro. Specifically, we add entries for the \xmpprop{dc:title}
@@ -4360,11 +4477,14 @@ ______</dc:#2>^^J%
% specified a \optname{pdfcopyright}, the \xmpprop{dc:creator} property
% if the author specified a \optname{pdfauthor}, the
% \xmpprop{dc:subject} property if the author specified
-% \optname{pdfkeywords}, and the \xmpprop{dc:language} property if the
-% author specified \optname{pdflang}. We also specify the
-% \xmpprop{dc:date} property using the date the document was run through
-% \LaTeX\ and the \xmpprop{dc:source} property using the base name of
-% the source file with |.tex| appended.
+% \optname{pdfkeywords}, the \xmpprop{dc:language} property if the
+% author specified \optname{pdflang}, the \xmpprop{dc:type} property if
+% the author specified \optname{pdftype}, and the
+% \xmpprop{dc:identifier} if the author specified
+% \optname{pdfidentifier} or if we can derive it from other options. We
+% also specify the \xmpprop{dc:date} property using the date the
+% document was run through \LaTeX\ and the \xmpprop{dc:source} property
+% using the base name of the source file with |.tex| appended.
% \changes{v2.0}{2012/08/26}{Added support for \xmpprop{dc:language}
% and \xmpprop{dc:source}}
% \changes{v2.4}{2013/12/21}{Made \xmpprop{dc:language} a \xmpterm{Bag}
@@ -4386,6 +4506,20 @@ ______</dc:#2>^^J%
\else
\hyxmp@add@simple{dc:source}{\@pdfsource}%
\fi
+% \end{macrocode}
+% If |\@pdfidentifier| is empty, try setting it to each of |\@pdfdoi|,
+% |\@pdfeissn|, |\@pdfissn|, and |\@pdfisbn|, in turn, with proper
+% syntactic adjustments.
+% \begin{macrocode}
+ \@ifmtargexp{\@pdfidentifier}{%
+ \let\hyxmp@xmlified=\@empty
+ \hyxmp@cond@dc@identifier{info:doi/}{\@pdfdoi}%
+ \hyxmp@cond@dc@identifier{urn:ISSN:}{\@pdfeissn}%
+ \hyxmp@cond@dc@identifier{urn:ISSN:}{\@pdfissn}%
+ \hyxmp@cond@dc@identifier{urn:ISBN:}{\@pdfisbn}%
+ }{%
+ \hyxmp@add@simple{dc:identifier}{\@pdfidentifier}%
+ }%
}
% \end{macrocode}
% \end{macro}