[latex3-commits] [latex3/latex2e] testmergearray: set metadata from title (f4bd9193)
github at latex-project.org
github at latex-project.org
Sun Dec 24 01:10:09 CET 2023
Repository : https://github.com/latex3/latex2e
On branch : testmergearray
Link : https://github.com/latex3/latex2e/commit/f4bd919350022fdac1df0ef1ce83a8f554ee8c11
>---------------------------------------------------------------
commit f4bd919350022fdac1df0ef1ce83a8f554ee8c11
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sun Dec 24 01:10:09 2023 +0100
set metadata from title
>---------------------------------------------------------------
f4bd919350022fdac1df0ef1ce83a8f554ee8c11
required/latex-lab/config-title.lua | 11 ++
required/latex-lab/latex-lab-title.dtx | 145 +++++++++++++++++-
required/latex-lab/testfiles-title/title-001.lvt | 13 ++
required/latex-lab/testfiles-title/title-001.tlg | 186 +++++++++++++++++++++++
4 files changed, 348 insertions(+), 7 deletions(-)
diff --git a/required/latex-lab/config-title.lua b/required/latex-lab/config-title.lua
new file mode 100644
index 00000000..3212a6ed
--- /dev/null
+++ b/required/latex-lab/config-title.lua
@@ -0,0 +1,11 @@
+-- Tests for output routine stuff
+--
+-- Tests here only function locally due to the class not loaded in github actions!
+
+
+checkengines = {"pdftex","luatex"}
+checksearch = true
+testfiledir = "testfiles-title"
+
+checkruns = 1
+
diff --git a/required/latex-lab/latex-lab-title.dtx b/required/latex-lab/latex-lab-title.dtx
index c4099f7f..e529f1c3 100644
--- a/required/latex-lab/latex-lab-title.dtx
+++ b/required/latex-lab/latex-lab-title.dtx
@@ -52,7 +52,7 @@
% The followings contains changes to improve the tagging of
% the title created with the \cs{maketitle} command in the standard classes.
%
-% For basic tagging they are basically three main things to do:
+% For basic tagging they are basically three things to do:
%
% \begin{itemize}
% \item The actual title should be tagged with the \texttt{Title} tag.
@@ -60,6 +60,28 @@
% \item \cs{maketitle} redefines footnote internals. These must be made tagging aware.
% \end{itemize}
%
+% A second task related to title is to use it (or a shorter version) inside the
+% XMP-metadata and in the displayed title. Currently this can only be set if hyperref
+% is loaded and requires the use of the \texttt{pdftitle} key.
+% The new code therefore extends the \cs{title} command: It stores its argument and
+% uses it at the end of the document for the PDF metadata if the PDF title
+% hasn't been given in another way.
+% It also gives \cs{title} an optional argument where the PDF title can be given with
+% the pdftitle key. As with hyperref it is possible to store titles
+% in more than one language:
+%
+% \begin{verbatim}
+% \title
+% [pdftitle =
+% {[en]English Title,[de] Deutscher Titel,[fr]{titre français, avec comma}}]
+% {Document title}
+% \end{verbatim}
+%
+% If hyperref is loaded there is no difference to the \texttt{pdftitle}
+% of \cs{hypersetup}. Both can be used.
+%
+%
+%
% \section{Implementation}
% \begin{macrocode}
%<*package>
@@ -136,8 +158,14 @@
\vskip 2em%
\begin{center}%
\let \footnote \thanks
- {\LARGE \tagtool{paratag=Title}\@title \par}%
- \vskip 1.5em%
+% \end{macrocode}
+% use Title around the title. As in PDF 1.7 this is
+% rolemapped to P we change the text-unit tag there.
+% \begin{macrocode}
+ \pdf_version_compare:NnTF > {1.7}
+ {{\LARGE \tag_struct_begin:n{tag=Title}\@title \par\tag_struct_end:}}
+ {{\LARGE \tagtool{paratag=Title}\@title \par}}%
+ \vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
@@ -165,12 +193,14 @@
\null\vfil
\vskip 60\p@
% \end{macrocode}
-% use Title around the title. As in PDF 2.0 this is rolemapped to P
-% we change the text-unit tag here.
+% use Title around the title. As in PDF 1.7 this is
+% rolemapped to P we change the text-unit tag there.
% \begin{macrocode}
\begin{center}%
- {\LARGE \tagtool{paratag=Title}\@title\par}%
- \vskip 3em%
+ \pdf_version_compare:NnTF > {1.7}
+ {{\LARGE \tag_struct_begin:n{tag=Title}\@title \par\tag_struct_end:}}
+ {{\LARGE \tagtool{paratag=Title}\@title \par}}%
+ \vskip 3em%
{\large
\lineskip .75em%
\begin{tabular}[t]{c}%
@@ -225,6 +255,107 @@
\cs_set_eq:NN \@maketitle \@@_patch_ at maketitle:
\fi
}
+% \end{macrocode}
+% \subsection{Extend title to set metadata}
+% At first a variable to store the title, as \cs{@title} is emptied by \LaTeX.
+% \begin{macrocode}
+\tl_new:N \g_@@_title_text_tl
+% \end{macrocode}
+% Now we redefine \cs{title} so that it stores the title, and processes
+% keys in the optional argument. We use \texttt{hyp} as module
+% name for the key as this means that it hyperref is loaded its definition
+% of \textt{pdftitle} will be used -- at some time probably this
+% should be moved out of hyperref so that we have only one definition.
+%
+% \begin{macrocode}
+\RenewDocumentCommand\title{O{}m}
+ {
+ \gdef\@title{#2}
+ \cs_gset_eq:NN\g_@@_title_text_tl\@title
+ \keys_set:nn {hyp}{#1}
+ }
+% \end{macrocode}
+%We offer also support for \cs{texorpdfstring}
+% \begin{macrocode}
+\providecommand\texorpdfstring[2]{#1}%
+% \end{macrocode}
+% Now we define the \texttt{pdftitle} key. This is more or less
+% the same definition as in the generic hyperref driver.
+% \begin{macrocode}
+\str_new:N \g_@@_title_tmpa_str
+\str_new:N \l_@@_title_tmpa_str
+\tl_new:N \l_@@_title_tmpa_tl
+\seq_new:N \l_@@_title_tmpa_seq
+\regex_new:N\l_@@_title_optlang_regex
+\regex_set:Nn\l_@@_title_optlang_regex {\A\[([A-Za-z\-]+)\](.*)}
+\cs_generate_variant:Nn \regex_extract_once:NnN{NVN}
+\cs_generate_variant:Nn \clist_item:nn {on}
+% \end{macrocode}
+% A helper command to convert the title into a pdfstring
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_title_pdfstring:nnN #1 #2 #3
+ {
+ \group_begin:
+% \end{macrocode}
+% TODO: we need probably a common boolean to handle
+% \cs{texorpdfstring} also without hyperref.
+% \begin{macrocode}
+ \cs_set_eq:NN\texorpdfstring\use_ii:nn
+ \str_set:Ne \l_@@_title_tmpa_str {\text_purify:n { #1 } }
+ \pdf_string_from_unicode:nVN { #2 } \l_@@_title_tmpa_str \l_@@_title_tmpa_str
+ \str_gset_eq:NN \g_@@_title_tmpa_str\l_@@_title_tmpa_str
+ \group_end:
+ \str_set_eq:NN #3 \g_@@_title_tmpa_str
+ }
+\cs_generate_variant:Nn\@@_title_pdfstring:nnN {e}
+% \end{macrocode}
+% and now the key.
+% \begin{macrocode}
+\keys_define:nn { hyp }
+ {
+ pdftitle .code:n =
+ {
+ \tl_if_blank:nTF {#1}
+ {
+ \pdfmanagement_remove:nn {Info}{Title}
+ }
+ {
+ \tl_set:Ne\l_@@_title_tmpa_tl {\clist_item:on{#1}{1}}
+ \regex_extract_once:NVN
+ \l_@@_title_optlang_regex
+ \l_@@_title_tmpa_tl
+ \l_@@_title_tmpa_seq
+ \seq_if_empty:NTF\l_@@_title_tmpa_seq
+ {
+ \@@_title_pdfstring:nnN {#1}{utf16/hex}\l_@@_title_tmpa_str
+ }
+ {
+ \@@_title_pdfstring:enN
+ {\seq_item:Nn \l_@@_title_tmpa_seq{3}}{utf16/hex}\l_@@_title_tmpa_str
+ }
+ \str_if_eq:VnF\l_@@_title_tmpa_str{<FEFF>}
+ {
+ \pdfmanagement_add:nne {Info}{Title}{\l_@@_title_tmpa_str}
+ }
+ }
+ \AddToDocumentProperties[hyperref]{pdftitle}{#1}
+ }
+ }
+% \end{macrocode}
+% At last we set the title at the end of document
+% if that hasn't happened yet:
+% \begin{macrocode}
+\AddToHook{enddocument}
+ {
+ \tl_if_empty:eT{\GetDocumentProperties{hyperref/pdftitle}}
+ {
+ \group_begin:
+ \cs_set_eq:NN\thanks \use_none:n
+ \str_set:Ne \l_@@_title_tmpa_str {\text_purify:n { \g_@@_title_text_tl } }
+ \keys_set:ne{hyp}{pdftitle=\exp_not:V\l_@@_title_tmpa_str}
+ \group_end:
+ }
+ }
%</package>
% \end{macrocode}
diff --git a/required/latex-lab/testfiles-title/title-001.lvt b/required/latex-lab/testfiles-title/title-001.lvt
new file mode 100644
index 00000000..20f1d4e0
--- /dev/null
+++ b/required/latex-lab/testfiles-title/title-001.lvt
@@ -0,0 +1,13 @@
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation }
+\ExplSyntaxOff
+\DocumentMetadata{uncompress,testphase=title}
+\input{regression-test}
+\documentclass[]{article}
+
+\author{author A \and author B}
+\title{A title\thanks{Note}}
+\begin{document}
+\START \showoutput
+\maketitle
+\end{document}
diff --git a/required/latex-lab/testfiles-title/title-001.tlg b/required/latex-lab/testfiles-title/title-001.tlg
new file mode 100644
index 00000000..ee6ae2c4
--- /dev/null
+++ b/required/latex-lab/testfiles-title/title-001.tlg
@@ -0,0 +1,186 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <17.28> on input line ....
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <12> on input line ....
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <8> on input line ....
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <6> on input line ....
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <5> on input line ....
+Completed box being shipped out [1]
+\vbox(633.0+0.0)x407.0
+.\hbox(0.0+0.0)x0.0
+..\kern -72.26999
+..\vbox(0.0+0.0)x0.0, glue set 72.26999fil
+...\kern -72.26999
+...\hbox(0.0+0.0)x0.0
+....\glue 0.0 plus 1.0fil minus 1.0fil
+...\glue 0.0 plus 1.0fil minus 1.0fil
+.\glue 16.0
+.\vbox(617.0+0.0)x345.0, shifted 62.0
+..\vbox(12.0+0.0)x345.0, glue set 12.0fil
+...\glue 0.0 plus 1.0fil
+...\hbox(0.0+0.0)x345.0
+....\hbox(0.0+0.0)x345.0
+..\glue 25.0
+..\glue(\lineskip) 0.0
+..\vbox(550.0+0.0)x345.0, glue set 404.90665fil
+...\write-{}
+...\glue(\topskip) 10.0
+...\hbox(0.0+0.0)x0.0
+...\glue 20.00003
+...\glue -20.00003
+...\penalty -51
+...\glue 20.00003
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\parskip) 0.0
+...\glue(\baselineskip) 10.0
+...\hbox(12.0+0.0)x345.0, glue set 149.95718fil
+....\glue(\leftskip) 0.0 plus 1.0fil
+....\hbox(0.0+0.0)x0.0
+.....\glue 0.0
+.....\glue 0.0
+.....\glue -5.0
+.....\hbox(0.0+0.0)x0.0
+.....\glue 5.0
+....\penalty 0
+....\OT1/cmr/m/n/17.28 A
+....\glue 5.21661 plus 2.70558 minus 1.80734
+....\OT1/cmr/m/n/17.28 t
+....\OT1/cmr/m/n/17.28 i
+....\OT1/cmr/m/n/17.28 t
+....\OT1/cmr/m/n/17.28 l
+....\OT1/cmr/m/n/17.28 e
+....\hbox(11.85274+0.0)x0.0, glue set - 6.37357fil
+.....\penalty 10000
+.....\hbox(11.85274+0.0)x6.37357
+......\mathon
+......\hbox(5.58197+0.0)x6.37357, shifted -6.27077
+.......\TS1/cmr/m/n/12 *
+......\mathoff
+.....\glue 0.0 plus 1.0fil minus 1.0fil
+....\penalty 10000
+....\glue(\parfillskip) 0.0
+....\glue(\rightskip) 0.0 plus 1.0fil
+...\glue 15.00002
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\parskip) 0.0
+...\glue(\baselineskip) 4.20004
+...\hbox(9.79996+4.20004)x345.0, glue set 99.72343fil
+....\glue(\leftskip) 0.0 plus 1.0fil
+....\hbox(0.0+0.0)x0.0
+....\hbox(9.79996+4.20004)x58.66898
+.....\mathon
+.....\vbox(9.79996+4.20004)x58.66898
+......\hbox(9.79996+4.20004)x58.66898
+.......\glue(\tabskip) 0.0
+.......\hbox(9.79996+4.20004)x58.66898
+........\rule(9.79996+4.20004)x0.0
+........\glue 6.0
+........\glue 0.0 plus 1.0fil
+........\glue 0.00002
+........\OT1/cmr/m/n/12 a
+........\OT1/cmr/m/n/12 u
+........\OT1/cmr/m/n/12 t
+........\OT1/cmr/m/n/12 h
+........\OT1/cmr/m/n/12 o
+........\OT1/cmr/m/n/12 r
+........\glue 3.91663 plus 1.95831 minus 1.30554
+........\OT1/cmr/m/n/12 A
+........\glue 0.0 plus 1.0fil
+........\glue 6.0
+.......\glue(\tabskip) 0.0
+.....\mathoff
+....\glue 11.74988 plus 0.17fil
+....\hbox(9.79996+4.20004)x58.18149
+.....\mathon
+.....\vbox(9.79996+4.20004)x58.18149
+......\hbox(9.79996+4.20004)x58.18149
+.......\glue(\tabskip) 0.0
+.......\hbox(9.79996+4.20004)x58.18149
+........\rule(9.79996+4.20004)x0.0
+........\glue 6.0
+........\glue 0.0 plus 1.0fil
+........\glue 0.00002
+........\OT1/cmr/m/n/12 a
+........\OT1/cmr/m/n/12 u
+........\OT1/cmr/m/n/12 t
+........\OT1/cmr/m/n/12 h
+........\OT1/cmr/m/n/12 o
+........\OT1/cmr/m/n/12 r
+........\glue 3.91663 plus 1.95831 minus 1.30554
+........\OT1/cmr/m/n/12 B
+........\glue 0.0 plus 1.0fil
+........\glue 6.0
+.......\glue(\tabskip) 0.0
+.....\mathoff
+....\penalty 10000
+....\glue(\parfillskip) 0.0
+....\glue(\rightskip) 0.0 plus 1.0fil
+...\glue 10.00002
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\parskip) 0.0
+...\glue(\lineskip) 1.0
+...\hbox(8.2+2.33331)x345.0, glue set 138.06842fil
+....\glue(\leftskip) 0.0 plus 1.0fil
+....\hbox(0.0+0.0)x0.0
+....\OT1/cmr/m/n/12 M
+....\OT1/cmr/m/n/12 a
+....\kern-0.32639
+....\OT1/cmr/m/n/12 y
+....\glue 3.91663 plus 1.95831 minus 1.30554
+....\OT1/cmr/m/n/12 2
+....\OT1/cmr/m/n/12 0
+....\OT1/cmr/m/n/12 ,
+....\glue 3.91663 plus 2.44789 minus 1.04443
+....\OT1/cmr/m/n/12 2
+....\OT1/cmr/m/n/12 0
+....\OT1/cmr/m/n/12 1
+....\OT1/cmr/m/n/12 6
+....\penalty 10000
+....\glue(\parfillskip) 0.0
+....\glue(\rightskip) 0.0 plus 1.0fil
+...\penalty -51
+...\glue 10.0 plus 3.0 minus 5.0
+...\glue 15.00002
+...\glue -2.33331
+...\glue 0.0 plus 1.0fil
+...\glue 9.0 plus 4.0 minus 2.0
+...\kern -3.0
+...\rule(0.4+0.0)x137.9979
+...\kern 2.6
+...\hbox(6.65+2.85002)x345.0, glue set 311.99951fil
+....\hbox(5.64903+0.0)x15.30023, glue set 11.13446fil
+.....\glue 0.0 plus 1.0fil minus 1.0fil
+.....\hbox(5.64903+0.0)x4.16577
+......\mathon
+......\hbox(2.8257+0.0)x4.16577, shifted -2.82333
+.......\TS1/cmr/m/n/6 *
+......\mathoff
+....\hbox(6.65+0.0)x0.0
+.....\rule(6.65+0.0)x0.0
+....\OT1/cmr/m/n/8 N
+....\OT1/cmr/m/n/8 o
+....\OT1/cmr/m/n/8 t
+....\OT1/cmr/m/n/8 e
+....\penalty 10000
+....\rule(0.0+2.85002)x0.0
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue -2.85002
+...\glue 0.0 plus 0.0001fil
+..\glue(\baselineskip) 23.55556
+..\hbox(6.44444+0.0)x345.0
+...\hbox(6.44444+0.0)x345.0, glue set 170.0fil
+....\glue 0.0 plus 1.0fil
+....\OT1/cmr/m/n/10 1
+....\glue 0.0 plus 1.0fil
+.\kern 0.0
+.\kern -633.0
+.\hbox(0.0+0.0)x0.0
+.\kern 633.0
+(title-001.aux)
More information about the latex3-commits
mailing list.