%
% \iffalse meta-comment
%
% metastr.dtx Copyright (C) 2020-2025 Niklas Beisert
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Niklas Beisert.
%
% This work consists of the files metastr.dtx and metastr.ins
% and the derived files metastr.sty and metasamp.tex.
%
%<package|sample>\NeedsTeXFormat{LaTeX2e}[1996/12/01]
%<package>\ProvidesPackage{metastr}[2025/03/25 v1.1.3 Metadata Strings Storage]
%<sample>\ProvidesFile{metasamp.tex}[2025/03/25 v1.1.3 sample for metastr]
%<*driver>
\def\thedate#1{2025/03/25}\def\theversion#1{v1.1.3}
\ProvidesFile{metastr.dtx}[\thedate{} \theversion{} metastr reference manual file]
\PassOptionsToClass{10pt,a4paper}{article}
\documentclass{ltxdoc}

\usepackage[margin=35mm]{geometry}
\usepackage[hyperindex=false]{hyperref}
\usepackage{hyperxmp}
\usepackage[usenames]{color}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{ccicons}
\newcommand{\translate}[1]{\ignorespaces}

\IfFileExists{doclicense.sty}{}{%
  \GenericWarning{please install package `doclicense'}}

\AddToHook{begindocument/before}{\hypersetup{colorlinks=false}}
\hypersetup{urlbordercolor={.5 1 1}}
\hypersetup{linkbordercolor={1 .7 .7}}
\AddToHook{begindocument/before}{\hypersetup{pdfstartview=FitH}}
\hypersetup{keeppdfinfo=true}
\hypersetup{pdfsource={}}
\hypersetup{pdflang={en-UK}}
\hypersetup{pdfurl={https://ctan.org/pkg/metastr}}
\hypersetup{pdfcopyright={Copyright 2020-2025 Niklas Beisert.
  This work may be distributed and/or modified under the
  conditions of the LaTeX Project Public License, either version 1.3
  of this license or (at your option) any later version.}}
\hypersetup{pdflicenseurl={https://www.latex-project.org/lppl.txt}}
\hypersetup{pdfcontactaddress={ETH Zurich, ITP, HIT K,
  Wolfgang-Pauli-Strasse 27}}
\hypersetup{pdfcontactpostcode={8093}}
\hypersetup{pdfcontactcity={Zurich}}
\hypersetup{pdfcontactcountry={Switzerland}}
\hypersetup{pdfcontactemail={nbeisert@itp.phys.ethz.ch}}
\hypersetup{pdfcontacturl={https://people.phys.ethz.ch/\xmptilde nbeisert/}}

\newcommand{\markpkg}[1]{\textsf{#1}}
\newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}}
\newcommand{\ctanref}[2]{\href{https://ctan.org/#1}{#2}}
\newcommand{\ctanpkg}[1]{\ctanref{pkg/#1}{\markpkg{#1}}}

\def\textvert{\texttt{\char"7C}}

\parskip1ex
\parindent0pt
\let\olditemize\itemize
\def\itemize{\olditemize\parskip0pt}

\begin{document}

\title{The \markpkg{metastr} Package}
\hypersetup{pdftitle={The metastr Package}}
\author{Niklas Beisert\\[2ex]
  Institut f\"ur Theoretische Physik\\
  Eidgen\"ossische Technische Hochschule Z\"urich\\
  Wolfgang-Pauli-Strasse 27, 8093 Z\"urich, Switzerland\\[1ex]
  \href{mailto:nbeisert@itp.phys.ethz.ch}
  {\texttt{nbeisert@itp.phys.ethz.ch}}}
\hypersetup{pdfauthor={Niklas Beisert}}
\hypersetup{pdfsubject={Manual for the LaTeX2e Package metastr}}
\date{\thedate{}, \theversion{}\\[1ex]
\url{https://ctan.org/pkg/metastr}}
\maketitle

\begin{abstract}\noindent
\markpkg{metastr} is a \LaTeXe{} package
to store and compose strings in a structured way.
This can serve several purposes such as:
manage and write document metadata;
use templates for formatting document data;
assist in assembling and displaying document license information;
facilitate basic internationalisation and localisation.
\end{abstract}

\begingroup
\parskip0ex
\tableofcontents
\endgroup

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}

This package provides some basic functionality
to store and compose strings.
The main goal is to keep relevant information
for the document in a structured way
such that it can be accessed and used by conveniently
using some standardised methods.

The package has the following goals, tasks and features:
%
\begin{itemize}
\item
manage document metadata and write them to the PDF output file;
\item
set up and use templates for formatting document data, e.g.\ for title pages;
\item
assist in assembling and displaying document license information;
\item
facilitate basic internationalisation and localisation;
\item
provide preset texts and common license statements
in different languages.
\end{itemize}
%
Using the structures provided by the packages makes particular sense
if you can rely on predefined text and formatting or if you have a couple
of similar documents for which you can define suitable templates.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Usage}
\label{sec:usage}

To use the package \ctanpkg{metastr}, add the command
%
\begin{center}
|\usepackage{metastr}|
\end{center}
%
to the preamble of the \LaTeX{} document.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Defining Strings}
\label{sec:def}

\DescribeMacro{\metadef}
\DescribeMacro{\metaset}
The package supplies registers for storing data.
Registers need to be declared before they can be filled or used
(unless the package option |checkdef=false| is set,
see \secref{sec:options}).
A new register \textit{reg} is declared by the command:
%
\begin{center}
|\metadef{|\textit{reg}|}|
\end{center}
%
The register \textit{reg} can be filled
with the value \textit{def}
by the command:
%
\begin{center}
|\metaset{|\textit{reg}|}{|\textit{def}|}|
\end{center}
%

The package declares a couple of registers for storing standard metadata.
The basic set of registers consists of:
%
\begin{center}
\begin{tabular}{ll}
|title| & document title
\\
|subtitle| & document subtitle
\\
|author| & document author
\\
|location| & location associated to the document
\\
|date| & document date
\\
|subject| & `subject' of the document
\\
|keywords| & (a list of) keywords describing the document
\\
|titlematter| & composition register for title matter
\\
|titletext| & composition register for title
\\
|authortext| & composition register for author
\\
|datatext| & composition register for location and date
\end{tabular}
\end{center}
%

The register |titletext| composes information
for printing the title
(such as |title|, |subtitle| but also |author|, |location| and |date|).
It can serve a similar purpose as the \LaTeX{} command |\maketitle|.

Finally, there are some auxiliary registers:
%
\begin{center}
\begin{tabular}{ll}
|language| &
main language of the document
\\
|url| &
URL of the document or additional info on it
\\
|urlmessage| &
message to describe the document URL
\\
|source| &
name of the source file
\\
|draft| &
indicator of draft version
\\
|linebreak| &
expands to linebreak when printed or space otherwise
\end{tabular}
\end{center}
%
The register |language| specifies
the main language used in the document.
This should be a two-letter language code (\textit{ln})
potentially followed by two-letter country code
(\textit{ln}|-|\textit{CN}) such as |en| or |en-GB|.
The language has some impact on selecting
register variants, see \secref{sec:variants} and \secref{sec:language},
it should therefore be set by the command:
%
\begin{center}
|\metasetlang|[|*|]|{|\textit{ln-CN}|}|
\end{center}
%
The starred version declares the language for PDF metadata
rather than the document contents.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Working with Strings}
\label{sec:work}

\DescribeMacro{\metaget}
A register \textit{reg} can be read out by the macro:
%
\begin{center}
|\metaget[]{|\textit{reg}|}{|\textit{def}|}|
\end{center}
%
Note that the (empty) argument in square brackets is mandatory,
it cannot be left out, see \secref{sec:variants}
for further details on its purpose.
This is because |\metaget| must be robust so that its output
can be processed for writing (optional arguments make a macro fragile).
In case the register \textit{reg} has not been filled,
|\metaget| returns nothing.

\DescribeMacro{\metaif}
Sometimes one may want to test whether a register is filled or not,
e.g.\ in order to display a default value otherwise.
This can be achieved by the conditional:
%
\begin{center}
|\metaif[]{|\textit{reg}|}{|\textit{true}|}{|\textit{false}|}|
\end{center}
%
If the register \textit{reg} is filled, return \textit{true}
otherwise \textit{false}.
Again, the argument in square brackets is mandatory.

\DescribeMacro{\metaunset}
The following command cleans a register \textit{reg}
which has previously been filled:
%
\begin{center}
|\metaunset{|\textit{reg}|}|
\end{center}
%
Note that cleaning is different from filling an empty string
when it comes to the conditional |\metaif|
which evaluates true for an empty string but false for a clean register.

\DescribeMacro{\metaappend}
\DescribeMacro{\metaprepend}
\DescribeMacro{\metaaddsep}
The content of registers can be manipulated by some commands.
To append or prepend a string to a register,
use the commands:
%
\begin{center}
\begin{tabular}{l}
|\metaappend{|\textit{reg}|}{|\textit{def}|}|\\
|\metaprepend{|\textit{reg}|}{|\textit{def}|}|\\
|\metaaddsep{|\textit{reg}|}{|\textit{sep}|}{|\textit{def}|}|
\end{tabular}
\end{center}
%
The latter command |\metaaddsep| is designed to compose lists with separators,
it appends the separator \textit{sep}
and the value \textit{def} unless the register is clean,
in which case it is set to \textit{def} without the separator \textit{sep}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{String Variants}
\label{sec:variants}

A versatile feature of the registers is that they can be provided
in several variants.
These variants can be used for producing different representations
of the same register depending on the intended situation.
For example, a title could be given in a fully formatted version
|print| for printing, a bare version for metadata
and a shortened version for headings.
Similarly, translations to different languages
could be stored as different versions of the same register,
see \secref{sec:language}.
Moreover, certain attributes related to the registers
could be stored in additional variants.

\DescribeMacro{titletext}
For example, the register |titletext| exists in
the default variant (mainly intended for writing out metadata)
and the |print| variant
(for printing out a combination of title data on the title page).
The default variant expands to a combination
of |draft|, |title| and |subtitle|
(as far as filled):
%
\begin{center}
[\textit{draft}: ]\textit{title}[ -- \textit{subtitle}]
\end{center}
%
The |print| variant is accessed by the command:
%
\begin{center}
|\metapick[print]{titletext}|
\end{center}
%
It expands to two lines containing |title| and |subtitle| + |draft|
(as far as filled):
%
\begin{center}
\textit{title}\\
\textit{subtitle} |\par| \textit{draft}
\end{center}
%
In fact, the legacy behaviour of |titletext|
also adds two lines containing |author| and |location| + |date|,
as in the new composition register |titlematter| to be explained below;
this behaviour needs to be disabled explicitly
for purposes of backwards compatibility
by the package option |titlematter|.
The formatting style of each line is given
by the variant |style| of the first register on this line;
the vertical space above each line is
produced by the variant |skip|.
Two items on a single line are separated by the variant |sep|
of the second register;
an unfilled |sep| variant puts the two items on individual lines
(by default this applies to |subtitle| and |draft|).

\DescribeMacro{titlematter}
The composition register |titlematter| (in |print| variant):
%
\begin{center}
|\metapick[print]{titlematter}|
\end{center}
%
collects extended information
on the documents for display on the title page
(it substitutes the \LaTeX{} command |\maketitle| in the class \textsf{article}
whose display it mimics):
%
\begin{center}
\textit{title}\\
\textit{subtitle} |\par| \textit{draft}\\
\textit{author}\\
\textit{location}, \textit{date}
\end{center}
%
By adjusting the definitions,
the layout of the title display on the title page
can be adjusted conveniently.

Variants are always specified by an argument |[|\textit{var}|]|
in square brackets preceding the register |{|\textit{reg}|}|.
This argument is optional for commands
which set registers and which can be fragile;
it is however \emph{mandatory} for macros which read
the register content and whose output needs to be expandable
into the output stream
(even though the register is not optional,
it is more uniform to stick with square brackets to specify the variant).
The main declaration involving variants is:
%
\begin{center}
|\metaset[|\textit{var}|]{|\textit{reg}|}{|\textit{def}|}|
\end{center}
%
This command defines the register \textit{reg} in variant \textit{var}
as \textit{def}.
The default variant is the empty string,
while the variant |print| is intended for printed output.
The variant string is obtained by:
%
\begin{center}
|\metaget[|\textit{var}|]{|\textit{reg}|}|
\end{center}

\DescribeMacro{\metapick}
The variant mechanism can become powerful
through macros which fall back to default variants
if the desired variant has not been filled explicitly:
%
\begin{center}
|\metapick[|\textit{var}|]{|\textit{reg}|}|
\end{center}
%
This macro tests whether the variant \textit{var},
the language variant \textit{ln}
specified through |\metasetlang{|\textit{ln}|}|,
the generic (empty) variant
or a fallback language variant have been specified.
If so, their value is returned (in this order of preference).
Importantly, the intended variant \textit{var} is passed along
to the evaluation of \textit{reg} as the argument `|#1|' in
the definition string \textit{def} of |\metaset|.
This allows to define a register in one generic variant
which composes other registers in more specific variants.
To that end reference registers should be accessed by the construct:
%
\begin{center}
|\metaset{|\textit{reg1}|}{|\ldots|\metapick[#1]{|\textit{reg2}|}|\ldots|}|
\end{center}
%
When this register is accessed by
|\metapick[|\textit{var}|]{|\textit{reg1}|}|,
it will read the default variant of \textit{reg1}
which will pass on to \textit{reg2} in \textit{var}
(rather than in the default variant).
A useful application within title declarations
is |\metapick[#1]{linebreak}| which expands to a line break
when the title is displayed and to a space when the title is used elsewhere.

\DescribeMacro{\metaifpick}
\DescribeMacro{\metacompose}
There also exist a corresponding conditional:
%
\begin{center}
|\metaifpick[|\textit{var}|]{|\textit{reg}|}|%
  |{|\textit{true}|}{|\textit{false}|}|
\end{center}
%
This command tests whether any of the above variants \textit{var}
have been filled.
Another convenient macro to more efficiently compose strings is:
%
\begin{center}
|\metacompose[|\textit{var}|]{|\textit{reg}|}|%
  |{|\textit{prefix}|}{|\textit{postfix}|}{|\textit{empty}|}|
\end{center}
%
It returns the intended register value with prefix string \textit{prefix}
and suffix string \textit{suffix} if any of the above variants
have been filled; otherwise it returns \textit{empty}.
For example, the prefix and/or suffix could be separators for
displaying the content of an optional register.

In dealing with variants,
the following commands specify the variant \textit{var}
as an optional argument |[|\textit{var}|]|:
%
\begin{center}
\begin{tabular}{l}
|\metaset[|\textit{var}|]{|\textit{reg}|}{|\textit{def}|}|\\
|\metaunset[|\textit{var}|]{|\textit{reg}|}|\\
|\metaappend[|\textit{var}|]{|\textit{reg}|}{|\textit{def}|}|\\
|\metaprepend[|\textit{var}|]{|\textit{reg}|}{|\textit{def}|}|\\
|\metaaddsep[|\textit{var}|]{|\textit{reg}|}{|\textit{sep}|}{|\textit{def}|}|
\end{tabular}
\end{center}
%
For the following macros, specifying the variant \textit{var}
as |[|\textit{var}|]| is \emph{mandatory}:
%
\begin{center}
|\metaget[|\textit{var}|]{|\textit{reg}|}|\\
|\metapick[|\textit{var}|]{|\textit{reg}|}|\\
|\metaifpick[|\textit{var}|]{|\textit{reg}|}|%
  |{|\textit{true}|}{|\textit{false}|}|\\
|\metacompose[|\textit{var}|]{|\textit{reg}|}|%
  |{|\textit{prefix}|}{|\textit{postfix}|}|
\end{center}
%
Here, the default variant is accessed by an empty argument \textit{var}.

\DescribeMacro{titletext}
\DescribeMacro{\metatitleline}
\DescribeMacro{\metatitlelinetwo}
To illustrate a construction using variants,
let us consider the above register |titletext|
(with activated package option |titlematter|).
It is defined in the generic variant as:
%
\begin{center}
\begin{tabular}{l}
|\metaset{titletext}{%|\\
|  \metacompose[#1]{draft}{}{\metaget[sep]{draft}}{}%|\\
|  \metapick[#1]{title}%|\\
|  \metacompose[#1]{subtitle}{\metaget[sep]{subtitle}}{}{}}|
\end{tabular}
\end{center}
%
This expands to the prefix `\textit{draft}: ' (if available),
the main title `\textit{title}'
and the suffix ` -- \textit{subtitle}' (if available).
The |print| variant to output a full title for the document is defined by:
%
\begin{center}
\begin{tabular}{l}
|\metaset[print]{titletext}{%|\\
|  \metatitleline[print]{title}%|\\
|  \metatitlelinetwo[print]{subtitle}[print]{draft}|
\end{tabular}
\end{center}
%
Here, the macros |\metatitleline|[|two|] produce a title line
consisting of one or two items.
The single-item version is defined as:
%
\begin{center}
\begin{tabular}{l}
|\def\metatitleline[#1]#2{%|\\
|  \metacompose[#1]{#2}|\\
|   {\metaget[skip]{#2}\begingroup\metaget[style]{#2}}|\\
|   {\par\endgroup}{}}|
\end{tabular}
\end{center}
%
If register |#2| is filled,
this expands to the vertical skip defined by the variant |skip|
and an encapsulated paragraph of the register value
in the layout defined by the variant |style|.

\DescribeMacro{authortext}
\DescribeMacro{datetext}
\DescribeMacro{titlematter}
The composition registers |authortext| and |datetext| work in
a similar fashion as |titletext| and compose
the registers |author| and |location| + |date|, respectively.
The composition register |titlematter| (in variant |print|)
prints out the title, author and date information
and serves a similar purpose as the \LaTeX{} command |\maketitle|:
%
\begin{center}
\begin{tabular}{l}
|\metaset{titlematter}{%|\\
|  \metapick[#1]{titletext}%|\\
|  \metapick[#1]{authortext}%|\\
|  \metapick[#1]{datatext}%|\\
|  \metaget[skip]{titlematter}}|
\end{tabular}
\end{center}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Write Document Metadata}
\label{sec:meta}

The contents of certain registers can be written out to
PDF files as metadata using the package \ctanpkg{hyperref}
and the extension \ctanpkg{hyperxmp}.

\DescribeMacro{\metawritepdfinfo}
The basic metadata registers are written out by |\metawritepdfinfo|
using \ctanpkg{hyperref}.
The mapping between \ctanpkg{metastr} registers
and \ctanpkg{hyperref} |\hypersetup| options is given by:
%
\begin{center}
\begin{tabular}{l@{\quad$\to$\quad}l}
|titletext| & |pdftitle|
\\
|authortext| & |pdfauthor|
\\
|subject| & |pdfsubject|
\\
|keywords| & |pdfkeywords|
\end{tabular}
\end{center}
%
Here, |titletext| is used instead of |title| to compose information
from the registers |draft|, |title| and |subtitle| (as far as filled).
Similarly, |authortext| composes information on the author,
typically just |author|.
Note that |\metawritepdfinfo| will be effective
only when invoked before the contents of the first page are written out.

\DescribeMacro{\metawritepdfaux}
Auxiliary metadata is written out using \ctanpkg{hyperxmp}
by the command |\metawritepdfaux| with the mapping:
%
\begin{center}
\begin{tabular}{l@{\quad$\to$\quad}l}
|url| & |pdfurl|
\\
|source| & |pdfsource|
\end{tabular}
\end{center}

\DescribeMacro{\metawritepdfpreamble}
Some metadata must be written out sufficiently early,
i.e.\ in the document preamble, in order to go into effect.
These include the language settings,
and they are written out by |\metawritepdfpreamble|
with the mapping:
%
\begin{center}
\begin{tabular}{l@{\quad$\to$\quad}l}
|language| & |pdflang|
\\
|language| variant |[meta]| & |pdfmetalang|
\\
 & |keeppdfinfo|
\end{tabular}
\end{center}
%
Note that |pdfmetalang| is a setting of \ctanpkg{hyperxmp}
and will be ignored if the package is not loaded.
Furthermore, the \ctanpkg{hyperxmp} option |keeppdfinfo|
will be set unless the package option |xmppdfinfo=false| is set.

\DescribeMacro{\metawritepdfcontact}
A contact can be specified within PDF files
in a standardised format using \ctanpkg{hyperxmp}.
The command |\metawritepdfcontact| passes on the following
registers with the mapping:
%
\begin{center}
\begin{tabular}{l@{\quad$\to$\quad}l}
|contactaddress| & |pdfcontactaddress|
\\
|contactpostcode| & |pdfcontactpostcode|
\\
|contactcity| & |pdfcontactcity|
\\
|contactregion| & |pdfcontactregion|
\\
|contactcountry| & |pdfcontactcountry|
\\
|contactemail| & |pdfcontactemail|
\\
|contacturl| & |pdfcontacturl|
\end{tabular}
\end{center}

\DescribeMacro{\metawritepdfrights}
A document copyright statement, see \secref{sec:rights},
is recorded within the PDF file by |\metawritepdfrights|
using \ctanpkg{hyperxmp} with the mapping:
%
\begin{center}
\begin{tabular}{l@{\quad$\to$\quad}l}
|rightstext| & |pdfcopyright|
\\
|licenseurl| & |pdflicenseurl|
\end{tabular}
\end{center}
%

\DescribeMacro{\metawritepdf}
\DescribeMacro{writepdf}
Finally, it makes sense to write out PDF metadata automatically.
This is controlled by filling or clearing certain variants \textit{var}
of the register |writepdf|:
%
\begin{center}
\begin{tabular}{rl}
&|\metaset[|\textit{var}|]{writepdf}{}|\\
or&|\metaunset[|\textit{var}|]{writepdf}|
\end{tabular}
\end{center}
%
If the variant |auto| is filled (default),
PDF metadata is written automatically
at the beginning of the |document| block
by calling |\metawritepdf|.
The command |\metawritepdf| calls
the commands |\metawritepdf|\ldots{}
depending on whether the variants |info|, |aux|, |preamble|,
|contact|, |rights| of the register |writepdf| are filled;
the variants |info|, |aux|, |preamble| are enabled by default,
the variants |contact|, |rights| need to be enabled explicitly.

Note that the basic metadata such as |author| and |title|
do not have to be defined already in the preamble,
but (depending on the combination of drivers and packages)
they can be set before the contents of the first page
are shipped out to the PDF file.
If the basic registers are to be declared on the first page,
one should disable their automatic writing by
|\metaunset[info]{writepdf}|.
When the corresponding registers have been filled,
(but no later than the end of the first page),
they need to be written manually
by invoking |\metawritepdfinfo|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Copyright and Licenses}
\label{sec:rights}

Specifying a copyright statement and a license is very useful because it
makes the allowed (re)use of the provided material evident to the reader.
However, it also takes some efforts to set things up properly.
The package \ctanpkg{metastr} provides some default texts to
state the license for a couple of well-established licenses.
For instance, the set of Creative Commons licenses has become a standard
to mark the intended (re)use of a document involving creative content.
For documents related to software, there is a number of
standard software licenses to choose from.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Registers.}

The package declares the following registers to state the copyright:
%
\begin{center}
\begin{tabular}{ll}
|copyrightmark| & `\copyright' (|print| variant) or ``Copyright''
\\
|copyrightdate| & copyright date
\\
|copyrightowner| & copyright owner
\\
|copyrightstatement| & combines:
|...mark| + |...date| + |...owner|
\\
|copyrightmessage| & a message explaining the copyright situation
\end{tabular}
\end{center}
%
The package declares the following registers to state the license:
%
\begin{center}
\begin{tabular}{ll}
|licensemessage| & licensing message
\\
|licenseprovider| & license provider
\\
|licenseversion| & license version
\\
|licenselogo| & license logo inclusion
\\
|licenselogomessage| & display the license logo
\\
|licenseurl| & URL with license text and details
\\
|licenseurlmessage| & display the license URL
\end{tabular}
\end{center}
%
Furthermore, there are some related auxiliary registers:
%
\begin{center}
\begin{tabular}{ll}
|partof| & specifies the work this document is a part of
\\
|partofmessage| & a message declaring being part of
\\
|attributionmessage| & a message declaring attributions
\\
|rightstext| & a composition template for all of the above
\end{tabular}
\end{center}
%
The above information is compiled automatically in the register |rightstext|.
It can be written as PDF metadata
as well as printed with formatting:
%
\begin{center}
|\metapick[print]{rightstext}|
\end{center}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Presets.}

The package provides a couple of presets
for commonly used copyright statements and licenses.
These are selected by:
%
\begin{center}
\begin{tabular}{l}
|\metacopyright{|\textit{preset}|}|\\
|\metalicense{|\textit{preset}|}|
\end{tabular}
\end{center}
%
The following \textit{preset} values
provide the associated copyright statements:
%
\begin{center}
\begin{tabular}{ll}
|plain| & This work is protected by copyright.
\\
|parts| & This work as well as its parts is protected by copyright.
\\
|doc| & This document is protected by copyright.
\\
|doc-parts| & This document as well as its parts is protected by copyright.
\\
|reserved| & All rights reserved.
\\
|publicdomain| & This work is dedicated to the public domain.
\end{tabular}
\end{center}
%
The following \textit{preset} values
provide the associated license statements:
%
\begin{center}
\begin{tabular}{ll}
|consent| &
\parbox[t]{0.75\textwidth}{\raggedright
  Reproduction of any part of this work in any form
  without prior written consent
  \textit{of the author}
  is not permissible.
}
\\
\vphantom{$\hat A$}%
|consent-noncom| &
\parbox[t]{0.75\textwidth}{\raggedright
  Reproduction of any part of this work in any form
  without prior written consent
  \textit{of the author}
  is permissible only for private, scientific and non-commercial use.
  \vphantom{g}}
\\
\vphantom{$\hat A$}%
|lppl| &
\parbox[t]{0.75\textwidth}{\raggedright
  This work may be distributed and/or modified under the
  conditions of the LaTeX Project Public License, either version \textit{1.3}
  of this license or (at your option) any later version.\\
  \url{https://www.latex-project.org/lppl.txt}
}
\end{tabular}
\end{center}
%
The license URL will be selected where available.
The italicised parts of the license statement can be customised
by the registers |licenseversion| and |licenseprovider|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Creative Commons Licenses.}

A Creative Commons license can be selected by the command:
%
\begin{center}
|\metalicensecc{|\textit{license}|}|
\end{center}
%
The parameter \textit{license} specifies the type of CC license:
%
\begin{center}
\begin{tabular}{ll}
|by| & Attribution \\
|by-sa| & Attribution-ShareAlike \\
|by-nd| & Attribution-NoDerivatives \\
|by-nc| & Attribution-NonCommercial \\
|by-nc-sa| & Attribution-NonCommercial-ShareAlike \\
|by-nc-nd| & Attribution-NonCommercial-NoDerivatives \\
|zero| & CC0 public domain declaration \\
|pd| & generic public domain declaration
\end{tabular}
\end{center}
%
The appropriate license URL and CC logo is selected
by the command as well, e.g.
%
\begin{center}
\includegraphics{doclicense-CC-by-sa-88x31}\\
\url{https://creativecommons.org/licenses/by-sa/4.0/}
\end{center}
%
Note that |pd| is not a CC license, but it declares
that the document is in the public domain by
|\metacopyright{publicdomain}|
and it selects the corresponding CC logo for public domain content.

A version of the CC license can be specified by
the register |licenseversion|.
The default version is |4.0| (international), further available versions are
|3.0| (unported) as well as |2.5|, |2.0|, |1.0| (generic).
For the CC0 license |zero|, the only available version is |1.0| (universal)
which is the default.

Displaying the logo requires (manual) loading
of the package \ctanpkg{graphicx};
furthermore the package \ctanpkg{doclicense} containing the logo files
must be present.
The display of the logo can be disabled by the package option |cclogo=false|.
The logo display is coded by the following definitions
which can be customised:
%
\begin{center}
\begin{tabular}{l}
|\metaset[print]{licenselogomessage}{%|\\
|  \centerline{\metapick[#1]{licenselogo}}}|\\
|\metaset[cmd]{licenselogo}{\includegraphics{#1}}|
\end{tabular}
\end{center}

Various registers and variants of the selected CC license exist.
The registers specific to CC licenses are:
%
\begin{center}
\begin{tabular}{ll}
|licencecc| & CC license identifier
\\
|licenceccver| & CC license version
\\
|licenceccfull| & full license descriptor
\end{tabular}
\end{center}
%
The variants specific to CC licenses are:
%
\begin{center}
\begin{tabular}{ll}
\textit{ln} & representation in language \textit{ln}
\\
|icon| & CC icon (package \ctanpkg{ccicons} required),
e.g. \ccLogo\ccAttribution\ccShareAlike
\\
|url| & license URL
\\
|ident| & CC identifier, e.g.\ `BY-SA'
\\
|short| & short form, e.g.\ `CC BY-SA'
\\
|logo| & logo filename (package \ctanpkg{doclicense})
\end{tabular}
\end{center}
%
For example, a full license descriptor is displayed by
|\metapick[]{licenseccfull}|:
Creative Commons License ``Attribution-ShareAlike 4.0 International''.
The license icon can be displayed by
|\metaget[icon]{licensecc}|: \ccLogo\ccAttribution\ccShareAlike{}
(this requires the package \ctanpkg{ccicons} to be loaded).
Note that displaying the full license message |licensemessage|
in variant |print| in some languages
may produce quotation marks not declared in default fonts
causing an error; this can be avoided to some extent by
loading an appropriate packages for internationalisation
such as \ctanpkg{babel}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Languages}
\label{sec:language}

A principal application of the register variants is to
implement internationalisation and localisation.
Evidently, this is a tricky subject
due to various particularities of languages,
but the register variants can be used
to specify and select different language representations
for some commonly used text elements.
For example, the copyright and license statements in \secref{sec:rights}
are internationalised (to some extent).
This makes them conveniently usable in the appropriate language.
Note that the language presets to be loaded
need to be specified explicitly by the package option |loadlang|,
see \secref{sec:options}.

The idea is to understand the variant \textit{var}
of a register \textit{reg} to be its representation in the language
\textit{var}=\textit{ln}[|-|\textit{CN}].
The default (empty) variant as well as specific purpose variants
(such as |print|) should be provided in the
document language or a fallback language (such as English).
The macro |\metapick[|\textit{var}|]{|\textit{reg}|}|
then selects the appropriate language representation
or falls back to the default language.
Here \textit{var} can specify a particular language or a particular purpose.
Then, |\metapick| will pick (in this order of preference):
%
\begin{itemize}
\item
the language or purpose \textit{var},
\item
the document language specified by |\metasetlang| (if available),
\item
the document language specified by |\metasetlang|
with country code stripped (if available),
\item
the default variant,
\item
the fallback language (first of package option |loadlang|).
\end{itemize}
%
Note that nesting of |\metapick|
via |\metapick[#1]{|\textit{reg}|}|
passes along the original variant
\textit{var} in the parameter |#1|.
This mechanism allows to specify some non-specific elements
in a universal language while the appropriate language is
selected where available.

\macro{\metaterm}
\macro{\metatranslate}
\macro{\metasetterm}
The package reserves registers of the form |term-|\textit{term}
for storing terms in various (language) representations.
A couple of such term registers describing common entities in typesetting
are defined by the package:
%
\begin{center}
\begin{tabular}[t]{ll}
|title|&Title\\
|abstract|&Abstract\\
|copyright|&Copyright\\
|preface|&Preface\\
|part|&Part\\
|chapter|&Chapter\\
|section|&Section\\
|subsection|&Subsection\\
|paragraph|&Paragraph
\end{tabular}
\qquad\qquad
\begin{tabular}[t]{ll}
|appendix|&Appendix\\
|page|&Page\\
|figure|&Figure\\
|table|&Table\\
|contents|&Contents\\
|listfigure|&List of Figures\\
|listtable|&List of Tables\\
|references|&References\\
|index|&Index\\
|draft|&DRAFT
\end{tabular}
\end{center}
%
These are provided in different languages for convenient
internationalisation
(this can be viewed as a low-key implementation of some of the features
of the \ctanpkg{babel} package).
Additional term registers can be defined by the user.
Term registers are accessed by the macros:
%
\begin{center}
\begin{tabular}{l}
|\metaterm{|\textit{term}|}|\\
|\metatranslate[|\textit{ln}|]{|\textit{term}|}|\\
|\metasetterm[|\textit{ln}|]{|\textit{reg}|}{|\textit{def}|}|
\end{tabular}
\end{center}
%
The macro |\metaterm| obtains the term \textit{term}
in the default language
(it invokes |\metapick[]| with empty variant),
while |\metatranslate| uses any other language \textit{ln}.
The macro |\metasetterm| declares and fills a term register \textit{term}
(in a particular language \textit{ln}).
Note that therefore it is not necessary to declare term registers
explicitly by |\metadef|.

The PDF metadata are written out in the metadata language variant
specified by |\metasetlang*|;
otherwise in the default document language
specified by |\metasetlang| is used.
Some registers can even be written out
in several alternative language versions
using the package \ctanpkg{hyperxmp},
namely |title|, |subject| and |rightstext|.
The set of alternative languages is specified by
(before invoking the respective command |\metawritepdf...|):
%
\begin{center}
\begin{tabular}{l}
|\metaset[altlang]{title}{|\textit{languages}|}|\\
|\metaset[altlang]{subject}{|\textit{languages}|}|\\
|\metaset[altlang]{rightstext}{|\textit{languages}|}|
\end{tabular}
\end{center}
%
Here, \textit{languages} is a comma-separated list of language identifiers
and for each identifier \textit{ln}
the information is written out in the respective language variant.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Package Options}
\label{sec:options}

General options for the package can be selected by the commands:
%
\begin{center}
\begin{tabular}{rl}
&|\usepackage[|\textit{opts}|]{metastr}|
\\
or&|\PassOptionsToPackage{|\textit{opts}|}{metastr}|
\end{tabular}
\end{center}
%
|\PassOptionsToPackage| must be used before |\usepackage|.
\textit{opts} is a comma-separated list of options.

The following options are available:
%
\begin{itemize}
\item |hyperref|[|=true|\textbar|false|]
(no value implies |true|, initially set to |true|) --
use the package \ctanpkg{hyperref} to write metadata to PDF.
\item |hyperxmp|[|=true|\textbar|false|]
(no value implies |true|, initially set to |true|) --
use the auxiliary package \ctanpkg{hyperxmp}
to write additional metadata to PDF.
\item |checkdef|[|=true|\textbar|false|]
(no value implies |true|, initially set to |true|) --
check whether registers have been previously declared
when filling them.
\item |cclogo|[|=true|\textbar|false|]
(no value implies |true|, initially set to |true|) --
display CC logo from \ctanpkg{doclicense} package.
\item |cclogocurr=dollar|\textbar|euro|\textbar|yen|
(initially set to |dollar|) --
select currency symbol for Creative Commons NonCommercial logos.
\item |cclogoshape=box|\textbar|slim|
(initially set to |box|) --
select shape of Creative Commons NonCommercial logos.
\item |xmppdfinfo|[|=true|\textbar|false|]
(no value implies |true|, initially set to |true|) --
write the basic PDF info block
when using the auxiliary package \ctanpkg{hyperxmp};
if this option is set,
\ctanpkg{hyperxmp} is loaded with the option |keeppdfinfo|.
\item |draft|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
fill |draft| register with ``DRAFT''.
\item |titlematter|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
when set to |true|, composition register |titletext|
prints only the title; when set to |false|,
|titletext| also prints authorship, location and date information
(legacy behaviour).
\item |course|[|=true|\textbar|false|]
(no value implies |true|, initially set to |false|) --
Setup extended registers for course materials, see \secref{sec:extras}.
\item |loadlang=|\textit{ln-1}\texttt{\textbar}\textit{ln-2}%
  \texttt{\textbar}|...|\texttt{\textbar}\textit{ln-n}
(bar-separated list w/o spaces, initially set to |en|) --
Load presets for languages \textit{ln-1}, \textit{ln-2}, \ldots, \textit{ln-n},
see \secref{sec:language}.
The first language \textit{ln-1} serves as the fallback variant.
Available internationalisations currently consist of:
\begin{center}
\begin{tabular}{ll}
|en|& English\\
|de|& German\\
|fr|& French\\
|es|& Spanish
\end{tabular}
\end{center}
\end{itemize}
%

Selected package options can be adjusted after the package
has been loaded by the command:
%
\begin{center}
|\metasetup{|\textit{opts}|}|
\end{center}
%
Presently, only |draft| can be adjusted.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Extras}
\label{sec:extras}

The package can provide some special purpose registers on request.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Course Materials.}

A couple of registers for course materials are provided
upon setting the package option |course|:
%
\begin{center}
\begin{tabular}{ll}
|course| & title of course
\\
|material| & description of document material
\\
|period| & period where course takes place
\\
|institution| & institution where course is given
\\
|instructor| & instructor of course
\end{tabular}
\end{center}
%

The variant |course| of the register |titlematter| (or |titletext|)
displays a compilation of these registers for display on a title page:
%
\begin{center}
\textit{course}\\
\textit{material} |\par| \textit{draft}\\
\textit{institution}, \textit{period}\\
\textit{instructor}
\end{center}
%
Furthermore, the registers
|title|, |subtitle|, |author|, |location| and |date| are
diverted to |course|, |material|, |instructor|,
|institution| and |period| respectively.
Consequently, their values are automatically written as PDF metadata,
but it is certainly possible to override them with custom values.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Information}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Copyright}

Copyright \copyright{} 2020 Niklas Beisert

This work may be distributed and/or modified under the
conditions of the \LaTeX{} Project Public License, either version 1.3
of this license or (at your option) any later version.
The latest version of this license is in
  \url{https://www.latex-project.org/lppl.txt}
and version 1.3c or later is part of all distributions of \LaTeX{}
version 2008 or later.

This work has the LPPL maintenance status `maintained'.

The Current Maintainer of this work is Niklas Beisert.

This work consists of the files |README.txt|, |metastr.ins| and |metastr.dtx|
as well as the derived files |metastr.sty|, |metasamp.tex| and |metastr.pdf|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Files and Installation}

The package consists of the files:
%
\begin{center}
\begin{tabular}{ll}
    |README.txt|   & readme file \\
    |metastr.ins|  & installation file \\
    |metastr.dtx|  & source file \\
    |metastr.sty|  & package file \\
    |metasamp.tex| & sample file \\
    |metastr.pdf|  & manual
\end{tabular}
\end{center}
%
The distribution consists of the files
|README.txt|, |metastr.ins| and |metastr.dtx|.
%
\begin{itemize}
\item
Run (pdf)\LaTeX{} on |metastr.dtx|
to compile the manual |metastr.pdf| (this file).
\item
Run \LaTeX{} on |metastr.ins| to create the package |metastr.sty|
and the samples consisting of |metasamp.tex|.
Copy the file |metastr.sty| to an appropriate directory of your \LaTeX{}
distribution, e.g.\ \textit{texmf-root}|/tex/latex/metastr|.
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Related Packages}

The package makes use of other packages available at CTAN:
\begin{itemize}
\item
This package uses the package
\ctanpkg{hyperref}
to write basic metadata to a PDF file.
Compatibility with the \ctanpkg{hyperref} package
has been tested with v7.00c (2019/11/10).
\item
This package uses the package \ctanpkg{keyval}
from the \ctanpkg{graphics} bundle
to process the options for the package, environments and macros.
Compatibility with the \ctanpkg{keyval} package
has been tested with v1.15 (2014/10/28).
\item
This package can use the package \ctanpkg{hyperxmp}
to write extended metadata to a PDF file.
Compatibility with the \ctanpkg{hyperxmp} package
has been tested with v5.4 (2020/06/19).
\item
This package can use the Creative Commons license icon files
included in the package \ctanpkg{doclicense}.
Compatibility with the \ctanpkg{doclicense} package
has been tested with v2.0.1 (2020/06/26).
\item
This package can use the Creative Commons license icon fonts
included in the package \ctanpkg{ccicons}.
Compatibility with the \ctanpkg{ccicons} package
has been tested with v1.6 (2017/10/30).
\item
Icon files are displayed by means of the \ctanpkg{graphicx} package.
The package needs to be loaded explicitly.
Compatibility with the \ctanpkg{graphicx} package
has been tested with v1.1a (2017/06/01).
\end{itemize}

There are several other \LaTeX{} packages
which store and write basic metadata
for some specific purposes:
%
\begin{itemize}
\item
The package \ctanpkg{hyperref}
writes the arguments of |\author| and |\title|
unless the package option |pdfusetitle=false| is declared (at load time).
\item
The package \ctanpkg{hyperxmp}
writes the arguments of |\author| and |\title|.
\item
The package \ctanpkg{exframe}
writes the |\exercisedata| registers
|author|, |title|, |subject| and |keyword|
unless the package option |pdfdata=off| is specified.
\item
The package \ctanpkg{beamer}
writes the arguments of |\author|, |\title|, |\subject| and |\keywords|.
\item
The package \ctanpkg{gitver}
writes |pdfsubject| unless the package option |nopdfinfo| is specified.
\item
Various packages to prepare articles for publication in journals.
\end{itemize}
%
Their mechanisms may be in competition
with the ones of the present package \ctanpkg{metastr}.
In order to make the packages work together on the same set of data,
the most promising option which should work in many cases is the following:
Fill the registers of \ctanpkg{metastr}
with the desired values.
Then pass them on to the structures
of the other package(s) using |\metaget| or |\metapick|.
Since the latter commands are robust,
the other structures ought to be able to handle them without further ado.
To avoid potential conflicts, multiple writing of (basic) metadata
should be disabled. For the \ctanpkg{metastr} package this is achived by:
%
\begin{center}
\begin{tabular}{rl}
&|\metaunset[info]{writepdf}|\\
or&|\metaunset[auto]{writepdf}|
\end{tabular}
\end{center}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Feature Suggestions}
\label{sec:suggestions}

The following is a list of features which may be useful for future
versions of this package:
%
\begin{itemize}
\item
Presets for GNU and other software licenses.
\item
Registers for publication data.
% editor, preprint, doi, publisher, publication, (volume, page), version ...
\item
Further translations of copyright and license statements.
\item
Export translations to files
\item
Make use of the \ctanpkg{babel} package for translations of basic terms.
% load babel when not only en?
%\item
%title translations via titletext?
%\item
%perhaps use \ctanpkg{xparse} to generate robust commands for optional variants
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Revision History}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\iffalse
\paragraph{vN.N.N+:} 20YY/MM/NN

\begin{itemize}
\item
\ldots
\end{itemize}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.1.3:} 2025/03/25

