summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/hyperxmp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-07-27 21:26:51 +0000
committerKarl Berry <karl@freefriends.org>2017-07-27 21:26:51 +0000
commit163883bed154d373386a4ec682c67a89c10dd75e (patch)
tree82c0ddac5fceee8feb1f976937bcca8b53353121 /Master/texmf-dist/source/latex/hyperxmp
parent489bf93080c55ee77ca42507502afcbfdec203aa (diff)
hyperxmp (27jul17)
git-svn-id: svn://tug.org/texlive/trunk@44902 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/hyperxmp')
-rw-r--r--Master/texmf-dist/source/latex/hyperxmp/einstein-xmp.tex4
-rw-r--r--Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx246
2 files changed, 217 insertions, 33 deletions
diff --git a/Master/texmf-dist/source/latex/hyperxmp/einstein-xmp.tex b/Master/texmf-dist/source/latex/hyperxmp/einstein-xmp.tex
index 59190765d09..cc9182d1daf 100644
--- a/Master/texmf-dist/source/latex/hyperxmp/einstein-xmp.tex
+++ b/Master/texmf-dist/source/latex/hyperxmp/einstein-xmp.tex
@@ -37,6 +37,10 @@
\metavalue{On a heuristic viewpoint concerning the production and
transformation of light}
</rdf:li>
+ <rdf:li xml:lang="de">
+ \metavalue{\"Uber einen die Erzeugung und Verwandlung des Lichtes
+ betreffenden heuristischen Gesichtspunkt}
+ </rdf:li>
</rdf:Alt>
</dc:title>
<dc:description>
diff --git a/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx b/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx
index 7d95a994ae7..c1fd1b5d2e0 100644
--- a/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx
+++ b/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{hyperxmp}
%<*package>
- [2017/02/23 v3.2 Store hyperref metadata in XMP format]
+ [2017/07/25 v3.3 Store hyperref metadata in XMP format]
%</package>
%
%<*driver>
@@ -39,8 +39,9 @@
\usepackage{varioref}
\usepackage{alltt}
\usepackage{needspace}
+\usepackage[utf8]{inputenc}
\usepackage{hyperxmp}
-\usepackage[bookmarksopen,bookmarksopenlevel=2,bookmarksnumbered]{hyperref}
+\usepackage[unicode,bookmarksopen,bookmarksopenlevel=2,bookmarksnumbered]{hyperref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
@@ -81,7 +82,7 @@
%</driver>
% \fi
%
-% \CheckSum{1775}
+% \CheckSum{1833}
%
% \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
@@ -167,6 +168,11 @@
% \mbox{\acrostyle{#1}}^^A
% \SortIndex{#1}{\acrostyle{#1}}^^A
% }
+% \newcounter{note}
+% \newcommand{\usagenote}[1]{^^A
+% \addtocounter{note}{1}^^A
+% \paragraph{Note~\thenote: #1}%
+% }
%
% ^^A Define some other shortcut macros.
% \DeclareRobustCommand{\tex}{^^A
@@ -398,6 +404,7 @@
% \item \optname{pdflicenseurl}
% \item \optname{pdfmetadate}
% \item \optname{pdfmetalang}
+% \item \optname{pdfsource}
% \item \optname{pdftype}
% \end{itemize}
% \label{page:end-new-options}
@@ -465,18 +472,25 @@
% \optname{pdflicenseurl} identifies a \acro{URL} that points to the
% document's license agreement.
%
-% \optname{pdfmetalang} indicates the natural language in which the
-% metadata is written, typically as an \acro{IETF} language
-% tag~\cite{IANA2011:lang-tags}, for example, ``|en|'' for English,
-% ``|en-US|'' for specifically United States English, ``|de|'' for
-% German, and so forth. If \optname{pdfmetalang} is not specified,
-% \pkgname{hyperxmp} assumes the metadata language is the same as the
-% document language (\pkgname{hyperref}'s \optname{pdflang} option). If
-% neither \optname{pdfmetalang} nor \optname{pdflang} is specified,
-% \pkgname{hyperxmp} uses only ``|x-default|'' as the metadata language.
-% Note that ``|x-default|'' metadata is always included in addition to
-% the specified metadata language, as the user reading the document may
-% not have specified a language preference.
+% \optname{pdfmetalang} indicates the natural language in which certain
+% metadata---specifically, the document's title, subject, and copyright
+% statement---are written. The language should be specified using an
+% \acro{IETF} language tag~\cite{IANA2011:lang-tags}, for example,
+% ``|en|'' for English, ``|en-US|'' for specifically United States
+% English, ``|de|'' for German, and so forth. If \optname{pdfmetalang}
+% is not specified, \pkgname{hyperxmp} assumes the metadata language is
+% the same as the document language (\pkgname{hyperref}'s
+% \optname{pdflang} option). If neither \optname{pdfmetalang} nor
+% \optname{pdflang} is specified, \pkgname{hyperxmp} uses only
+% ``|x-default|'' as the metadata language. Note that ``|x-default|''
+% metadata are always included in addition to the specified metadata
+% language, as the user reading the document may not have specified a
+% language preference.
+%
+% A rarely needed option, \optname{pdfsource}, overrides the name of the
+% \LaTeX\ source file. It defaults to ``|\jobname.tex|'' but can be
+% replaced by any other string. If \optname{pdfsource} is given an
+% empty argument, no document source will be specified at all.
%
% \optname{pdftype} describes the type of document being produced. This
% refers to ``the nature or genre of the resource''~\cite{Adobe2012:XMP}
@@ -509,7 +523,7 @@
% \begin{verbatim}
% \documentclass{article}
% \usepackage{hyperxmp}
-% \usepackage{hyperref}
+% \usepackage[unicode]{hyperref}
% \title{%
% On a heuristic viewpoint concerning the production and
% transformation of light}
@@ -538,8 +552,11 @@
% https://www.facebook.com/AlbertEinstein
% },
% pdflang={en},
+% pdfmetalang={en},
% baseurl={http://mirror.ctan.org/macros/latex/contrib/hyperxmp/}
% }
+% \XMPLangAlt{de}{pdftitle={Über einen die Erzeugung und Verwandlung
+% des Lichtes betreffenden heuristischen Gesichtspunkt}}
% \begin{document}
% \maketitle
% A profound formal difference exists between the theoretical
@@ -597,7 +614,7 @@
% \label{fig:xmp-metadata-2}
% \end{figure}
%
-% \paragraph{Note~1: Acrobat \pdfterm{Author} bug}
+% \usagenote{Acrobat \pdfterm{Author} bug}
% \label{page:author-bug}
% A bug in Adobe Acrobat---at least in versions~10.0.1 and
% earlier---causes that \acro{PDF} reader to confuse the \acro{XMP} and
@@ -628,8 +645,7 @@
% properly display all of the authors but at the cost of other
% \acro{PDF} readers likely displaying only the first author.
%
-%
-% \paragraph{Note~2: Acrobat multiline-field bug}
+% \usagenote{Acrobat multiline-field bug}
% The \acro{IPTC} Photo Metadata schema states that ``the [contact]
% address is a multiline field''~\cite{IPTC2010:photo-meta}.
% \pkgname{hyperxmp} converts commas in \optname{pdfcontactaddress}'s
@@ -648,8 +664,7 @@
% \renewcommand*{\xmlinesep}{;}
% \end{verbatim}
%
-%
-% \paragraph{Note~3: Object compression}
+% \usagenote{Object compression}
% One intention of \acro{XMP} is that metadata embedded in a file be
% readable even without knowledge of the file's format. That is, the
% metadata are expected to appear as plain text. Although
@@ -682,8 +697,7 @@
% re-saving it with the Save As\dots\ menu option.
% \end{enumerate}
%
-%
-% \paragraph{Note~4: Literal commas}
+% \usagenote{Literal commas}
% \pkgname{hyperxmp} splits the \optname{pdfauthor} and
% \optname{pdfkeywords} lists at commas. Therefore, when specifying
% \optname{pdfauthor} and \optname{pdfkeywords}, you should separate
@@ -747,13 +761,13 @@
% |scott/|'') in options such as \optname{baseurl},
% \optname{pdfcontacturl} and \optname{pdflicenseurl}.
%
-% \paragraph{Note~5: Unicode support}
+% \usagenote{Unicode support}
% \term{Unicode} support is provided via the \pkgname{hyperref} package.
% If you specify \optname{unicode}|=true| either as a \pkgname{hyperref}
% option or as an argument to the |\hypersetup| command, the document
% can include \term{Unicode} characters in its \acro{XMP} fields.
%
-% \paragraph{Note~6: Automatically specified metadata}
+% \usagenote{Automatically specified metadata}
% \optname{pdftitle} defaults to the document's title as specified by
% |\title{|\dots|}|. \optname{pdfauthor} defaults to the document's
% author(s) as specified by |\author{|\dots|}|. \optname{pdfdate}
@@ -764,6 +778,42 @@
% |\usepackage{hyperxmp}| in a document's preamble and benefit from
% a modicum of \acro{XMP} metadata with no additional effort.
%
+% \usagenote{Multilingual metadata}
+% The \optname{pdfmetalang} option specifies the language in which the
+% document's metadata is written. It defaults to the value of
+% \optname{pdflang}, which specifies the document language.
+% \DescribeMacro{\XMPLangAlt} As of version~3.3 of \pkgname{hyperxmp},
+% it is possible to include certain metadata---specifically, the
+% document's title, subject, and copyright statement---in more than one
+% language. The |\XMPLangAlt| macro provides this functionality. Usage
+% is as follows:
+%
+% \bigskip
+% \indent
+% |\XMPLangAlt| \marg{language} |{| \meta{option}|=|\meta{text},~\dots\ |}|
+% \bigskip
+%
+% \noindent
+% where \meta{language} is an \acro{ISO} \mbox{639-1} two-letter country
+% code with an optional \acro{ISO} \mbox{3166-1} two-letter region code
+% (e.g.,~``|en|'' for English or ``|en-US|'' for specifically US
+% English); \meta{option} is one of ``|pdftitle|'', ``|pdfsubject|'', or
+% ``|pdfcopyright|''; and \meta{text} is the text as expressed in the
+% specified language. By way, of example, the following code provides
+% the document title in English then specifies an alternative title to
+% use in four other languages:
+%
+% \begin{verbatim}
+% \hypersetup{%
+% pdfmetalang={en},
+% pdftitle={English title}
+% }
+% \XMPLangAlt{de}{pdftitle={Deutscher Titel}}
+% \XMPLangAlt{fr}{pdftitle={Titre fran\c{c}ais}}
+% \XMPLangAlt{it}{pdftitle={Titolo italiano}}
+% \XMPLangAlt{rm}{pdftitle={Titel rumantsch}}
+% \end{verbatim}
+%
%
% \StopEventually{^^A
% \section{Future Work}
@@ -1095,6 +1145,17 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@pdfsource}
+% Prepare to store the document's source, which defaults to the value of
+% |\jobname|.
+% \changes{v3.3}{2017/07/16}{Added this macro and the corresponding
+% \protect\optname{pdfsource} option, at Niklas Beisert's request}
+% \begin{macrocode}
+\edef\@pdfsource{\jobname.tex}
+\define@key{Hyp}{pdfsource}{\hyxmp@pdfstringdef\@pdfsource{#1}}
+% \end{macrocode}
+% \end{macro}
+%
% The following eight macros---|\@pdfcontactaddress|,
% |\@pdfcontactcity|, |\@pdfcontactregion|, |\@pdfcontactpostcode|,
% |\@pdfcontactcountry|, |\@pdfcontactphone|, |\@pdfcontactemail|, and
@@ -1453,11 +1514,17 @@ provide metadata values to hyperxmp}%
% wrote the document's metadata}
% \changes{v2.0}{2012/08/02}{New \cs{AtBeginDocument} code from Heiko
% Oberdiek to properly encode \cs{@pdfmetalang}}
-% \begin{macrocode}
- \ifx\@pdflang\@empty
- \let\@pdfmetalang=\hyxmp@x@default
- \else
- \edef\@pdfmetalang{\@pdflang}%
+% \changes{v3.3}{2017/07/21}{Don't overwrite an existing
+% \protect\optname{pdfmetalang} with \protect\optname{pdflang} or
+% \protect\texttt{x-default}. This addresses a bug report by Niklas
+% Beisert}
+% \begin{macrocode}
+ \ifx\@pdfmetalang\@empty
+ \ifx\@pdflang\@empty
+ \let\@pdfmetalang=\hyxmp@x@default
+ \else
+ \edef\@pdfmetalang{\@pdflang}%
+ \fi
\fi
\hyxmp@xmlify\@pdfmetalang
% \end{macrocode}
@@ -2486,6 +2553,89 @@ disabled}%
% \end{macro}
%
%
+% \subsubsection{Providing metadata in multiple languages}
+% \label{sec:lang-alt}
+%
+% Certain \acro{XMP} tags---\xmpterm{dc:title},
+% \xmpterm{dc:description}, and \xmpterm{dc:rights} (and others? Let me
+% know.)---can be expressed in multiple languages. The same text is
+% used for both language \optname{pdfmetalang} (default:
+% \optname{pdflang}) and language ``|x-default|''. To express the same
+% metadata in multiple languages, we provide an |\XMPLangAlt| macro to
+% construct a list of alternative forms for a piece of metadata.
+%
+% \begin{macro}{\hyxmp@alt@title}
+% \begin{macro}{\hyxmp@alt@description}
+% \begin{macro}{\hyxmp@alt@rights}
+% Each of these macros is a list in which each element is of the form
+% ``|\do| \meta{language} \meta{text}'' in which \meta{language} is an
+% \acro{ISO} \mbox{639-1} two-letter country code with an optional
+% \acro{ISO} \mbox{3166-1} two-letter region code. For example,
+% |\hyxmp@alt@title| may contain an element, ``|\do| |{es-MX}|
+% |{Este| |es| |mi| |documento}|''.
+% \begin{macrocode}
+\def\hyxmp@alt@title{}
+\def\hyxmp@alt@description{}
+\def\hyxmp@alt@rights{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp@LA@accept}
+% This macro wraps |\define@key| to make the option ``|#1|=\meta{value}''
+% append \meta{value} to list~|#2|.
+% \begin{macrocode}
+\newcommand{\hyxmp@LA@accept}[2]{%
+ \define@key{hyxmp@LA}{#1}{%
+% \end{macrocode}
+% \begin{macro}{\hyxmp@value}
+% As Niklas Beisert observed, if the option passed to the current key
+% contains \LaTeX\ code, this code will be included in the \acro{XMP}
+% packet, which is undesirable. Hence, we first clean up the string
+% using |\hyxmp@pdfstringdef|.
+% \begin{macrocode}
+ \hyxmp@pdfstringdef\hyxmp@value{##1}%
+ \xdef#2{#2\noexpand\do {\hyxmp@cur@lang} {\hyxmp@value}}%
+ }
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Define \meta{key}=\meta{value} options for appending to each of the
+% |\hyxmp@alt|\meta{tag} lists.
+% \begin{macrocode}
+\hyxmp@LA@accept{pdftitle}{\hyxmp@alt@title}
+\hyxmp@LA@accept{pdfsubject}{\hyxmp@alt@description}
+\hyxmp@LA@accept{pdfcopyright}{\hyxmp@alt@rights}
+% \end{macrocode}
+%
+% \begin{macro}{\XMPLangAlt}
+% Argument~|#1| is a language expressed as a two-letter country code and
+% optional two-letter region code. Argument~|#2| is a list of
+% \meta{key}=\meta{value} pairs. Keys correspond to |\hypersetup|
+% options such as ``|pdftitle|'', ``|pdfsubject|'', and
+% ``|pdfcopyright|''. Values are the alternative-language form of the
+% text provided for the corresponding option.
+% \changes{v3.3}{2017/07/22}{Added this macro based on a request---and
+% some code---by Niklas Beisert to support metadata expressed in multiple
+% languages}
+% \begin{macrocode}
+\newcommand{\XMPLangAlt}[2]{%
+ \let\do=\relax
+% \end{macrocode}
+% \begin{macro}{\hyxmp@cur@lang}
+% Store the provided language, which will be used during option processing.
+% \begin{macrocode}
+ \edef\hyxmp@cur@lang{#1}%
+ \setkeys{hyxmp@LA}{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
% \subsection{UUID generation}
% \label{sec:uuid-gen}
%
@@ -2920,6 +3070,9 @@ _________<#1>\hyxmp@xmlified</#1>^^J%
% macro.
% \changes{v1.4}{2011/06/12}{Included metadata in the \texttt{x-default}
% language regardless of the specified metadata language}
+% \changes{v3.3}{2017/07/22}{Bug fix: Output the metadata language as
+% correct \noexpand\acro{XML} even when \noexpand\pkgname{hyperref} is
+% loaded with the \noexpand\optname{unicode} option}
% \begin{macrocode}
\newcommand*{\hyxmp@rdf@dc}[3][\iffalse]{%
% \end{macrocode}
@@ -2939,18 +3092,41 @@ _________<#1>\hyxmp@xmlified</#1>^^J%
% \begin{macrocode}
\if@tempswa
\hyxmp@xmlify{#3}%
+% \end{macrocode}
+% \begin{macro}{\hyxmp@value}
+% Store the \acro{XML}-ified version of |#3| in |\hyxmp@value| so we can
+% reuse |\hyxmp@xmlifiied| if necessary.
+% \begin{macrocode}
+ \let\hyxmp@value=\hyxmp@xmlified
\hyxmp@add@to@xml{%
_________<dc:#2>^^J%
____________<rdf:Alt>^^J%
}%
\ifx\@pdfmetalang\hyxmp@x@default
\else
+ \hyxmp@xmlify{\@pdfmetalang}%
\hyxmp@add@to@xml{%
-_______________<rdf:li xml:lang="\@pdfmetalang">\hyxmp@xmlified</rdf:li>^^J%
+_______________<rdf:li xml:lang="\hyxmp@xmlified">\hyxmp@value</rdf:li>^^J%
}%
\fi
\hyxmp@add@to@xml{%
-_______________<rdf:li xml:lang="\hyxmp@x@default">\hyxmp@xmlified</rdf:li>^^J%
+_______________<rdf:li xml:lang="\hyxmp@x@default">\hyxmp@value</rdf:li>^^J%
+ }%
+% \end{macrocode}
+% Include variants of the text expressed in other languages, as specified by
+% the author using |\XMPLangAlt| (Section~\ref{sec:lang-alt}).
+% \begin{macrocode}
+ \def\do##1##2{
+ \hyxmp@xmlify{##2}%
+ \hyxmp@add@to@xml{%
+_______________<rdf:li xml:lang="##1">\hyxmp@xmlified</rdf:li>^^J%
+ }%
+ }%
+ \csname hyxmp@alt@#2\endcsname
+% \end{macrocode}
+% Complete this \acro{XMP} element.
+% \begin{macrocode}
+ \hyxmp@add@to@xml{%
____________</rdf:Alt>^^J%
_________</dc:#2>^^J%
}%
@@ -2958,6 +3134,7 @@ _________</dc:#2>^^J%
}%
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\hyxmp@list@to@xml}
% Given an optional |\if|\meta{something} statement (|#1|), a Dublin Core
@@ -3048,7 +3225,10 @@ _________<dc:format>application/pdf</dc:format>^^J%
\hyxmp@list@to@xml{date}{Seq}{\hyxmp@today}%
\hyxmp@list@to@xml{language}{Bag}{\@pdflang}%
\hyxmp@list@to@xml{type}{Bag}{\@pdftype}%
- \hyxmp@add@simple{dc:source}{\jobname.tex}%
+ \ifx\@pdfsource\@empty
+ \else
+ \hyxmp@add@simple{dc:source}{\@pdfsource}%
+ \fi
\hyxmp@add@to@xml{%
______</rdf:Description>^^J%
}%