summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/rectopma/rectopma.dtx
blob: aadfbe1da6cd74425b211d72547440352304927d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
%\iffalse 
% file:    rectopma.dtx
% author:  Battista Benciolini
% contact: benciolinibattista at gmail dot com
% date:    2024-04-04
%\fi
%\iffalse 
%<*ins>
\begingroup
\input docstrip.tex
\keepsilent
\preamble
----------------------------------------------------------------
This file is part of the distribution of   rectopma [2024-04-04]
The author of  rectopma   is Battista Benciolini 
<benciolinibattista at gmail dot com >
----------------------------------------------------------------
This program may be used, distributed and modified under 
the conditions of the LaTeX Project Public License.
(see: http://www.latex-project.org/lppl.txt)
----------------------------------------------------------------
\endpreamble
\askforoverwritefalse
\generate{\file{rectopma.sty}{\from{rectopma.dtx}{package}}}
\generate{\file{TestTitle.tex}{\from{rectopma.dtx}{example}}}
\endgroup
%</ins>
%\fi
%\iffalse 
%<*driver>
\documentclass[a4paper,10pt]{ltxdoc}
\title{The \texttt{rectopma} package: 
\\ recicle top matter, i.e. 
\\ reuse the title and author(s)}
\author{Battista Benciolini 
\thanks{e-mail: benciolinibattista at gmail dot com}}
\begin{document}
\maketitle
\DocInput{rectopma.dtx}
\end{document}
%</driver>
%\fi
%
%\section{Introduction}
% The package |rectopma| makes it possible to reuse the main 
% content of |\title| and |\author| in different parts of a 
% document. It is also possible to force linebreaks in the title with 
% a command that has no effect 
% when the title is re-printed.
% The file |TestTitle.tex| is an example of the use 
% of the functions made available by the package.
% 
% 
%\iffalse
%<*example>
%\fi
%\section{Suggestions for the use and an example}
% 
% I first present the suggestions for the use of |rectopma.sty|
% and the example that will be available in |TestTitle.tex|
% The example must obviously start loading the class (I use article) 
% and the package rectopma
%    \begin{macrocode}
\documentclass{article}
\usepackage{rectopma}   
%    \end{macrocode}
% 
% In the preamble I define the title and the authors.
% The authors must be separated by |\and|. Title and authors 
% can have a note using |\thanks|, and the note will disappear when 
% the title and the author will be reused.  
% When a long title is present it is 
% \DescribeMacro{\intitlebreak}
% \DescribeMacro{\intitlebreakvs}
% perhaps useful to force linebreaks in some special position. 
% The new commands |\intitlebreak| and |\intitlebreakvs|
% (vs= vertical skip) are used for this purpose, and their effect 
% will disappears when the title itself is re-used in the document.
%    \begin{macrocode}
\title{Test of the package \texttt{rectopma} 
\intitlebreak and suggestions for its use 
\intitlebreakvs (I need a long title)%
\thanks{Comments are welcome !}}
\author{Battista Benciolini%
\thanks{e-mail: benciolinibattista at gmail dot com}%
\and    No Second Author\thanks{No-Where Institute}}%
%    \end{macrocode}
% 
%\par 
% The main part of the document starts as usual.
% The command \DescribeMacro{\SaveTopMatter} |\SaveTopMatter| 
% must be used  before |maketitle| to save the  title and the author(s).
% 
%    \begin{macrocode}
\begin{document}
\SaveTopMatter
\maketitle 
%    \end{macrocode}
% 
% The title and the authors can be reprinted with the commands
% \DescribeMacro{\SavedTitle} \DescribeMacro{\SavedAuthor}
%|\SavedTitle| and |\SavedAuthor|. When they are 
% reprinted the names of the various authors are simply separated 
% by commas and the content of |\thanks| is ignored.
% 
%    \begin{macrocode}
The authors are listed here after: \SavedAuthor. 
This is obtained with \verb|\SavedAuthor|. 
It is also possible to reprint the title, 
by means of  \verb|\SavedTitle|, 
and the result is: \SavedTitle. 
%    \end{macrocode} 
% 
% And this is the end of the example.
%    \begin{macrocode}
\end{document}
%    \end{macrocode}
% 
%\iffalse
%</example>
%<*package>
%\fi
%\section{Code of the package} 
% 
%    \begin{macrocode}
\ProvidesPackage{rectopma}[2024/04/04]
%    \end{macrocode}% 
%
% \begin{macro}{\declarecommand}
% I need |\declarecommand| ! 
% The definition is due to egreg in 
% a comment to question 128797 in |tex.stackexchange.com|. 
%    \begin{macrocode}
\newcommand\declarecommand[1]{\providecommand{#1}{}\renewcommand{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\intitlebreak}
% The command |\intitlebreak| is used to force a line break in the title. 
%    \begin{macrocode}
\newcommand{\intitlebreak}{\\}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\intitlebreakvs}
% The comman |\intitlebreakvs| (vs= vertical skip)  
% produces a line break and a vertical skip.
%    \begin{macrocode}
\newcommand{\intitlebreakvs}{\\ \vskip 4mm }
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\@outsidetitle}
% The commands |\intitlebreak|, |\intitlebreakvs|, 
% |\and| and |\thanks| need a redefinition for the  
% correct output of title and authors in a generic 
% position in the document.
% The redefinition is operated by the command |\@outsidetitle|.
% (I follow the old tradition of inserting a |@| in the 
% commands that are of internal use, not available to the user.)
%    \begin{macrocode}
\newcommand{\@outsidetitle}{%
\renewcommand{\intitlebreak}{\relax}%
\renewcommand{\intitlebreakvs}{\relax}%
\declarecommand{\thanks}[1]{\relax}%
\declarecommand{\and}{\unskip,\ }}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\SaveTopMatter}
% The new command  |\SaveTopMatter| saves the contents of |\@title| 
% and |\@author| in |\@SavedTitle| and |\@SavedAuthor| respectively, 
% so that they can be re-used anywhere in the document.
%    \begin{macrocode}
\newcommand{\SaveTopMatter}{%
\global\let\@SavedTitle\@title%
\global\let\@SavedAuthor\@author}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\SavedTitle}
% The command  |\SavedTitle|
% actually prints the title.
%    \begin{macrocode}
\newcommand{\SavedTitle}{\@outsidetitle\@SavedTitle}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SavedAuthor}
% The command  |\SavedAuthor|
% actually prints the authors.
%    \begin{macrocode}
\newcommand{\SavedAuthor}{\@outsidetitle\@SavedAuthor}
%    \end{macrocode}
% \end{macro}
% 
% The package is now complete.
%
%\iffalse
%</package>
%\fi
%\section{History}
%\begin{description}
%\item[2002] first release in CTAN,
%\item[2024] second release in CTAN, 
% complete re-coding of |rectopma.sty|, 
% some changes in |TestTitle.sty|,
% new documentation, 
% all stuff collected in |rectopma.dtx|.
%\end{description}
%\section{Recommendation}
% I recommend all the users of |rectopma|, and all the 
% persons that by chance encounter it, 
% to send me any comment about it. 
% \vfill\centerline{\Large ***}\vfill
% 
%\iffalse
% END OF FILE rectopma.dtx
%\fi