summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/schooldocs/schooldocs.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/schooldocs/schooldocs.dtx')
-rw-r--r--macros/latex/contrib/schooldocs/schooldocs.dtx151
1 files changed, 92 insertions, 59 deletions
diff --git a/macros/latex/contrib/schooldocs/schooldocs.dtx b/macros/latex/contrib/schooldocs/schooldocs.dtx
index d1cd9a484b..4b1f1c451e 100644
--- a/macros/latex/contrib/schooldocs/schooldocs.dtx
+++ b/macros/latex/contrib/schooldocs/schooldocs.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2020-2023 by Antoine Missier <antoine.missier@ac-toulouse.fr>
+% Copyright (C) 2020-2024 by Antoine Missier <antoine.missier@ac-toulouse.fr>
% ----------------------------------------------------------------------
%
% This file may be distributed and/or modified under the
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{schooldocs}
%<*package>
- [2023/12/28 v1.4 .dtx Layout styles for school documents]
+ [2024/01/31 v1.5 .dtx Layout styles for school documents]
%</package>
%
%<*driver>
@@ -80,7 +80,7 @@
%</driver>
% \fi
%
-% \CheckSum{805}
+% \CheckSum{863}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -110,11 +110,15 @@
% - sffamily discarded from the default titlestyle
% - smalltitletopskip changed from -2.0cm to -1.32cm}
% \changes{v1.2}{2023/01/24}{
-% Small changes in the documentation (charter font is now used)
+% - Small changes in the documentation (charter font is now used)
% and the examples file (with several fonts)}
% \changes{v1.3}{2023/08/28}{English corrections in the documentation}
% \changes{v1.4}{2023/12/28}{
-% headtitlestyle in exam and collection styles set to scshape instead of MakeUppercase}
+% - Headtitlestyle in exam and collection styles set to scshape instead of MakeUppercase}
+% \changes{v1.5}{2024/01/30}{
+% - Possibility to call maketitle several times with different information fields
+% that can be changed outside the preamble
+% - The schooldocs-examples.pdf file is now generated in a single compilation}
%
% \GetFileInfo{schooldocs.dtx}
%
@@ -675,20 +679,30 @@
% \medskip
% \subsection{Information fields}
%
+% The PDF information fields are automatically filled in using the information macros,
+% but this only works in the preamble, hence the test |\ifx@onlypreamble@notprerr|.
+% This allows using these macros outside the preamble, which is the normal behavior
+% for |\title|, |\date|, |\author|, etc. with the 'article' class.
+%
% Once defined, information fields are initially set to empty
% to ensure that tests for empty fields work correctly.
+
%
% \begin{macrocode}
\renewcommand{\title}[2][]{\long\def\@title{#2}
\ifthenelse{\equal{#1}{}}{\def\@headtitle{#2}}{\def\@headtitle{#1}}
- \@ifpackageloaded{hyperref}{\hypersetup{pdftitle={\@headtitle}}}{}
+ \ifx\@onlypreamble\@notprerr\else
+ \@ifpackageloaded{hyperref}{\hypersetup{pdftitle={\@headtitle}}}{}
+ \fi
}
\title{}
\author{}
\newcommand\school[1]{\long\def\@school{#1}
- \@ifpackageloaded{hyperref}{
- \hypersetup{pdfauthor={\@author\ (\@school)}}}{}
+ \ifx\@onlypreamble\@notprerr\else
+ \@ifpackageloaded{hyperref}{
+ \hypersetup{pdfauthor={\@author\ (\@school)}}}{}
+ \fi
}
\school{}
\newcommand{\institute}{\school}
@@ -696,7 +710,9 @@
\let\subject\relax
\newcommand{\subject}[2][]{\long\def\@subject{#2}
\ifthenelse{\equal{#1}{}}{\def\@headsubject{#2}}{\def\@headsubject{#1}}
- \@ifpackageloaded{hyperref}{\hypersetup{pdfsubject={\@headsubject}}}{}
+ \ifx\@onlypreamble\@notprerr\else
+ \@ifpackageloaded{hyperref}{\hypersetup{pdfsubject={\@headsubject}}}{}
+ \fi
}
\def\@subject{}
\def\@headsubject{}
@@ -764,55 +780,64 @@
%
% \subsection{Title composition}
%
+% The first macro, |\schooldocstitles|, aims to define the default composition of titles.
+% Several styles redefine their own title composition.
+% This macro allows, when using |\maketitle| multiple times at different places
+% in the document, to revert to the default definition when a style has modified
+% the title definition.
% \begin{macrocode}
-\renewcommand{\maketitle}[1][\seprulelength]{
- \mbox{}\par\vspace{\titletopskip}
- \begin{\titleflush}
- {\color{titlecolor}
- {\titlestyle{\@title}}
- \ifx\@subject\@empty\else
- \par\vspace{\titlesep}\subjectstyle\@subject
- \fi
- \ifthenelse{\equal{\@date}{}}{}{%
- \par\vspace{0.5\titlesep} \datestyle\@date}
- \par\vspace{0.5\titlesep}
- }
- \ifthenelse{\lengthtest{#1 > 0cm}}{\rule{#1}{\seprulewidth}}{}
- \end{\titleflush}
- \vspace{\titlebottomskip}
-}
+\newcommand{\schooldocstitles}{
+ \renewcommand{\maketitle}[1][\seprulelength]{
+ \newpage\mbox{}\par\vspace{\titletopskip}
+ \begin{\titleflush}
+ {\color{titlecolor}
+ {\titlestyle{\@title}}
+ \ifx\@subject\@empty\else
+ \par\vspace{\titlesep}\subjectstyle\@subject
+ \fi
+ \ifthenelse{\equal{\@date}{}}{}{%
+ \par\vspace{0.5\titlesep} \datestyle\@date}
+ \par\vspace{0.5\titlesep}
+ }
+ \ifthenelse{\lengthtest{##1 > 0cm}}{\rule{##1}{\seprulewidth}}{}
+ \end{\titleflush}
+ \vspace{\titlebottomskip}
+ }
-\newcommand{\makesmalltitle}{
- \mbox{}\par\vspace{\smalltitletopskip}
- \begin{center}
- {\color{titlecolor}
- {\titlestyle{\@title}}
- \hfill \subjectstyle\@subject
- \ifthenelse{\equal{\@date}{}}{}{%
- \enskip --\enskip \smalltitledatestyle\@date}
- }
- \rule{\linewidth}{\seprulewidth}
- \end{center}
- \vspace{\titlebottomskip}
-}
+ \let\makesmalltitle\relax
+ \newcommand{\makesmalltitle}{
+ \newpage\mbox{}\par\vspace{\smalltitletopskip}
+ \begin{center}
+ {\color{titlecolor}
+ {\titlestyle{\@title}}
+ \hfill \subjectstyle\@subject
+ \ifthenelse{\equal{\@date}{}}{}{%
+ \enskip --\enskip \smalltitledatestyle\@date}
+ }
+ \rule{\linewidth}{\seprulewidth}
+ \end{center}
+ \vspace{\titlebottomskip}
+ }
-\newcommand\correct{%
- \let\@originalheadtitle\@headtitle
- \def\@headtitle{\@originalheadtitle ~--~\correctname}
- \@ifpackageloaded{hyperref}{%
- \AtBeginDocument{\hypersetup{pdftitle={\@headtitle}}}}{}
- \let\@originaltitle\@title
- \def\@title{\@originaltitle ~--~\correctname}
+ \let\correct\relax
+ \newcommand\correct{%
+ \let\@originalheadtitle\@headtitle
+ \def\@headtitle{\@originalheadtitle ~--~\correctname}
+ \ifx\@onlypreamble\@notprerr\else
+ \@ifpackageloaded{hyperref}{%
+ \AtBeginDocument{\hypersetup{pdftitle={\@headtitle}}}}{}
+ \fi
+ \let\@originaltitle\@title
+ \def\@title{\@originaltitle ~--~\correctname}
+ }
}
+\schooldocstitles
\newcommand{\seprule}[1][\seprulelength]{\begin{center}
\raisebox{0.25\baselineskip}{\rule{#1}{\seprulewidth}}\end{center}}
% \end{macrocode}
-% The use of |\AtBeginDocument| is necessary in the |\correct| macro because
-% |\correctname| could be redefined by \textsf{babel} at |\begin{document}|.
%
-% \bigskip
% \subsection{Basic styles}
%
% In the \textbf{classic} style, the header is displayed on two lines,
@@ -832,7 +857,7 @@
\cfoot{\footstyle \thepage /\pageref{LastPage}}
\setlength{\titletopskip}{-0.67cm}
\renewcommand{\maketitle}[1][\seprulelength]{%
- \mbox{}\par\vspace{\titletopskip}
+ \newpage\mbox{}\par\vspace{\titletopskip}
\begin{\titleflush}
{\color{titlecolor}\titlestyle{\@title}}
\par\vspace{0.5\titlesep}
@@ -841,7 +866,7 @@
\vspace{\titlebottomskip}
}
\renewcommand{\makesmalltitle}{
- \mbox{}\par\vspace{\smalltitletopskip}
+ \newpage\mbox{}\par\vspace{\smalltitletopskip}
\begin{center}
{\color{titlecolor}
{\titlestyle{\@title}}
@@ -879,7 +904,7 @@
\headdatestyle\@date\ignorespaces}{}
}
\renewcommand{\maketitle}[1][\seprulelength]{%
- \mbox{}\par\vspace{\titletopskip}
+ \newpage\mbox{}\par\vspace{\titletopskip}
\begin{\titleflush}
{\color{titlecolor}
{\titlestyle{\@title}}
@@ -893,7 +918,7 @@
\vspace{\titlebottomskip}
}
\renewcommand{\makesmalltitle}{
- \mbox{}\par\vspace{\smalltitletopskip}
+ \newpage\mbox{}\par\vspace{\smalltitletopskip}
\begin{center}
{\color{titlecolor}
{\titlestyle{\@title}}
@@ -922,7 +947,7 @@
}
\setlength{\titletopskip}{-0.67cm}
\renewcommand{\maketitle}[1][\seprulelength]{%
- \mbox{}\par\vspace{\titletopskip}
+ \newpage\mbox{}\par\vspace{\titletopskip}
\begin{\titleflush}
{\color{titlecolor}\titlestyle{\@title}}
\par\vspace{0.5\titlesep}
@@ -931,7 +956,7 @@
\vspace{\titlebottomskip}
}
\renewcommand{\makesmalltitle}{
- \mbox{}\par\vspace{\smalltitletopskip}
+ \newpage\mbox{}\par\vspace{\smalltitletopskip}
\begin{center}
{\color{titlecolor}
{\titlestyle{\@title}}
@@ -973,18 +998,22 @@
\setlength{\titlesep}{2\bigskipamount}
\renewcommand{\titlestyle}{\LARGE\MakeUppercase}
\renewcommand{\subjectstyle}{\Large\bfseries}
+ \let\subtitlestyle\relax
\newcommand{\subtitlestyle}{\large\slshape}
+ \let\titlecorrectstyle\relax
\newcommand*{\titlecorrectstyle}{\color{red}\large\scshape}
\renewcommand\correct{%
\let\@originalheadtitle\@headtitle
\def\@headtitle{\@originalheadtitle ~--~\correctname}
- \@ifpackageloaded{hyperref}{%
- \AtBeginDocument{\hypersetup{pdftitle={\@headtitle}}}}{}
+ \ifx\@onlypreamble\@notprerr\else
+ \@ifpackageloaded{hyperref}{%
+ \AtBeginDocument{\hypersetup{pdftitle={\@headtitle}}}}{}
+ \fi
\renewcommand{\subtitlestyle}{\titlecorrectstyle}
\subtitle{\correctname}
}
\renewcommand{\maketitle}[1][\seprulelength]{%
- \mbox{}\par\vspace{\titletopskip}
+ \newpage\mbox{}\par\vspace{\titletopskip}
\begin{center}
{\color{titlecolor}
{\titlestyle{\@title}}
@@ -1004,7 +1033,11 @@
\fancypagestyle{collection}{%
\lhead{\headstyle\headtitlestyle\@headtitle}
- \AtBeginDocument{\renewcommand{\sectionmark}[1]{\markboth{##1}{}}}
+ \ifx\@onlypreamble\@notprerr
+ \renewcommand{\sectionmark}[1]{\markboth{##1}{}}
+ \else
+ \AtBeginDocument{\renewcommand{\sectionmark}[1]{\markboth{##1}{}}}
+ \fi
\rhead{\headstyle\headsubjectstyle\leftmark} %\@section
\lfoot{\footstyle\schoolstyle \@school}
\cfoot{}
@@ -1017,7 +1050,7 @@
\renewcommand{\datestyle}{\Large}
\renewcommand{\maketitle}[1][\seprulelength]{%
\thispagestyle{empty}
- \mbox{}\par\vspace{\titletopskip}
+ \newpage\mbox{}\par\vspace{\titletopskip}
\begin{center}
{\color{titlecolor}
{\titlestyle{\@title}}