\begin{itemize}
\item
maintenance and manual update
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.1.2:} 2020/09/02

\begin{itemize}
\item
improve hook processing to set |pdflang| at the right moment
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.1.1:} 2020/08/27

\begin{itemize}
\item
introduce |skip| variant for |titlematter| register
\item
adjust hook to new \LaTeXe\ (2020-10) hook processing
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.1:} 2020/06/28

\begin{itemize}
\item
|\metasetup| to adjust some package options (|draft|)
\item
|titlematter|, |authortext|, |datatext| composition registers added;
legacy behaviour of |titletext| preserved,
can be changed by package option |titlematter|
\item
|linebreak| register added
\item
fix saving of PDF info (|keeppdfinfo|) with updated \ctanpkg{hyperxmp} package
\item
fix package options |hyperref|, |hyperxmp|, |checkdef|, |xmppdfinfo|
\item
fix compatibility with updated \ctanpkg{doclicense} package (v2)
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.0:} 2020/02/06

\begin{itemize}
\item
first version, published on CTAN
\end{itemize}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\appendix

\settowidth\MacroIndent{\rmfamily\scriptsize 0000\ }

 \DocInput{metastr.dtx}

\end{document}
%</driver>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Sample}
% \label{sec:sample}
%\iffalse
%<*sample>
%\fi
%
% This section provides an example of how to apply
% some of the \ctanpkg{metastr} mechanisms and licenses.
%
% Some lines in the example are commented by |%%| for easy experimenting.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Preamble.}
%
% Standard document class:
%    \begin{macrocode}
\documentclass[12pt]{article}
%    \end{macrocode}

% Use package \ctanpkg{geometry} to set the page layout;
% adjust the paragraph shape:
%    \begin{macrocode}
\usepackage{geometry}
\geometry{layout=a4paper}
\geometry{paper=a4paper}
\geometry{margin=2.5cm}
\parindent0pt
\parskip1ex
%    \end{macrocode}

% Declare some options for the package \ctanpkg{hyperref};
% it does not hurt to load it explicitly
% although \ctanpkg{metastr} will invoke it by default if not loaded:
%    \begin{macrocode}
\PassOptionsToPackage{bookmarks=true}{hyperref}
\usepackage{hyperref}
%    \end{macrocode}

% Set some options for the \ctanpkg{metastr} package:
%    \begin{macrocode}
\PassOptionsToPackage{loadlang=en|de|fr|es}{metastr}
%%\PassOptionsToPackage{loadlang=en|fr|es}{metastr}
%%\PassOptionsToPackage{loadlang=de|en}{metastr}
\PassOptionsToPackage{cclogocurr=euro}{metastr}
%%\PassOptionsToPackage{cclogoshape=slim}{metastr}
%    \end{macrocode}

% Include the \ctanpkg{metastr} package along with
% \ctanpkg{graphicx}, \ctanpkg{babel}
% and \ctanpkg{ccicons} (where available):
%    \begin{macrocode}
\usepackage[titlematter]{metastr}
\usepackage{graphicx}
\usepackage[english]{babel}
\IfFileExists{ccicons.sty}{\usepackage{ccicons}}{}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Some Adjustments.}
%
% Declare some term to be translated;
% doesn't hurt to declare a couple of variants:
%    \begin{macrocode}
\metasetterm[en]{Zurich}{Zurich}
\metasetterm[de]{Zurich}{Z\"rich}
\metasetterm[fr]{Zurich}{Zurich}
\metasetterm[es]{Zurich}{Z\'urich}
\metasetterm[it]{Zurich}{Zurigo}
\metasetterm[pt]{Zurich}{Zurique}
%    \end{macrocode}

% Define |subject| to combine |location| and |date|
% (as far as filled):
%    \begin{macrocode}
\metaset{subject}{\metacompose[#1]{location}{location: }
   {\metacompose[#1]{date}{, date: }{}{}}
   {\metacompose[#1]{date}{date: }{}{}}}
%    \end{macrocode}

% Adjust title display:
%    \begin{macrocode}
\metaset[skip]{subtitle}{\vspace{1ex}}
\metaset[skip]{author}{\vspace{2ex}}
\metaset[skip]{location}{\vspace{1ex}}
\metaset[skip]{date}{\vspace{1ex}}
\metaset[style]{title}{\LARGE\bfseries}
\metaset[style]{author}{\large\scshape}
\metaset[sep]{draft}{ -- }
%%\metaunset[sep]{date}
%    \end{macrocode}

% Write title also in english and german;
% write rights as PDF metadata also in English and Spanish:
%    \begin{macrocode}
\metaset[altlang]{title}{en,de}
\metaset[altlang]{rightstext}{en,es}
\metaset[rights]{writepdf}{}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Set Document Data.}
%
% Set the document language:
%    \begin{macrocode}
\metasetlang{en}
%%\metasetlang{de}
%%\metasetlang{de-CH}
%%\metasetlang{fr}
%    \end{macrocode}

% Define some document data:
%    \begin{macrocode}
\metaset[en]{title}{A metastr Sample}
\metaset[de]{title}{Ein metastr Beispiel}
\metaset[print]{title}{A \textsf{metastr} Sample}
\metaset{subtitle}{Illustration of some features}
\metaset{author}{Niklas Beisert}
\metaset{keywords}{composition of title, application of licenses, translations}
\metaset{location}{\metatranslate[#1]{Zurich}}
\metaset{date}{2020/02/06}
\metaset{partof}{The metastr Package}
\metaset[print]{partof}{The \textsf{metastr} Package}
\metasetup{draft=true}
%    \end{macrocode}

% Copyright settings:
%    \begin{macrocode}
\metaset{copyrightowner}{\metapick[#1]{author}}
\metaset{copyrightdate}{2020}
\metacopyright{doc}
%%\metacopyright{reserved}
%    \end{macrocode}

% License settings:
%    \begin{macrocode}
%%\metaset{licenseversion}{1.2}
%%\metalicense{lppl}
%    \end{macrocode}

% Creative Commons License use:
%    \begin{macrocode}
%%\metaset{licenseversion}{3.0}
\metalicensecc{by-sa}
%%\metalicensecc{by-nc-sa}
%%\metalicensecc{zero}
%%\metalicensecc{pd}
%    \end{macrocode}

% Scale the CC logo a bit:
%    \begin{macrocode}
\metaset[cmd]{licenselogo}{\includegraphics[scale=0.75]{#1}}
%    \end{macrocode}

% Start document body:
%    \begin{macrocode}
\begin{document}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Header.}
%
% Display title block:
%    \begin{macrocode}
\pdfbookmark[1]{\metaterm{title}}{title}
\begin{center}
\metapick[print]{titlematter}
\end{center}
%    \end{macrocode}

% Display fineprint in fine print:
%    \begin{macrocode}
\vspace{1ex}\hrule\par\vspace{1ex}
\begingroup\footnotesize
\pdfbookmark[1]{\metaterm{copyright}}{copyright}
\metapick[print]{rightstext}
\endgroup
\vspace{1ex}\hrule\par\vspace{1ex}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Content.}
%
% Some useful content:
%    \begin{macrocode}
\section{Metadata Inspection}

The metadata stored in this example PDF can be inspected with
the tool \texttt{pdfinfo}:

\begin{tabular}{l}
\verb+pdfinfo metasamp.pdf+\\
\verb+pdfinfo -meta metasamp.pdf | less+
\end{tabular}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Translations.}
%
% Demonstration of terms and translations:
%    \begin{macrocode}
\section{Translations}

\begin{tabular}{ll}
document language:&\metaterm{Zurich}\\
Spanish:&\metatranslate[es]{Zurich}
\end{tabular}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Creative Commons.}
%
% Demonstrate some CC terms:
%    \begin{macrocode}
\metaif[]{cc@type}{ % only if a CC license is in use
\section{Creative Commons}
some representations of the selected license:
\begin{itemize}
\item license identifier:
  \metapick[]{licensecc}
\item \texttt{short} identifier:
  \metapick[short]{licensecc}
\item full form:
  \metapick[]{licenseccfull}
\item \texttt{ident} form:
  \metapick[ident]{licensecc}
\item \texttt{short} form:
  \metapick[short]{licenseccfull}
\IfFileExists{ccicons.sty}
  {\item \texttt{icon} forms:
   -- \metapick[icon]{licensecc}
   -- \metapick[icon]{licenseccfull} --}{}
\item \texttt{url} form:
  \metapick[url]{licenseccfull}
\end{itemize}
}{}
%    \end{macrocode}

% End of document body:
%    \begin{macrocode}
\end{document}
%    \end{macrocode}
%\iffalse
%</sample>
%\fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Implementation}
% \label{sec:implementation}
%\iffalse
%<*package>
%\fi
%
% This section describes the implementation of the package |metastr.sty|.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Package Setup}
% \label{sec:imp-setup}
%
% The package declares a couple of setup options.
%
% It loads the package \ctanpkg{keyval}
% for extended options processing.
%    \begin{macrocode}
\RequirePackage{keyval}
%    \end{macrocode}

% \macro{hyperref}
% \macro{hyperxmp}
% \macro{checkdef}
% \macro{cclogo}
% \macro{cclogocurr}
% \macro{cclogoshape}
% \macro{xmppdfinfo}
% Store the selected package options in some corresponding internal macros:
%    \begin{macrocode}
\newif\ifmstr@opt@hyperref\mstr@opt@hyperreftrue
\newif\ifmstr@opt@hyperxmp\mstr@opt@hyperxmptrue
\newif\ifmstr@opt@checkdef\mstr@opt@checkdeftrue
\newif\ifmstr@opt@xmppdfinfo\mstr@opt@xmppdfinfotrue
\newif\ifmstr@opt@course\mstr@opt@coursefalse
\newif\ifmstr@opt@draft\mstr@opt@draftfalse
\newif\ifmstr@opt@titlematter\mstr@opt@titlematterfalse
\newif\ifmstr@opt@cclogo\mstr@opt@cclogotrue
\def\mstr@opt@cclogocurr{dollar}
\def\mstr@opt@cclogoshape{box}
\def\mstr@opt@loadlang{en}
\def\mstr@group{mstr@}
\define@key{\mstr@group}{hyperref}[true]{%
  \csname mstr@opt@hyperref#1\endcsname}
\define@key{\mstr@group}{hyperxmp}[true]{%
  \csname mstr@opt@hyperxmp#1\endcsname}
\define@key{\mstr@group}{checkdef}[true]{%
  \csname mstr@opt@checkdef#1\endcsname}
\define@key{\mstr@group}{xmppdfinfo}[true]{%
  \csname mstr@opt@xmppdfinfo#1\endcsname}
\define@key{\mstr@group}{cclogo}[true]{\csname mstr@opt@cclogo#1\endcsname}
\define@key{\mstr@group}{cclogocurr}{\def\mstr@opt@cclogocurr{#1}}
\define@key{\mstr@group}{cclogoshape}{\def\mstr@opt@cclogoshape{#1}}
\define@key{\mstr@group}{loadlang}{\def\mstr@opt@loadlang{#1}}
\define@key{\mstr@group}{course}[true]{\csname mstr@opt@course#1\endcsname}
\define@key{\mstr@group}{draft}[true]{\csname mstr@opt@draft#1\endcsname}
\define@key{\mstr@group}{titlematter}[true]{%
  \csname mstr@opt@titlematter#1\endcsname}
%    \end{macrocode}

% Pass undeclared options on to \ctanpkg{keyval} processing:
%    \begin{macrocode}
\DeclareOption*{\expandafter\setkeys\expandafter\mstr@group%
  \expandafter{\CurrentOption}}
%    \end{macrocode}

% Process global options while loading package:
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}

% \macro{\metasetup}
% |\metasetup| processes package options
% when the package has already been loaded:
%    \begin{macrocode}
\def\mstr@setup{mstr@setup}
\newcommand{\metasetup}[1]{\setkeys\mstr@setup{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Definitions}
% \label{sec:imp-def}
%
% The following describes the basic definitions
% of the package.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Required Packages.}
%
% The package loads the packages
% \ctanpkg{hyperref} and \ctanpkg{hyperxmp}
% (unless excluded):
%    \begin{macrocode}
\ifmstr@opt@hyperref\RequirePackage{hyperref}\fi
\ifmstr@opt@hyperxmp\RequirePackage{hyperxmp}\fi
\ifmstr@opt@xmppdfinfo\ifdefined\xmptilde\hypersetup{keeppdfinfo}\fi\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{General Definitions.}
%
% \macro{\mstr@exptwo}
% A macro to conveniently expand the third token in line:
%    \begin{macrocode}
\def\mstr@exptwo#1{\expandafter#1\expandafter}
%    \end{macrocode}
% \macro{\mstr@csdo}
% \macro{\mstr@csdotwo}
% Some macros to conveniently expand |\csname| arguments
% before expanding the macro:
%    \begin{macrocode}
\def\mstr@csdo#1#2{\expandafter#1\csname#2\endcsname}
\def\mstr@csdotwo#1#2#3{\mstr@exptwo#1#2\csname#3\endcsname}
%    \end{macrocode}
% \macro{\mstr@iftext}
% Check whether macro |#1| equals text |#2|, then do |#3|:
%    \begin{macrocode}
\long\def\mstr@iftext#1#2#3{\def\mstr@tmp{#2}\ifx#1\mstr@tmp#3\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Internal Definitions.}
%
% \macro{\mstr@lang@main}
% \macro{\mstr@lang@short}
% \macro{\mstr@lang@fallback}
% \macro{\mstr@lang@meta}
% Predefine language identifiers as empty.
% These define the language for the document text
% (with and without country code), document metadata
% and a fallback language:
%    \begin{macrocode}
\let\mstr@lang@main\@empty
\let\mstr@lang@short\@empty
\let\mstr@lang@fallback\@empty
\let\mstr@lang@meta\@empty
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Interface Definitions.}
%
% \macro{\metatilde}
% \macro{\metacomma}
% Define a macro for the tilde character (mostly for use within URLs);
% recycle the definitions from \ctanpkg{hyperxmp} if available:
%    \begin{macrocode}
\ifdefined\xmptilde
\let\metatilde\xmptilde
\let\metacomma\xmpcomma
\else
\def\metatilde{~}
\def\metacomma{,}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Declare Registers.}
%
% \macro{\metadef}
% Declare a register:
%    \begin{macrocode}
\newcommand{\metadef}[1]{%
  \mstr@csdo\let{mstr@def@#1}\relax}
%    \end{macrocode}

% \macro{\mstr@verify}
% Verify the declaration of a register;
% throw an error if undeclared;
% disable checking for package option |checkdef=false|:
%    \begin{macrocode}
\newcommand{\mstr@verify}[1]{%
  \ifcsname mstr@def@#1\endcsname\else
    \PackageError{metastr}{register `#1' undefined}{}%
  \fi}
\ifmstr@opt@checkdef\else\def\mstr@verify#1{}\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Set Registers.}
%
% \macro{\mstr@setbare}
% Store the register value in the macro
% |\mstr@data@|\textit{reg}|@|\textit{var};
% define one argument to pass along original variant:
%    \begin{macrocode}
\long\def\mstr@setbare[#1]#2#3{%
  \mstr@csdo\gdef{mstr@data@#2@#1}##1{#3}}
%    \end{macrocode}

% \macro{\mstr@set}
% Set the register value; verify whether the register has been declared:
%    \begin{macrocode}
\long\def\mstr@set[#1]#2#3{\mstr@verify{#2}%
  \mstr@setbare[#1]{#2}{#3}}
%    \end{macrocode}

% \macro{\metaset}
% Interface macro for setting register
% with optional variant argument:
%    \begin{macrocode}
\newcommand{\metaset}{\@ifnextchar[{\mstr@set}{\mstr@set[]}}
%    \end{macrocode}

% \macro{\mstr@unset}
% Clear a register value:
%    \begin{macrocode}
\long\def\mstr@unset[#1]#2{\mstr@verify{#2}%
  \mstr@csdotwo\global\let{mstr@data@#2@#1}\@undefined}
%    \end{macrocode}

% \macro{\metaunset}
% Interface macro for clearing register
% with optional variant argument:
%    \begin{macrocode}
\newcommand{\metaunset}{\@ifnextchar[{\mstr@unset}{\mstr@unset[]}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Register Conditionals.}
%
% \macro{\metaif}
% If-then-else structure checking whether register variant is filled:
%    \begin{macrocode}
\long\def\metaif[#1]#2#3#4{%
  \ifcsname mstr@data@#2@#1\endcsname #3\else #4\fi}
%    \end{macrocode}

% \macro{\metaifpick}
% If-then-else structure checking if the register in either of the variants
% |#1|, |\mstr@lang@main|, |\mstr@lang@short|,
% default and |\mstr@lang@fallback|
% is filled;
% |#1| may in fact be a comma-separated list of variants (without spaces):
%    \begin{macrocode}
\long\def\mstr@ifloop[#1,#2]#3#4#5{%
  \metaif[#1]{#3}{#4}{\if @#2@#5\else\mstr@ifloop[#2]{#3}{#4}{#5}\fi}}
\long\def\metaifpick[#1]#2#3#4{%
  \mstr@ifloop
    [#1,\mstr@lang@main,\mstr@lang@short,,\mstr@lang@fallback,]
    {#2}{#3}{#4}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Manipulate Registers.}
%
% \macro{\mstr@append}
% Append some string to a register value:
%    \begin{macrocode}
\long\def\mstr@append[#1]#2#3{%
  \mstr@csdotwo\let\mstr@tmpa{mstr@data@#2@#1}%
  \def\mstr@tmpb##1{\mstr@set[#1]{#2}{##1#3}}%
  \mstr@exptwo\mstr@tmpb{\mstr@tmpa{##1}}}
%    \end{macrocode}

% \macro{\mstr@prepend}
% Prepend some string to a register value:
%    \begin{macrocode}
\long\def\mstr@prepend[#1]#2#3{%
  \mstr@csdotwo\let\mstr@tmpa{mstr@data@#2@#1}%
  \def\mstr@tmpb##1{\mstr@set[#1]{#2}{#3##1}}%
  \mstr@exptwo\mstr@tmpb{\mstr@tmpa{##1}}}
%    \end{macrocode}

% \macro{\mstr@addsep}
% Append a string to a register value separated by |#1|
% if the string was previously filled:
%    \begin{macrocode}
\long\def\mstr@addsep[#1]#2#3#4{%
  \metaif[#1]{#2}{\mstr@append[#1]{#2}{#3#4}}{\mstr@set[#1]{#2}{#4}}}
%    \end{macrocode}

% \macro{\metaappend}
% \macro{\metaprepend}
% \macro{\metaaddsep}
% Interface macros for appending, prepending
% and adding with separator:
%    \begin{macrocode}
\newcommand{\metaappend}{%
  \@ifnextchar[{\mstr@append}{\mstr@append[]}}
\newcommand{\metaprepend}{%
  \@ifnextchar[{\mstr@prepend}{\mstr@prepend[]}}
\newcommand{\metaaddsep}{%
  \@ifnextchar[{\mstr@addsep}{\mstr@addsep[]}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Read Register Values.}
%
% \macro{\mstr@getbare}
% Read a register value
% while passing along the original variant as an argument:
%    \begin{macrocode}
\def\mstr@getbare[#1]#2#3{\csname mstr@data@#2@#1\endcsname{#3}}
%    \end{macrocode}

% \macro{\metaget}
% Interface function to read register value
% with mandatory variant argument in square brackets;
% return nothing if register clean:
%    \begin{macrocode}
\def\metaget[#1]#2{%
  \metaif[#1]{#2}{\mstr@getbare[#1]{#2}{#1}}{}}%
%    \end{macrocode}

% \macro{\metacompose}
% \macro{\metapick}
% |\metapick| returns a filled register value among the variants
% |#1|, |\mstr@lang@main|, |\mstr@lang@short|, default
% and |\mstr@lang@fallback|
% (in this order of preference), otherwise it returns nothing;
% |#1| may in fact be a comma-separated list of variants (without spaces);
% |\metacompose| sandwiches the value between |#3| and |#4| if found,
% and otherwise returns |#5|:
%    \begin{macrocode}
\long\def\mstr@composeloop[#1,#2]#3#4#5#6#7{%
  \metaif[#1]{#4}{#5\mstr@getbare[#1]{#4}{#3}#6}
    {\if @#2@#7\else\mstr@composeloop[#2]{#3}{#4}{#5}{#6}{#7}\fi}}
\long\def\metacompose[#1]#2#3#4#5{%
  \mstr@composeloop
    [#1,\mstr@lang@main,\mstr@lang@short,,\mstr@lang@fallback,]{#1}
    {#2}{#3}{#4}{#5}}%
\def\metapick[#1]#2{\metacompose[#1]{#2}{}{}{}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Language Selection.}
%
% \macro{language}
% Declare language register:
%    \begin{macrocode}
\metadef{language}
%    \end{macrocode}
% \macro{\metasetlang}
% Set language and extract short forms:
%    \begin{macrocode}
\def\mstr@lang@split#1#2-#3@{%
  \mstr@csdo\gdef{mstr@lang@#1}{#2}}
\newcommand{\mstr@setlang@main}[1]{%
  \metaset{language}{#1}%
  \gdef\mstr@lang@main{#1}%
  \mstr@lang@split{short}#1-@%
  \metaset[short]{language}{\mstr@lang@short}%
  \metaif[meta]{language}{}{\mstr@lang@split{meta}#1-@}}
\newcommand{\mstr@setlang@meta}[1]{%
  \metaset[meta]{language}{#1}%
  \mstr@lang@split{meta}#1-@%
  \metaset[metashort]{language}{\mstr@lang@meta}}
\newcommand{\metasetlang}{%
  \@ifstar\mstr@setlang@meta\mstr@setlang@main}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Terms.}
%
% \macro{\metaterm}
% \macro{\metatranslate}
% \macro{\metasetterm}
% Macros for filling and reading term registers:
%    \begin{macrocode}
\newcommand{\metaterm}{\metatranslate[]}
\def\metatranslate[#1]#2{\metapick[#1]{term-#2}}
\long\def\mstr@setterm[#1]#2#3{%
  \metadef{term-#2}\mstr@setbare[#1]{term-#2}{#3}}
\newcommand{\metasetterm}{\@ifnextchar[{\mstr@setterm}{\mstr@setterm[]}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Automatic Writing to PDF.}
%
% \macro{writepdf}
% Declare register |writepdf| to control automatic
% writing of metadata to PDF files:
%    \begin{macrocode}
\metadef{writepdf}
\metaset[auto]{writepdf}{}
\metaset[preamble]{writepdf}{}
\metaset[info]{writepdf}{}
\metaset[aux]{writepdf}{}
%    \end{macrocode}

% \macro{\mstr@ifwritepdf}
% Auxiliary macro to write some type of metadata if switch activated,
% disable switch afterwards:
%    \begin{macrocode}
\long\def\mstr@ifwritepdf[#1]#2{%
  \metaif[#1]{writepdf}{#2\metaunset[#1]{writepdf}}{}}
%    \end{macrocode}

% \macro{\metawritepdf}
% Write selected types of metadata to PDF file:
%    \begin{macrocode}
\newcommand{\metawritepdf}{%
  \mstr@ifwritepdf[preamble]{\metawritepdfpreamble}%
  \mstr@ifwritepdf[info]{\metawritepdfinfo}%
  \mstr@ifwritepdf[aux]{\metawritepdfaux}%
  \mstr@ifwritepdf[contact]{\metawritepdfcontact}%
  \mstr@ifwritepdf[rights]{\metawritepdfrights}%
}
%    \end{macrocode}

% \macro{\mstr@begindoc}
% \macro{\mstr@begindocpreamble}
% Hook for writing data to PDF file;
% this is the last chance to write the preamble set of data to the PDF
% (|pdflang| must be declared before \ctanpkg{hyperxmp}
% detects languages at the end of the preamble
% and before \ctanpkg{hyperref} sets it at the beginning of the document):
%    \begin{macrocode}
\newcommand{\mstr@begindoc}{%
  \mstr@ifwritepdf[auto]{\metawritepdf}}
\newcommand{\mstr@begindocpreamble}{%
  \mstr@ifwritepdf[preamble]{\metawritepdfpreamble}}
%    \end{macrocode}

% Hook |\mstr@begindoc| to begining of |document| block
% (before hooks by \ctanpkg{hyperref} and \ctanpkg{hyperxmp} are called,
% just in case);
% hook |\mstr@begindocpreamble| to begining of |document| block
% before hooks by \ctanpkg{hyperxmp} are called;
% legacy code for latex releases earlier than 2020-10
% to add hook before all other hooks are called:
%    \begin{macrocode}
\ifdefined\AddToHook
\DeclareHookRule{begindocument}{metastr}{before}{hyperref}
\DeclareHookRule{begindocument}{metastr}{before}{hyperxmp}
\AddToHook{begindocument}{\mstr@begindoc}
\DeclareHookRule{begindocument/before}{metastr}{before}{hyperxmp}
\AddToHook{begindocument/before}{\mstr@begindocpreamble}
\else
\AtBeginDocument{\mstr@begindoc}
\begingroup
\toks@\expandafter{\expandafter\mstr@begindocpreamble\@begindocumenthook}
\xdef\@begindocumenthook{\the\toks@}
\endgroup
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Basic Registers}
% \label{sec:imp-basic}
%
% The following defines a set of basic and auxiliary registers.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Declarations.}
%
% \macro{draft}
% Declare register to state draft mode:
%    \begin{macrocode}
\metadef{draft}
%    \end{macrocode}
% Set draft text (if |draft| option set), declare |draft| option:
%    \begin{macrocode}
\newcommand{\mstr@set@draft}{%
  \ifmstr@opt@draft\metaset{draft}{\metatranslate[##1]{draft}}%
  \else\metaunset{draft}\fi}
\define@key{\mstr@setup}{draft}[true]{%
  \csname mstr@opt@draft#1\endcsname\mstr@set@draft}%
\mstr@set@draft
%    \end{macrocode}

% \macro{title}
% \macro{subtitle}
% \macro{author}
% \macro{date}
% \macro{location}
% \macro{subject}
% \macro{keywords}
% Basic registers:
%    \begin{macrocode}
\metadef{title}
\metadef{subtitle}
\metadef{author}
\metadef{date}
\metadef{location}
\metadef{subject}
\metadef{keywords}
%    \end{macrocode}

% \macro{linebreak}
% Declare an auxiliary register to break a line in |print| variant
% and display a space otherwise:
%    \begin{macrocode}
\metadef{linebreak}
\metaset[]{linebreak}{ }
\metaset[print]{linebreak}{\\}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Title and Author Composition.}
%
% \macro{titlematter}
% \macro{titletext}
% \macro{authortext}
% \macro{datatext}
% Declare register to compose title display (analogous to |\maketitle|):
%    \begin{macrocode}
\metadef{titlematter}
\metadef{titletext}
\metadef{authortext}
\metadef{datatext}
%    \end{macrocode}

% \macro{\metatitleline}
% \macro{\metatitlelinetwo}
% Macros to print a formatted title line
% with one or two items;
% variant |skip| produces vertical skip before the item,
% variant |style| sets the text style,
% variant |sep| defines the separator between
% two items or undefined for two independent lines:
%    \begin{macrocode}
\def\metatitleline[#1]#2{%
  \metacompose[#1]{#2}
   {\metaget[skip]{#2}\begingroup\metaget[style]{#2}}
   {\par\endgroup}{}}
\def\metatitlelinetwo[#1]#2[#3]#4{%
  \metaif[sep]{#4}
   {\metacompose[#1]{#2}
     {\metaget[skip]{#2}\begingroup\metaget[style]{#2}}
     {\metacompose[#3]{#4}{\metaget[sep]{#4}}{}{}\par\endgroup}
     {\metatitleline[#3]{#4}}}
   {\metatitleline[#1]{#2}\metatitleline[#3]{#4}}}
%    \end{macrocode}

% Set default layout and spacing:
%    \begin{macrocode}
\metaset[style]{title}{\LARGE}
\metaset[style]{subtitle}{\large}
\metaset[style]{draft}{\large}
\metaset[style]{author}{\large}
\metaset[style]{location}{\large}
\metaset[style]{date}{\large}
\metaset[skip]{subtitle}{\vspace{1.5em}}
\metaset[skip]{draft}{\vspace{1.5em}}
\metaset[skip]{author}{\vspace{3em}}
\metaset[skip]{location}{\vspace{1.5em}}
\metaset[skip]{date}{\vspace{1.5em}}
\metaset[sep]{subtitle}{ -- }
\metaset[sep]{date}{, }
\metaset[sep]{draft}{: }
%    \end{macrocode}
% Preset for |titlematter|, |titletext|, |authortext| and |datatext|
% in generic and |print| variants:
%    \begin{macrocode}
\metaset{titletext}{%
  \metacompose[#1]{draft}{}{\metaget[sep]{draft}}{}%
  \metapick[#1]{title}%
  \metacompose[#1]{subtitle}{\metaget[sep]{subtitle}}{}{}}
\metaset{authortext}{\metapick[#1]{author}}
\metaset{datatext}{%
  \metacompose[#1]{location}{}{\metaget[sep]{date}}{}%
  \metapick[#1]{date}}
\metaset{titlematter}{%
  \metapick[#1]{titletext}%
  \metapick[#1]{authortext}%
  \metapick[#1]{datatext}%
  \metaget[skip]{titlematter}}
\metaset[print]{titletext}{%
  \metatitleline[print]{title}%
  \metatitlelinetwo[print]{subtitle}[print]{draft}}
\metaset[print]{authortext}{%
  \metatitleline[print]{author}}
\metaset[print]{datatext}{%
  \metatitlelinetwo[print]{location}[print]{date}}
%    \end{macrocode}
% Legacy presets:
%    \begin{macrocode}
\ifmstr@opt@titlematter\else
\metaset{titlematter}{%
  \metapick[#1]{titletext}%
  \metaget[skip]{titlematter}}
\metaset[print]{titletext}{%
  \metatitleline[print]{title}%
  \metatitlelinetwo[print]{subtitle}[print]{draft}%
  \metapick[print]{authortext}%
  \metapick[print]{datatext}}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Further Registers.}
%
% \macro{url}
% \macro{urlmessage}
% Registers for document URL and message to display it:
%    \begin{macrocode}
\metadef{url}
\metadef{urlmessage}
%    \end{macrocode}
% Print URL as hyperlink:
%    \begin{macrocode}
\metaset[print]{url}{\url{\metaget[]{url}}}
%    \end{macrocode}
% URL message default text (translated):
% \translate{urlmessage}
%    \begin{macrocode}
% \metaset{urlmessage}{%
%   The current version of this work can be found at:
%   \metapick[#1]{url}.}
%    \end{macrocode}

% \macro{partof}
% \macro{partofmessage}
% Registers for document URL and message to display it:
%    \begin{macrocode}
\metadef{partof}
\metadef{partofmessage}
%    \end{macrocode}
% part of message default text (translated):
% \translate{partofmessage}
%    \begin{macrocode}
% \metaset{partofmessage}{%
%   This document is part of the work: \metapick[#1]{partof}.}
%    \end{macrocode}

% \macro{source}
% Register for source name:
%    \begin{macrocode}
\metadef{source}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Write to PDF.}
%
% \macro{\metawritepdfpreamble}
% Write some registers to PDF that need to be written
% before the start of the document:
%    \begin{macrocode}
\newcommand{\metawritepdfpreamble}{\ifdefined\hypersetup
  \metaif[]{language}
    {\hypersetup{pdflang={\metaget[]{language}}}}{}%
  \ifdefined\xmptilde
    \metaif[meta]{language}
      {\hypersetup{pdfmetalang={\metaget[meta]{language}}}}{}%
  \fi\fi}
%    \end{macrocode}

% \macro{\metawritepdfinfo}
% Write the basic registers to PDF;
% also write alternative language representations
% of |pdftitle| and |pdfsubject|:
%    \begin{macrocode}
\newcommand{\metawritepdfinfo}{\ifdefined\hypersetup
  \metaifpick[\mstr@lang@meta]{author}
    {\hypersetup{pdfauthor={\metapick[\mstr@lang@meta]{authortext}}}}{}%
  \metaifpick[\mstr@lang@meta]{title}
    {\hypersetup{pdftitle={\metapick[\mstr@lang@meta]{titletext}}}}{}%
  \metaifpick[\mstr@lang@meta]{subject}
    {\hypersetup{pdfsubject={\metapick[\mstr@lang@meta]{subject}}}}{}%
  \metaifpick[\mstr@lang@meta]{keywords}
    {\hypersetup{pdfkeywords={\metapick[\mstr@lang@meta]{keywords}}}}{}%
  \ifdefined\xmptilde
    \metaif[altlang]{title}{%
      \@for\mstr@tmp:=\mstr@data@title@altlang{}\do{%
        \metaifpick[\mstr@tmp]{title}
          {\XMPLangAlt{\mstr@tmp}{pdftitle=
            {\metapick[\mstr@tmp]{titletext}}}}{}}%
      \metaunset[altlang]{title}}{}%
    \metaif[altlang]{subject}{%
      \@for\mstr@tmp:=\mstr@data@subject@altlang{}\do{%
        \metaifpick[\mstr@tmp]{subject}
          {\XMPLangAlt{\mstr@tmp}{pdfsubject=
            {\metapick[\mstr@tmp]{subject}}}}{}}%
      \metaunset[altlang]{subject}}{}%
  \fi\fi}
%    \end{macrocode}

% \macro{\metawritepdfaux}
% Write auxiliary registers to PDF:
%    \begin{macrocode}
\newcommand{\metawritepdfaux}{\ifdefined\hypersetup\ifdefined\xmptilde
  \metaif[]{url}
    {\hypersetup{pdfurl={\metaget[]{url}}}}{}%
  \hypersetup{pdfsource={}}%
  \metaif[]{source}
    {\hypersetup{pdfsource={\metaget[]{source}}}}{}%
\fi\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Copyright and License}
% \label{sec:imp-rights}
%
% The following defines some registers concerning
% copyright and licensing.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Rights Composition.}
%
% \macro{rightstext}
% Declare a register to compose copyright and license information:
%    \begin{macrocode}
\metadef{rightstext}
%    \end{macrocode}
% Define generic version of composition register:
%    \begin{macrocode}
\metaset{rightstext}{%
  \metaifpick[]{partof}{\metacompose[#1]{partofmessage}{}{ }{}}{}%
  \metapick[#1]{copyrightstatement}%
  \metacompose[#1]{copyrightmessage}{ }{}{}%
  \metacompose[#1]{licensemessage}{ }{}{}%
  \metaif[]{licenseurl}{\metacompose[#1]{licenseurlmessage}{ }{}{}}{}%
  \metaif[]{url}{\metacompose[#1]{urlmessage}{ }{}{}}{}%
}
%    \end{macrocode}
% Define print version of composition register;
% variant |sep| contains code to separate parts of the message:
%    \begin{macrocode}
\metaset[skip]{rightstext}{\par\addvspace\medskipamount}
\metaset[print]{rightstext}{%
  \metaifpick[]{partof}{%
    \metacompose[#1]{partofmessage}{}{\metaget[skip]{rightstext}}{}}{}%
  \metacompose[#1]{copyrightstatement}{}{\metaget[skip]{rightstext}}{}%
  \metacompose[#1]{copyrightmessage}{}{ }{}%
  \metacompose[#1]{licensemessage}{}{ }{}%
  \metaif[]{licenselogo}{%
    \metacompose[#1]{licenselogomessage}
    {\metaget[skip]{rightstext}}{\metaget[skip]{rightstext}}{}}{}%
  \metaif[]{licenseurl}{\metacompose[#1]{licenseurlmessage}{ }{ }{}}{}%
  \metaif[]{url}{\metacompose[#1]{urlmessage}
    {\metaget[skip]{rightstext}}{}{}}{}
  \metacompose[#1]{attributionmessage}{\metaget[skip]{rightstext}}{}{}%
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Copyright Composition.}
%
% \macro{copyright...}
% Declare registers to specify document copyright:
%    \begin{macrocode}
\metadef{copyrightmark}
\metadef{copyrightdate}
\metadef{copyrightowner}
\metadef{copyrightstatement}
\metadef{copyrightmessage}
%    \end{macrocode}

% \macro{copyrightmark}
% The copyright sign or word:
%    \begin{macrocode}
\metaset{copyrightmark}{Copyright}
\metaset[print]{copyrightmark}{\copyright}
%    \end{macrocode}

% \macro{copyrightstatement}
% Assemble the copyright statement from available fragments;
% proper spacing makes this a bit tedious:
%    \begin{macrocode}
\metaset{copyrightstatement}{\metaifpick[#1]{copyrightdate}%
  {\metapick[#1]{copyrightmark} \metapick[#1]{copyrightdate}%
  \metacompose[#1]{copyrightowner}{ }{}{}.}
  {\metaifpick[#1]{copyrightowner}
   {\metapick[#1]{copyrightmark} \metapick[#1]{copyrightowner}.}{}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{License Composition.}
%
% \macro{license...}
% Declare registers to specify document license:
%    \begin{macrocode}
\metadef{licenseversion}
\metadef{licenseprovider}
\metadef{licensemessage}
\metadef{licenselogo}
\metadef{licenselogomessage}
\metadef{licenseurl}
\metadef{licenseurlmessage}
%    \end{macrocode}

% \macro{attributionmessage}
% Declare a register for the attribution message:
%    \begin{macrocode}
\metadef{attributionmessage}
%    \end{macrocode}

% \macro{licenseurlmessage}
% Message to declare URL at which the relevant license
% or further details can be found (translated):
% \translate{licenseurlmessage}
%    \begin{macrocode}
% \metaset{licenseurlmessage}{%
%   To view a copy of this license, visit: \metapick[#1]{licenseurl}.}
%    \end{macrocode}

% \macro{licenseurl}
% In |print| version, pass plain |licenseurl| through |\url|:
%    \begin{macrocode}
\metaset[print]{licenseurl}{\url{\metaget[]{licenseurl}}}
%    \end{macrocode}

% \macro{licenselogo}
% \macro{licenselogomessage}
% Display license logo, by default align centrally;
% abuse the variant argument for passing the file name argument
% to |\includegraphics|:
%    \begin{macrocode}
\metaset[print]{licenselogomessage}{%
  \centerline{\metapick[#1]{licenselogo}}}
\metaset[cmd]{licenselogo}{\includegraphics{#1}}
\metaset[print]{licenselogo}{%
  \IfFileExists{\metaget[]{licenselogo}.pdf}%
    {\mstr@getbare[cmd]{licenselogo}{\metaget[]{licenselogo}}}%
    {\mstr@getbare[cmd]{licenselogo}{\metaget[nocurr]{licenselogo}}}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Write to PDF.}
%
% \macro{\metawritepdfrights}
% Write rights information
% (rights text, alternative language representations, license url)
% to PDF via \ctanpkg{hyperxmp}:
%    \begin{macrocode}
\newcommand{\metawritepdfrights}{\ifdefined\hypersetup\ifdefined\xmptilde
    \metaifpick[\mstr@lang@meta]{rightstext}
      {\hypersetup{pdfcopyright=
        {\metapick[\mstr@lang@meta]{rightstext}}}}{}%
    \metaif[altlang]{rightstext}
      {\@for\mstr@tmp:=\mstr@data@rightstext@altlang{}\do
        {\XMPLangAlt{\mstr@tmp}{pdfcopyright=
          {\metapick[\mstr@tmp]{rightstext}}}}}{}
    \metaifpick[\mstr@lang@meta]{licenseurl}
      {\hypersetup{pdflicenseurl=
        {\metapick[\mstr@lang@meta]{licenseurl}}}}{}%
\fi\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Copyright Presets.}
%
% \macro{copyright@...}
% Declare some copyright presets:
%    \begin{macrocode}
\metadef{copyright@plain}
\metadef{copyright@parts}
\metadef{copyright@doc}
\metadef{copyright@doc-parts}
\metadef{copyright@reserved}
\metadef{copyright@publicdomain}
%    \end{macrocode}
% \macro{plain}
% \macro{parts}
% \macro{doc}
% \macro{doc-parts}
% \macro{reserved}
% Some plain copyright messages (translated):
% \translate{copyright@plain}
% \translate{copyright@parts}
% \translate{copyright@doc}
% \translate{copyright@doc-parts}
% \translate{copyright@reserved}
%    \begin{macrocode}
% \metaset{copyright@plain}{%
%   This work is protected by copyright.}
% \metaset{copyright@parts}{%
%   This work as well as its parts is protected by copyright.}
% \metaset{copyright@doc}{%
%   This document is protected by copyright.}
% \metaset{copyright@doc-parts}{%
%   This document as well as its parts is protected by copyright.}
% \metaset{copyright@reserved}{All rights reserved.}
%    \end{macrocode}
% \macro{publicdomain}
% A public domain declaration (translated):
% \translate{copyright@publicdomain}
%    \begin{macrocode}
% \metaset{copyright@publicdomain}
%   {This work is dedicated to the public domain.}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{License Presets.}
%
% \macro{license@...}
% Declare some license presets
%    \begin{macrocode}
\metadef{license@consent}
\metadef{license@consent-noncom}
\metadef{license@lppl}
%    \end{macrocode}

% \macro{consent}
% A license to reproduce with prior written consent (translated):
% \translate{license@consent}
%    \begin{macrocode}
% \metaset{license@consent}{%
%   Reproduction of any part of this work in any form
%   without prior written consent
%   \metacompose[#1]{licenseprovider}{}{}{of the author}
%   is not permissible.}
%    \end{macrocode}

% \macro{consent-noncom}
% A license to reproduce
% for private, scientific and non-commercial purposes
% or with prior written consent (translated):
% \translate{license@consent-noncom}
%    \begin{macrocode}
% \metaset{license@consent-noncom}{%
%   Reproduction of any part of this work in any form
%   without prior written consent
%   \metapick[#1]{licenseprovider}{}{}{of the author}
%   is permissible only for private, scientific and non-commercial use.}
%    \end{macrocode}

% \macro{lppl}
% \LaTeX{} project public license (translated):
% \translate{license@lppl}
%    \begin{macrocode}
\metaset[url]{license@lppl}{https://www.latex-project.org/lppl.txt}
% \metaset{license@lppl}{%
%   This work may be distributed and/or modified under the
%   conditions of the LaTeX Project Public License, either version
%   \metaif[]{licenseversion}{\metaget[]{licenseversion}}{1.3}
%   of this license or (at your option) any later version.}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Selection Code.}
%
% \macro{\metacopyright}
% \macro{\metalicense}
% Set a copyright or license message:
%    \begin{macrocode}
\newcommand{\metacopyright}[1]{%
  \metaset{copyrightmessage}{\metapick[##1]{copyright@#1}}}
\newcommand{\metalicense}[1]{%
  \metaset{licensemessage}{\metapick[##1]{license@#1}}%
  \metaif[url]{license@#1}{%
    \metaset{licenseurl}{\metaget[url]{license@#1}}}{}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Creative Commons}
% \label{sec:imp-cc}
%
% The following implements the scheme of Creative Commons licenses.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Declarations.}
%
% \macro{cc@type}
% \macro{cc@class}
% |cc@type| stores the selected CC license type;
% |cc@class| is `|@zero|' for the CC0 public domain dedication
% and empty otherwise:
%    \begin{macrocode}
\metadef{cc@type}
\metadef{cc@class}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Text Components and Internationalisation.}
%
% CC license declarations are composed
% from several elements which can be conveniently internationalised.
%
% The following registers store various terms used in CC licenses:
% \translate{term-cc@...}
%    \begin{macrocode}
\metasetterm{cc@sep}{-}
\metasetterm{cc@quotel}{\textquotedblleft}
\metasetterm{cc@quoter}{\textquotedblright}
\metasetterm{cc@cc}{Creative Commons}
\metasetterm{cc@zero}{CC0}
\metasetterm{cc@by}{Attribution}
\metasetterm{cc@sa}{ShareAlike}
\metasetterm{cc@nd}{NoDerivatives}
\metasetterm{cc@nc}{NonCommercial}
\metasetterm{cc@unported}{Unported}
\metasetterm{cc@generic}{Generic}
\metasetterm{cc@intl}{International}
\metasetterm{cc@univ}{Universal}
\metasetterm{cc@pd}{Public Domain}
\metasetterm{cc@license}{License}
\metasetterm{cc@pddecl}{Public Domain Dedication}
%    \end{macrocode}

% \macro{cc@pd}
% \macro{cc@zero}
% \macro{cc@by...}
% The following template registers store the combinations
% for the various CC licenses:
%    \begin{macrocode}
\metadef{cc@pd}
\metadef{cc@zero}
\metadef{cc@by}
\metadef{cc@by-sa}
\metadef{cc@by-nd}
\metadef{cc@by-nc}
\metadef{cc@by-nc-sa}
\metadef{cc@by-nc-nd}
%    \end{macrocode}
% Fill the registers:
%    \begin{macrocode}
\metaset{cc@zero}{\metatranslate[#1]{cc@zero}}
\metaset{cc@by}{\metatranslate[#1]{cc@by}}
\metaset{cc@by-sa}{%
  \metatranslate[#1]{cc@by}\metatranslate[#1]{cc@sep}%
  \metatranslate[#1]{cc@sa}}
\metaset{cc@by-nd}{%
  \metatranslate[#1]{cc@by}\metatranslate[#1]{cc@sep}%
  \metatranslate[#1]{cc@nd}}
\metaset{cc@by-nc}{%
  \metatranslate[#1]{cc@by}\metatranslate[#1]{cc@sep}%
  \metatranslate[#1]{cc@nc}}
\metaset{cc@by-nc-sa}{%
  \metatranslate[#1]{cc@by}\metatranslate[#1]{cc@sep}%
  \metatranslate[#1]{cc@nc}\metatranslate[#1]{cc@sep}%
  \metatranslate[#1]{cc@sa}}
\metaset{cc@by-nc-nd}{%
  \metatranslate[#1]{cc@by}\metatranslate[#1]{cc@sep}%
  \metatranslate[#1]{cc@nc}\metatranslate[#1]{cc@sep}%
  \metatranslate[#1]{cc@nd}}
%    \end{macrocode}

% \macro{cc@n.n}
% \macro{cc@n.n@zero}
% The following registers store the various versions for CC licenses:
%    \begin{macrocode}
\metadef{cc@1.0@zero}
\metadef{cc@1.0}
\metadef{cc@2.0}
\metadef{cc@2.5}
\metadef{cc@3.0}
\metadef{cc@4.0}
%    \end{macrocode}
% Fill the registers:
%    \begin{macrocode}
\metaset{cc@1.0@zero}{\metatranslate[#1]{cc@univ}}
\metaset{cc@1.0}{\metatranslate[#1]{cc@generic}}
\metaset{cc@2.0}{\metatranslate[#1]{cc@generic}}
\metaset{cc@2.5}{\metatranslate[#1]{cc@generic}}
\metaset{cc@3.0}{\metatranslate[#1]{cc@unported}}
\metaset{cc@4.0}{\metatranslate[#1]{cc@intl}}
%    \end{macrocode}

% \macro{cc@license}
% \macro{cc@license@zero}
% \macro{cc@license@pd}
% The following registers store the term ``CC license'':
%    \begin{macrocode}
\metadef{cc@license}
\metadef{cc@license@zero}
\metadef{cc@license@pd}
%    \end{macrocode}
% Fill the registers (translated):
% \translate{cc@license}
% \translate{cc@license@zero}
% \translate{cc@license@pd}
%    \begin{macrocode}
% \metaset{cc@license}{%
%   \metatranslate[#1]{cc@cc} \metatranslate[#1]{cc@license}}
% \metaset{cc@license@zero}{%
%   \metatranslate[#1]{cc@cc} \metatranslate[#1]{cc@pddecl}}
\metaset{cc@license@pd}{\metatranslate[#1]{cc@pddecl}}
%    \end{macrocode}

% \macro{cc@message}
% \macro{cc@message@zero}
% The following registers contain presets for the CC license messages:
%    \begin{macrocode}
\metadef{cc@message}
\metadef{cc@message@zero}
%    \end{macrocode}
% Fill the registers (translated):
% \translate{cc@message}
% \translate{cc@message@zero}
%    \begin{macrocode}
% \metaset{cc@message}{%
%   This work is licensed under the
%   \metapick[#1]{licenseccfull} (\metapick[short]{licenseccfull}).}
% \metaset{cc@message@zero}{%
%   This work is dedicated to the public domain by means of the
%   \metapick[#1]{licenseccfull} (\metapick[short]{licenseccfull}).}
%    \end{macrocode}

% \macro{licensecc}
% \macro{licenseccver}
% \macro{licenseccfull}
% |licensecc| and |licenseccver|
% represent the name and version of the selected CC license;
% |licenseccfull| contains a full representation of the selected CC license:
%    \begin{macrocode}
\metadef{licensecc}
\metadef{licenseccver}
\metadef{licenseccfull}
%    \end{macrocode}
% Fill the registers:
%    \begin{macrocode}
\metaset{licensecc}{%
  \metapick[#1]{cc@\metaget[]{cc@type}}}
\metaset{licenseccver}{%
  \metaget[]{licenseversion}
  \metapick[#1]{cc@\metaget[]{licenseversion}\metaget[]{cc@class}}}
\metaset{licenseccfull}{%
  \metapick[#1]{cc@license\metaget[]{cc@class}}
  \metatranslate[#1]{cc@quotel}%
  \metapick[#1]{licensecc}
  \metapick[#1]{licenseccver}%
  \metatranslate[#1]{cc@quoter}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{License Identifier.}
%
% \macro{ident}
% Compose the license identifier by |ident| variant:
%    \begin{macrocode}
\metaset[ident]{licenseccver}{\metaget[]{licenseversion}}
\metaset[ident]{licenseccfull}{%
  \metapick[ident]{licensecc} \metaget[ident]{licenseccver}}
\metasetterm[ident]{cc@sep}{-}
\metasetterm[ident]{cc@cc}{CC}
\metasetterm[ident]{cc@by}{BY}
\metasetterm[ident]{cc@sa}{SA}
\metasetterm[ident]{cc@nd}{ND}
\metasetterm[ident]{cc@nc}{NC}
\metasetterm[ident]{cc@zero}{CC0}
%    \end{macrocode}
%
% \macro{short}
% Compose the short license identifier by |short| variant:
%    \begin{macrocode}
\metaset[short]{licensecc}{%
  \metaget[short]{cc@license\metaget[]{cc@class}}%
  \metapick[short]{cc@\metaget[]{cc@type}}}
\metaset[short]{licenseccver}{\metaget[]{licenseversion}}
\metaset[short]{licenseccfull}{%
  \metapick[short]{licensecc} \metaget[short]{licenseccver}}
\metasetterm[short]{cc@sep}{-}
\metasetterm[short]{cc@cc}{CC}
\metasetterm[short]{cc@by}{BY}
\metasetterm[short]{cc@sa}{SA}
\metasetterm[short]{cc@nd}{ND}
\metasetterm[short]{cc@nc}{NC}
\metasetterm[short]{cc@zero}{CC0}
\metaset[short]{cc@license}{CC }
\metaset[short]{cc@license@zero}{}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{License Logo.}
%
% \macro{logo}
% |logo| variants used for the license logo
% provided by the \ctanpkg{doclicense} package:
%    \begin{macrocode}
\metaset[logo]{cc@pd}{doclicense-CC-pd}
\metaset[logo]{cc@zero}{doclicense-CC-zero}
\metaset[logo]{cc@by}{doclicense-CC-by}
\metaset[logo]{cc@by-sa}{doclicense-CC-by-sa}
\metaset[logo]{cc@by-nd}{doclicense-CC-by-nd}
\metaset[logo]{cc@by-nc}{doclicense-CC-by-nc}
\metaset[logo]{cc@by-nc-sa}{doclicense-CC-by-nc-sa}
\metaset[logo]{cc@by-nc-nd}{doclicense-CC-by-nc-nd}
%    \end{macrocode}
% Select currency versions:
%    \begin{macrocode}
\mstr@iftext\mstr@opt@cclogocurr{dollar}{\metaset[curr]{licenselogo}{}}
\mstr@iftext\mstr@opt@cclogocurr{euro}{\metaset[curr]{licenselogo}{-eu}}
\mstr@iftext\mstr@opt@cclogocurr{yen}{\metaset[curr]{licenselogo}{-jp}}
%    \end{macrocode}
% Select shape versions:
%    \begin{macrocode}
\mstr@iftext\mstr@opt@cclogoshape{box}{\metaset[shape]{licenselogo}{-88x31}}
\mstr@iftext\mstr@opt@cclogoshape{slim}{\metaset[shape]{licenselogo}{-80x15}}
%    \end{macrocode}

% \macro{\mstr@setcclogo}
% Use the Creative Commons logos
% included in the \ctanpkg{doclicense} package:
%    \begin{macrocode}
\newcommand{\mstr@setcclogo}{%
  \ifmstr@opt@cclogo
    \IfFileExists{doclicense.sty}{%
      \ifdefined\includegraphics
      \IfFileExists{doclicense-CC-by-88x31.pdf}
        {\metaset[size]{licenselogo}{-88x31}}{}
      \metaset{licenselogo}{%
        \metapick[logo]{licensecc}\metaget[curr]{licenselogo}%
        \metaget[shape]{licenselogo}}%
      \metaset[nocurr]{licenselogo}{%
        \metapick[logo]{licensecc}\metaget[shape]{licenselogo}}%
      \fi}{\GenericWarning{please install package `doclicense'}}%
  \fi}
%    \end{macrocode}

% \macro{icon}
% |icon| variants used for the license icons
% provided by the \ctanpkg{ccicons} package:
%    \begin{macrocode}
\metaset[icon]{licensecc}{%
  \metaget[icon]{cc@license\metaget[]{cc@class}}%
  \metapick[icon]{cc@\metaget[]{cc@type}}}
\metaset[icon]{licenseccver}{\metaget[]{licenseversion}}
\metaset[icon]{licenseccfull}{%
  \metaget[icon]{licensecc}
  \metaget[icon]{licenseccver}}
\metasetterm[icon]{cc@sep}{}
\metasetterm[icon]{cc@cc}{\ccLogo}
\metasetterm[icon]{cc@pd}{\ccPublicDomain}
\metasetterm[icon]{cc@zero}{\ccZero}
\metasetterm[icon]{cc@by}{\ccAttribution}
\metasetterm[icon]{cc@sa}{\ccShareAlike}
\metasetterm[icon]{cc@nd}{\ccNoDerivatives}
\metasetterm[icon]{cc@nc}{\ccNonCommercial}
\metaset[icon]{cc@license}{\metatranslate[#1]{cc@cc}}
\metaset[icon]{cc@license@zero}{\metatranslate[#1]{cc@cc}}
\metaset[icon]{cc@license@pd}{\metatranslate[#1]{cc@pd}}
\metaset[icon]{copyrightmark}{\ccCopy}
%    \end{macrocode}
% Use euro or yen sign versions:
%    \begin{macrocode}
\mstr@iftext\mstr@opt@cclogocurr{euro}{
  \metasetterm[icon]{cc@nc}{\ccNonCommercialEU}}
\mstr@iftext\mstr@opt@cclogocurr{yen}{
  \metasetterm[icon]{cc@nc}{\ccNonCommercialJP}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{License URL.}
%
% \macro{url}
% The |url| variant of compounds are used for the license URL.
%    \begin{macrocode}
\metaset[url]{licenseccver}{\metaget[]{licenseversion}}
\metaset[url]{licenseccfull}{%
  \metaget[url]{cc@license\metaget[]{cc@class}}/%
  \metapick[url]{licensecc}/%
  \metaget[url]{licenseccver}/}
\metaset[url]{cc@license}{https://creativecommons.org/licenses}
\metaset[url]{cc@license@zero}{https://creativecommons.org/publicdomain}
\metaset[url]{cc@zero}{zero}
\metaset[url]{cc@by}{by}
\metaset[url]{cc@by-sa}{by-sa}
\metaset[url]{cc@by-nd}{by-nd}
\metaset[url]{cc@by-nc}{by-nc}
\metaset[url]{cc@by-nc-sa}{by-nc-sa}
\metaset[url]{cc@by-nc-nd}{by-nc-nd}
%    \end{macrocode}

% Declare registers for internationalisation of deed URL:
%    \begin{macrocode}
\metadef{cc@url}
\metadef{cc@url@deed}
%    \end{macrocode}
% Fill registers:
% \translate{cc@url@deed}
%    \begin{macrocode}
\metaset{cc@url@deed}{}
\metaset{cc@url}{\metapick[url]{licenseccfull}\metapick[#1]{cc@url@deed}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{License Preset.}
%
% \macro{\metalicensecc}
% Set the CC license of type `|#1|':
%    \begin{macrocode}
\newcommand{\metalicensecc}[1]{%
  \def\mstr@tmpl{#1}%
  \def\mstr@tmp{pd}%
  \ifx\mstr@tmpl\mstr@tmp
    \metaset{cc@class}{@pd}%
    \metacopyright{publicdomain}%
    \metaset{cc@type}{pd}%
  \else
    \def\mstr@tmp{zero}%
    \ifx\mstr@tmpl\mstr@tmp
      \metaset{cc@class}{@zero}%
      \metaif[]{licenseversion}{}{\metaset{licenseversion}{1.0}}%
    \else
      \metaset{cc@class}{}%
      \metaif[]{licenseversion}{}{\metaset{licenseversion}{4.0}}%
    \fi
    \metaset{cc@type}{#1}%
    \metaset{licenseurl}{\metapick[##1]{cc@url}}%
    \metaset{licensemessage}
      {\metapick[##1]{cc@message\metaget[]{cc@class}}}%
  \fi
  \mstr@setcclogo}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Contact Information}
% \label{sec:imp-contact}
%
% The following describes an interface
% to store and write contact information.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Declarations.}
%
% \macro{contact...}
% Contact register declarations:
%    \begin{macrocode}
\metadef{contactaddress}
\metadef{contactpostcode}
\metadef{contactcity}
\metadef{contactregion}
\metadef{contactcountry}
\metadef{contactemail}
\metadef{contacturl}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Write to PDF.}
%
% \macro{\metawritepdfcontact}
% Write contact information to PDF via \ctanpkg{hyperxmp}:
%    \begin{macrocode}
\newcommand{\metawritepdfcontact}{\ifdefined\hypersetup\ifdefined\xmptilde
  \metaifpick[\mstr@lang@meta]{contactaddress}{%
    \hypersetup{pdfcontactaddress=
      {\metapick[\mstr@lang@meta]{contactaddress}}}}{}%
  \metaifpick[\mstr@lang@meta]{contactpostcode}{%
    \hypersetup{pdfcontactpostcode=
      {\metapick[\mstr@lang@meta]{contactpostcode}}}}{}%
  \metaifpick[\mstr@lang@meta]{contactcity}{%
    \hypersetup{pdfcontactcity=
      {\metapick[\mstr@lang@meta]{contactcity}}}}{}%
  \metaifpick[\mstr@lang@meta]{contactregion}{%
    \hypersetup{pdfcontactregion=
      {\metapick[\mstr@lang@meta]{contactregion}}}}{}%
  \metaifpick[\mstr@lang@meta]{contactcountry}{%
    \hypersetup{pdfcontactcountry=
      {\metapick[\mstr@lang@meta]{contactcountry}}}}{}%
  \metaifpick[\mstr@lang@meta]{contactemail}{%
    \hypersetup{pdfcontactemail=
      {\metapick[\mstr@lang@meta]{contactemail}}}}{}%
  \metaifpick[\mstr@lang@meta]{contacturl}{%
    \hypersetup{pdfcontacturl=
      {\metapick[\mstr@lang@meta]{contacturl}}}}{}%
\fi\fi}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Extras}
% \label{sec:imp-extra}
%
% The following defines some extras to be activated by package options.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Course Metadata.}
%
% Include structures for course materials:
%    \begin{macrocode}
\ifmstr@opt@course
%    \end{macrocode}

%\macro{institution}
%\macro{instructor}
%\macro{course}
%\macro{material}
%\macro{period}
% Declare course structures:
%    \begin{macrocode}
\metadef{institution}
\metadef{instructor}
\metadef{course}
\metadef{material}
\metadef{period}
%    \end{macrocode}

% Preset formatting styles:
%    \begin{macrocode}
\metaset[style]{course}{\LARGE\bfseries}
\metaset[style]{material}{\large}
\metaset[style]{institution}{\large}
\metaset[style]{period}{\large}
\metaset[style]{instructor}{\scshape\Large}
\metaset[skip]{material}{\vspace{2ex}}
\metaset[skip]{institution}{\vspace{4ex}}
\metaset[skip]{period}{\vspace{4ex}}
\metaset[skip]{instructor}{\vspace{6ex}}
\metaset[sep]{period}{, }
%    \end{macrocode}

% Fill |titletext| in |course| variant to display
% relevant title data for the course material:
%    \begin{macrocode}
\metaset[course]{titlematter}{%
  \metapick[course]{titletext}%
  \metapick[course]{datatext}%
  \metapick[course]{authortext}%
  \metaget[skip]{titlematter}}
\metaset[course]{titletext}{%
  \metatitleline[print]{course}%
  \metatitlelinetwo[print]{material}[print]{draft}}
\metaset[course]{authortext}{%
  \metatitleline[print]{instructor}}
\metaset[course]{datatext}{%
  \metatitlelinetwo[print]{institution}[print]{period}}
%    \end{macrocode}
% Legacy presets:
%    \begin{macrocode}
\ifmstr@opt@titlematter\else
\metaset[course]{titlematter}{%
  \metapick[course]{titletext}%
  \metaget[skip]{titlematter}}
\metaset[course]{titletext}{%
  \metatitleline[print]{course}%
  \metatitlelinetwo[print]{material}[print]{draft}%
  \metapick[course]{datatext}%
  \metapick[course]{authortext}}
\fi
%    \end{macrocode}

% Inherit title, subtitle, author and date:
%    \begin{macrocode}
\metaset{title}{\metapick[#1]{course}}
\metaset{subtitle}{\metapick[#1]{material}}
\metaset{author}{\metapick[#1]{instructor}}
\metaset{date}{\metapick[#1]{period}}
\metaset{location}{\metapick[#1]{institution}}
%    \end{macrocode}

%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Translations}
% \label{sec:imp-translate}
%
% Determine all desired international versions to be loaded;
% use first one as fallback language:
%    \begin{macrocode}
\def\mstr@loadlangloop#1|#2&{%
  \mstr@csdo\let{mstr@lang@#1}\relax%
  \ifx\mstr@lang@fallback\@empty\def\mstr@lang@fallback{#1}\fi%
  \if @#2@\else\mstr@loadlangloop#2&\fi}
\expandafter\mstr@loadlangloop\mstr@opt@loadlang|&
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{English.}
%
% Check whether to load English strings:
%    \begin{macrocode}
\ifdefined\mstr@lang@en
%    \end{macrocode}

% Terms:
%    \begin{macrocode}
\metasetterm[en]{title}{Title}
\metasetterm[en]{abstract}{Abstract}
\metasetterm[en]{copyright}{Copyright}
\metasetterm[en]{preface}{Preface}
\metasetterm[en]{part}{Part}
\metasetterm[en]{chapter}{Chapter}
\metasetterm[en]{section}{Section}
\metasetterm[en]{subsection}{Subsection}
\metasetterm[en]{paragraph}{Paragraph}
\metasetterm[en]{appendix}{Appendix}
\metasetterm[en]{page}{Page}
\metasetterm[en]{figure}{Figure}
\metasetterm[en]{table}{Table}
\metasetterm[en]{contents}{Contents}
\metasetterm[en]{listfigure}{List of Figures}
\metasetterm[en]{listtable}{List of Tables}
\metasetterm[en]{references}{References}
\metasetterm[en]{index}{Index}
\metasetterm[en]{draft}{DRAFT}
%    \end{macrocode}

% General purpose messages:
%    \begin{macrocode}
\metaset[en]{urlmessage}{%
  The current version of this work can be found at: \metapick[#1]{url}.}
\metaset[en]{partofmessage}{%
  This document is part of the work: \metapick[#1]{partof}.}
\metaset[en]{licenseurlmessage}{%
  To view a copy of this license, visit: \metapick[#1]{licenseurl}.}
%    \end{macrocode}
% Copyright statements:
%    \begin{macrocode}
\metaset[en]{copyright@plain}{%
  This work is protected by copyright.}
\metaset[en]{copyright@parts}{%
  This work as well as its parts is protected by copyright.}
\metaset[en]{copyright@doc}{%
  This document is protected by copyright.}
\metaset[en]{copyright@doc-parts}{%
  This document as well as its parts is protected by copyright.}
\metaset[en]{copyright@reserved}{All rights reserved.}
\metaset[en]{copyright@publicdomain}
  {This work is dedicated to the public domain.}
%    \end{macrocode}
% License statements:
%    \begin{macrocode}
\metaset[en]{license@consent}{%
  Reproduction of any part of this work in any form
  without prior written consent
  \metacompose[#1]{licenseprovider}{}{}{of the author}
  is not permissible.}
\metaset[en]{license@consent-noncom}{%
  Reproduction of any part of this work in any form
  without prior written consent
  \metacompose[#1]{licenseprovider}{}{}{of the author}
  is permissible only for private, scientific and non-commercial use.}
\metaset[en]{license@lppl}{%
  This work may be distributed and/or modified under the
  conditions of the LaTeX Project Public License, either version
  \metaif[]{licenseversion}{\metaget[]{licenseversion}}{1.3}
  of this license or (at your option) any later version.}
%    \end{macrocode}
% Creative Commons license composition:
%    \begin{macrocode}
\metaset[en]{cc@url@deed}{deed.en}
\metaset[en]{cc@message}{%
  This work is licensed under the
  \metapick[en]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[en]{cc@message@zero}{%
  This work is dedicated to the public domain by means of the
  \metapick[#1]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[en]{cc@license}{%
  \metatranslate[#1]{cc@cc} \metatranslate[#1]{cc@license}}
\metaset[en]{cc@license@zero}{%
  \metatranslate[#1]{cc@cc} \metatranslate[#1]{cc@pddecl}}
\metasetterm[en]{cc@sep}{-}
\metasetterm[en]{cc@quotel}{\textquotedblleft}
\metasetterm[en]{cc@quoter}{\textquotedblright}
\metasetterm[en]{cc@by}{Attribution}
\metasetterm[en]{cc@sa}{ShareAlike}
\metasetterm[en]{cc@nd}{NoDerivatives}
\metasetterm[en]{cc@nc}{NonCommercial}
\metasetterm[en]{cc@unported}{Unported}
\metasetterm[en]{cc@generic}{Generic}
\metasetterm[en]{cc@intl}{International}
\metasetterm[en]{cc@univ}{Universal}
\metasetterm[en]{cc@license}{License}
\metasetterm[en]{cc@pd}{Public Domain}
\metasetterm[en]{cc@pddecl}{Public Domain Dedication}
%    \end{macrocode}

%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{German.}
%
% Check whether to load German strings:
%    \begin{macrocode}
\ifdefined\mstr@lang@de
%    \end{macrocode}

% Terms:
%    \begin{macrocode}
\metasetterm[de]{title}{Titel}
\metasetterm[de]{abstract}{Zusammenfassung}
\metasetterm[de]{copyright}{Urheberrechte}
\metasetterm[de]{preface}{Vorwort}
\metasetterm[de]{part}{Teil}
\metasetterm[de]{chapter}{Kapitel}
\metasetterm[de]{section}{Abschnitt}
\metasetterm[de]{subsection}{Unterabschnitt}
\metasetterm[de]{paragraph}{Absatz}
\metasetterm[de]{appendix}{Anhang}
\metasetterm[de]{page}{Seite}
\metasetterm[de]{figure}{Abbildung}
\metasetterm[de]{table}{Tabelle}
\metasetterm[de]{contents}{Inhaltsverzeichnis}
\metasetterm[de]{listfigure}{Abbildungsverzeichnis}
\metasetterm[de]{listtable}{Tabellenverzeichnis}
\metasetterm[de]{references}{Literatur}
\metasetterm[de]{index}{Index}
\metasetterm[de]{draft}{ENTWURF}
%    \end{macrocode}

% General purpose messages:
%    \begin{macrocode}
\metaset[de]{urlmessage}{%
  Die aktuelle Version dieses Werks befindet sich unter:
  \metapick[#1]{url}.}
\metaset[de]{partofmessage}{%
  Dieses Dokument ist Teil des Werks: \metapick[#1]{partof}.}
\metaset[de]{licenseurlmessage}{%
  Die Lizenz kann eingesehen werden unter:
  \metapick[#1]{licenseurl}.}
%    \end{macrocode}
% Copyright statements:
%    \begin{macrocode}
\metaset[de]{copyright@plain}{%
  Dieses Werk ist urheberrechtlich gesch\"utzt.}
\metaset[de]{copyright@parts}{%
  Dieses Werk sowie seine Teile sind urheberrechtlich gesch\"utzt.}
\metaset[de]{copyright@doc}{%
  Dieses Dokument ist urheberrechtlich gesch\"utzt.}
\metaset[de]{copyright@doc-parts}{%
  Dieses Dokument sowie seine Teile sind urheberrechtlich gesch\"utzt.}
\metaset[de]{copyright@reserved}{Alle Rechte vorbehalten.}
\metaset[de]{copyright@publicdomain}
  {Dieses Werk ist gemeinfrei.}
%    \end{macrocode}
% License statements:
%    \begin{macrocode}
\metaset[de]{license@consent}{%
  Reproduktion eines Teils dieses Werks in beliebiger Form
  ohne vorg\"angige schriftliche Erlaubnis
  \metacompose[#1]{licenseprovider}{}{}{des Verfassers}
  ist nicht gestattet.}
\metaset[de]{license@consent-noncom}{%
  Reproduktion eines Teils dieses Werks in beliebiger Form
  ohne vorg\"angige schriftliche Erlaubnis
  \metacompose[#1]{licenseprovider}{}{}{des Verfassers}
  ist nur zum privaten, wissenschaftlichen
  und nicht-gewerblichen Gebrauch gestattet.}
\metaset[de]{license@lppl}{%
  Dieses Werk darf nach den Bedingungen der LaTeX Project Public Lizenz,
  entweder Version
  \metaif[]{licenseversion}{\metaget[]{licenseversion}}{1.3}
  oder (nach Ihrer Wahl) jede sp\"atere Version,
  verteilt und/oder ver\"andert werden.}
%    \end{macrocode}
% Creative Commons license composition:
%    \begin{macrocode}
\metaset[de]{cc@url@deed}{deed.de}
\metaset[de]{cc@message}{%
  Dieses Werk ist lizensiert unter der
  \metapick[de]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[de]{cc@message@zero}{%
  Dieses Werk ist gemeinfrei deklariert mittels der
  \metapick[de]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[de]{cc@license}{%
  \metatranslate[#1]{cc@cc} \metatranslate[#1]{cc@license}}
\metaset[de]{cc@license@zero}{%
  \metatranslate[#1]{cc@cc} \metatranslate[#1]{cc@pddecl}}
\metasetterm[de]{cc@sep}{ -- }
\metasetterm[de]{cc@quotel}{\quotedblbase}
\metasetterm[de]{cc@quoter}{\textquotedblleft}
\metasetterm[de]{cc@by}{Namensnennung}
\metasetterm[de]{cc@sa}{Weitergabe unter gleichen Bedingungen}
\metasetterm[de]{cc@nd}{Keine Bearbeitungen}
\metasetterm[de]{cc@nc}{Nicht kommerziell}
\metasetterm[de]{cc@unported}{Unportiert}
\metasetterm[de]{cc@generic}{Generisch}
\metasetterm[de]{cc@intl}{International}
\metasetterm[de]{cc@univ}{Universell}
\metasetterm[de]{cc@license}{Lizenz}
\metasetterm[de]{cc@pd}{Gemeinfrei}
\metasetterm[de]{cc@pddecl}{Gemeinfrei Deklaration}
%    \end{macrocode}

%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{French.}
%
% Disclaimer: professional assistance with translations needed.
%
% Check whether to load French strings:
%    \begin{macrocode}
\ifdefined\mstr@lang@fr
%    \end{macrocode}

% Terms:
%    \begin{macrocode}
\metasetterm[fr]{title}{Titre}
\metasetterm[fr]{abstract}{R\'esum\'e}
\metasetterm[fr]{copyright}{Droits d'Auteur}
\metasetterm[fr]{preface}{Pr\'eface}
\metasetterm[fr]{part}{Partie}
\metasetterm[fr]{chapter}{Chapitre}
\metasetterm[fr]{section}{Section}
\metasetterm[fr]{subsection}{Sous-Section}
\metasetterm[fr]{paragraph}{Paragraphe}
\metasetterm[fr]{appendix}{Annexe}
\metasetterm[fr]{page}{Page}
\metasetterm[fr]{figure}{Figure}
\metasetterm[fr]{table}{Table}
\metasetterm[fr]{contents}{Table des Mati\`eres}
\metasetterm[fr]{listfigure}{Table des Figures}
\metasetterm[fr]{listtable}{Liste des Tableaux}
\metasetterm[fr]{references}{R\'ef\'erences}
\metasetterm[fr]{index}{Index}
\metasetterm[fr]{draft}{BROUILLON}
%    \end{macrocode}

% General purpose messages:
%    \begin{macrocode}
\metaset[fr]{urlmessage}{%
  La version actuelle de cet \oe uvre se trouve \`a l'adresse:
  \metapick[#1]{url}.}
\metaset[fr]{partofmessage}{%
  Ce document fait partie de la \oe uvre: \metapick[#1]{partof}.}
\metaset[fr]{licenseurlmessage}{%
  Pour voir une copie de cette licence, visitez:
  \metapick[#1]{licenseurl}.}
%    \end{macrocode}
% Copyright statements:
%    \begin{macrocode}
\metaset[fr]{copyright@plain}{%
  Cette \oe uvre est prot\'eg\'ee par le droit d'auteur.}
\metaset[fr]{copyright@parts}{%
  Cette \oe uvre ainsi que ses parties
  sont prot\'eg\'ees par le droit d'auteur.}
\metaset[fr]{copyright@doc}{%
  Ce document est prot\'eg\'es par le droit d'auteur.}
\metaset[fr]{copyright@doc-parts}{%
  Ce document ainsi que ses parties
  sont prot\'eg\'es par le droit d'auteur.}
\metaset[fr]{copyright@reserved}{Tous les droits sont r\'eserv\'es.}
\metaset[fr]{copyright@publicdomain}
  {Cette \oe uvre est du domaine public.}
%    \end{macrocode}
% Creative Commons license composition:
%    \begin{macrocode}
\metaset[fr]{cc@url@deed}{deed.fr}
\metaset[fr]{cc@message}{%
  Cette \oe uvre est mise \`a disposition selon les termes de la
  \metapick[fr]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[fr]{cc@message@zero}{%
  Cette \oe uvre est d\'eclar\'ee du domaine public par le
  \metapick[fr]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[fr]{cc@license}{%
  \metatranslate[#1]{cc@license} \metatranslate[#1]{cc@cc}}
\metaset[fr]{cc@license@zero}{%
  \metatranslate[#1]{cc@pddecl} \metatranslate[#1]{cc@cc}}
\metasetterm[fr]{cc@sep}{ -- }
\metasetterm[fr]{cc@quotel}{\guillemotleft}
\metasetterm[fr]{cc@quoter}{\guillemotright}
\metasetterm[fr]{cc@by}{Attribution}
\metasetterm[fr]{cc@sa}{Partage dans les M\^emes Conditions}
\metasetterm[fr]{cc@nd}{Pas de Modification}
\metasetterm[fr]{cc@nc}{Pas d'Utilisation Commerciale}
\metasetterm[fr]{cc@unported}{Non Transpos\'e}
\metasetterm[fr]{cc@generic}{G\'en\'erique}
\metasetterm[fr]{cc@intl}{International}
\metasetterm[fr]{cc@univ}{Universel}
\metasetterm[fr]{cc@license}{Licence}
\metasetterm[fr]{cc@pd}{Domaine Public}
\metasetterm[fr]{cc@pddecl}{Transfert dans le Domaine Public}
%    \end{macrocode}

%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Spanish.}
%
% Disclaimer: professional assistance with translations needed.
%
% Check whether to load Spanish strings:
%    \begin{macrocode}
\ifdefined\mstr@lang@es
%    \end{macrocode}

% Terms:
%    \begin{macrocode}
\metasetterm[es]{chapter}{Cap\'itulo}
\metasetterm[es]{section}{Secci\'on}
\metasetterm[es]{subsection}{Subsecci\'on}
\metasetterm[es]{paragraph}{P\'arrafo}
\metasetterm[es]{title}{T\'itulo}
\metasetterm[es]{abstract}{Resumen}
\metasetterm[es]{copyright}{Derechos de Autor}
\metasetterm[es]{preface}{Prefacio}
\metasetterm[es]{part}{Parte}
\metasetterm[es]{appendix}{Ap\'endice}
\metasetterm[es]{page}{P\'agina}
\metasetterm[es]{figure}{Figura}
\metasetterm[es]{table}{Cuadro}
\metasetterm[es]{contents}{\'Indice}
\metasetterm[es]{listfigure}{\'Indice de Figuras}
\metasetterm[es]{listtable}{\'Indice de Cuadros}
\metasetterm[es]{references}{Referencias}
\metasetterm[es]{index}{\'Indice Alfab\'etico}
\metasetterm[es]{draft}{BORRADOR}
%    \end{macrocode}

% General purpose messages:
%    \begin{macrocode}
\metaset[es]{urlmessage}{%
  La versi\'on actual de esta obra se puede encontrar en:
  \metapick[#1]{url}.}
\metaset[es]{partofmessage}{%
  Este documento es parte de la obra: \metapick[#1]{partof}.}
\metaset[es]{licenseurlmessage}{%
  Para ver una copia de esta licencia, visite:
  \metapick[#1]{licenseurl}.}
%    \end{macrocode}
% Copyright statements:
%    \begin{macrocode}
\metaset[es]{copyright@plain}{%
  Esta obra est\'a protegida por derechos de autor.}
\metaset[es]{copyright@parts}{%
  Esta obra y sus partes est\'an protegidas por derechos de autor.}
\metaset[es]{copyright@doc}{%
  Este documento est\'a protegido por derechos de autor.}
\metaset[es]{copyright@doc-parts}{%
  Este documento y sus partes est\'an protegidos por derechos de autor.}
\metaset[es]{copyright@reserved}{Todos los derechos reservados.}
\metaset[es]{copyright@publicdomain}
  {Esta obra es de dominio p\'ublico.}
%    \end{macrocode}
% Creative Commons license composition:
%    \begin{macrocode}
\metaset[es]{cc@url@deed}{deed.es}
\metaset[es]{cc@message}{%
  Esta obra est\'a bajo la
  \metapick[es]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[es]{cc@message@zero}{Esta obra est\'a dedicada
  al dominio p\'ublico por la
  \metapick[es]{licenseccfull} (\metapick[short]{licenseccfull}).}
\metaset[es]{cc@license}{%
  \metatranslate[#1]{cc@license} \metatranslate[#1]{cc@cc}}
\metaset[es]{cc@license@zero}{%
  \metatranslate[#1]{cc@pddecl} \metatranslate[#1]{cc@cc}}
\metasetterm[es]{cc@sep}{-}
\metasetterm[es]{cc@quotel}{\textquotedblleft}
\metasetterm[es]{cc@quoter}{\textquotedblright}
\metasetterm[es]{cc@by}{Atribuci\'on}
\metasetterm[es]{cc@sa}{CompartirIgual}
\metasetterm[es]{cc@nd}{SinDerivadas}
\metasetterm[es]{cc@nc}{NoComercial}
\metasetterm[es]{cc@unported}{No Portada}
\metasetterm[es]{cc@generic}{Gen\'erica}
\metasetterm[es]{cc@intl}{Internacional}
\metasetterm[es]{cc@univ}{Universal}
\metasetterm[es]{cc@license}{Licencia}
\metasetterm[es]{cc@pd}{Dominio P\'ublico}
\metasetterm[es]{cc@pddecl}{Dedicaci\'on de Dominio P\'ublico}
%    \end{macrocode}

%    \begin{macrocode}
\fi
%    \end{macrocode}

%\iffalse
%</package>
%\fi
%
\endinput
