document additional commands
[lematema] / lematema.cls
1 %%%% Class file for Le Matematiche
2 %%% Author: Giuseppe Bilotta
3 %%% Email (work): bilotta@dmi.unict.it
4 %%% Email (home): giuseppe.bilotta@gmail.com
5 %
6 % Additional commands:
7 %
8 % *  \authorline          : put the following authors on another line
9 % *  \submissiondatefalse : hide the submission date on the first article page
10 % *  \shortauthorstrue    : shorten the author names under the title
11 % *  \shortauthormark     : shorten the author names in the headings
12
13 \NeedsTeXFormat{LaTeX2e}
14 \ProvidesClass{lematema}[2008/03/07 v0.9
15 Class for articles in ``Le Matematiche'']
16
17 \newif\if@langsel
18 \@langselfalse
19 %%% Language options
20 \DeclareOption{english}{\PassOptionsToPackage{\CurrentOption}{babel}\@langseltrue}
21 \DeclareOption{french}{\PassOptionsToPackage{\CurrentOption}{babel}\@langseltrue}
22 \DeclareOption{italian}{\PassOptionsToPackage{\CurrentOption}{babel}\@langseltrue}
23
24 %%% draft/final
25 \DeclareOption{draft}{\PassOptionsToClass{\CurrentOption}{article}}
26 \DeclareOption{final}{\PassOptionsToClass{\CurrentOption}{article}}
27
28 \ProcessOptions\relax
29
30 \if@langsel\else
31 \ClassWarning{lematema}{No language specified, defaulting to english}
32 \PassOptionsToPackage{english}{babel}
33 \fi
34
35 %%% Class based on the standard article class
36 \LoadClass[11pt,twoside]{article}
37 %%% Font: times (and math stuff)
38 \usepackage{mathptmx}
39 %%% Package `babel' for language management
40 \RequirePackage{babel}
41 %%% Package `url' for urls
42 \RequirePackage{url}
43 %%% Define an \email{...} command, but let's not use the url package for this
44 \newcommand{\email}[1]{{e-mail: \upshape\ttfamily#1}}
45
46 %%% AMS math environments and symbols
47 \RequirePackage{amsmath}
48 \RequirePackage{amssymb}
49 \RequirePackage{amsthm}
50
51 %%% Bibliography
52 \RequirePackage[square,numbers,sort&compress,sectionbib]{natbib}
53 \bibliographystyle{lematema}
54 \def\bibhere{\bibliography{\jobname}}
55 \addto\captionsitalian{%
56   \def\refname{Bibliografia}%
57   \def\bibname{Bibliografia}%
58 }
59 \addto\captionsenglish{%
60   \def\refname{References}%
61   \def\bibname{References}%
62 }
63 \addto\captionsfrench{%
64   \def\refname{Bibliographie}%
65   \def\bibname{Bibliographie}%
66 }
67 % from the needspace package
68 \newcommand{\needspace}[1]{\begingroup\setlength{\dimen@}{#1}%
69   \vskip\z@\@plus\dimen@ \penalty -100\vskip\z@\@plus -\dimen@
70     \vskip\dimen@ \penalty 9999\vskip -\dimen@\endgroup}
71 %
72 \def\bibsection{%
73   \par
74   \needspace{4cm}
75   \vspace{2cm}
76   \centering{\MakeUppercase{\refname}}%
77   \par
78   \small
79 }
80 \setlength{\bibsep}{3pt}
81
82 % %\magnification\magstephalf
83 %%% Page geometry, using the `geometry' package
84 \RequirePackage[paperwidth=17cm,%
85                 paperheight=24cm,%
86                 footskip=0pt,%
87                 headsep=0.5cm,%
88                 headheight=0.5cm,%
89                 width=12.2cm,%
90                 %height=18.5cm,% overspecification, comment out
91                 left=2cm,%
92                 top=2cm,%
93                 bottom=2.5cm]{geometry}
94
95 %%% Our default head/foot style
96
97 \renewcommand{\ps@plain}{%
98   \renewcommand{\@oddhead}{\hfill{\footnotesize\@htitle}\hfill\thepage}%
99   \renewcommand{\@evenhead}{\thepage\hfill{\footnotesize\@hauthor}\hfill}%
100   \renewcommand{\@oddfoot}{}%
101   \renewcommand{\@evenfoot}{}%
102 }
103 \pagestyle{plain}
104
105 \def\@htitle{\textbf{(no title)}}
106 \def\@hauthor{\textbf{(no author)}}
107
108 %%% Footnotes
109 \renewcommand\footnoterule{%
110   \hrule\@width.4\columnwidth
111   \kern2.6\p@}
112
113 %%% Section styles
114 \def\@seccntformat#1{\csname the#1\endcsname.\quad}
115 \renewcommand\section{\@startsection {section}{1}{\z@}%
116                                    {-24pt \@plus -6pt \@minus -3pt}%
117                                    {\medskipamount}%
118                                    {\normalfont\bfseries}}
119
120 %%% Theorem environments
121 \addto\captionsitalian{%
122   \def\theoremname{Teorema}%
123   \def\corollaryname{Corollario}%
124   \def\lemmaname{Lemma}%
125   \def\propositionname{Proposizione}%
126   \def\definitionname{Definizione}%
127   \def\examplename{Esempio}%
128   \def\remarkname{Osservazione}%
129   \def\notename{Nota}%
130 }
131 \addto\captionsenglish{%
132   \def\theoremname{Theorem}%
133   \def\corollaryname{Corollary}%
134   \def\lemmaname{Lemma}%
135   \def\propositionname{Proposition}%
136   \def\definitionname{Definition}%
137   \def\examplename{Example}%
138   \def\remarkname{Remark}%
139   \def\notename{Note}%
140 }
141 \addto\captionsfrench{%
142   \def\theoremname{Th\'eor\`eme}%
143   \def\corollaryname{Corollaire}%
144   \def\lemmaname{Lemma}%
145   \def\propositionname{Proposition}%
146   \def\definitionname{D\'efinition}%
147   \def\examplename{Exemple}%
148   \def\remarkname{Remarque}%
149   \def\notename{Note}%
150 }
151
152 \theoremstyle{plain}
153 \newtheorem{thm}{\theoremname}[section]
154 \newtheorem{cor}[thm]{\corollaryname}
155 \newtheorem{lemma}[thm]{\lemmaname}
156 \newtheorem{prop}[thm]{\propositionname}
157
158 \theoremstyle{definition}
159 \newtheorem{dfn}[thm]{\definitionname}
160 \newtheorem{exa}[thm]{\examplename}
161 \newtheorem{rem}[thm]{\remarkname}
162 \newtheorem{note}[thm]{\notename}
163
164 %%% Commands that define the article information
165 \let\originaltitlecmd\title
166 \def\title#1{\originaltitlecmd{#1}\titlemark{#1}}
167 \def\titlemark#1{\gdef\@htitle{\MakeUppercase{#1}}}
168 \def\titlenote#1{\expandafter\@titlenote\expandafter{\the\@titlenote\thanks{#1}}}
169 \newtoks\@titlenote
170
171 \def\makeshortauthor#1#2 #3\relax{
172 \if@shortauthortoks
173 \expandafter\@shortauthortoks\expandafter{\the\@shortauthortoks\space - \MakeUppercase{#1}. \MakeUppercase{#3}}%
174 \else
175 \@shortauthortoks{\MakeUppercase{#1}. \MakeUppercase{#3}}%
176 \@shortauthortokstrue
177 \fi
178 \def\@shortauthor{\the\@shortauthortoks}%
179 }
180 \newtoks\@shortauthortoks
181 \newif\if@shortauthortoks\@shortauthortoksfalse
182
183 \def\authormark#1{\gdef\@hauthor{\MakeUppercase{#1}}}
184 \def\author#1{%
185 \if@authortoks
186 \expandafter\@authortoks\expandafter{\the\@authortoks\space - \MakeUppercase{#1}}%
187 \else
188 \expandafter\@authortoks\expandafter{\the\@authortoks\MakeUppercase{#1}}%
189 \@authortokstrue
190 \fi
191 \makeshortauthor#1\relax%
192 \authormark{\the\@authortoks}%
193 \def\@author{\the\@authortoks}%
194 \@lastauthor{#1}%
195 }
196 \newtoks\@authortoks
197 \@authortoks{}
198 \newif\if@authortoks\@authortoksfalse
199 \newtoks\@lastauthor
200
201 \def\authorline@hyphen{ - }
202 \let\authorline@sep\authorline@hyphen
203 \def\authorline{%
204 \@authortoksfalse
205 \expandafter\@authortoks\expandafter{\the\@authortoks\protect\authorline@sep}%
206 }
207
208 \def\shortauthormark{\authormark{\the\@shortauthortoks}}
209
210 \def\address#1{%
211 \expandafter\expandafter\expandafter\@addresstoks\expandafter\expandafter\expandafter{%
212 \expandafter\the\expandafter\@addresstoks\expandafter\par
213 \expandafter\bigskip
214 \expandafter\MakeUppercase\expandafter{\the\@lastauthor}\\
215 #1}%
216 }
217 \newtoks\@addresstoks
218 \def\@address{\par\bigskip\begin{flushright}%
219   \itshape
220   \the\@addresstoks
221 \end{flushright}}
222 \AtEndDocument{\@address}
223
224 %% Mathematics Subject Classification
225 \def\MSC#1{\gdef\@MSC{#1}}
226 \def\@MSC{}
227 %% Keywords
228 \def\keywords#1{\gdef\@keywords{#1}}
229 \def\@keywords{}
230
231 %% Year/Volume/Number/First Page/Last Page
232 \def\LM@Year{????}
233 \def\LM@Vol{???}
234 \def\LM@Num{??}
235 \def\LM@FirstPg{??}
236 \def\LM@LastPg{??}
237
238 %% Redefine \date to parse a string yyyy/mm/dd, which will be used
239 %% as submission date
240 \newcounter{LM@year}
241 \newcounter{LM@month}
242 \newcounter{LM@day}
243 \def\date#1{\LM@parsedate#1\LM@enddate}
244 \def\LM@parsedate#1/#2/#3\LM@enddate{%
245 \setcounter{LM@year}{#1}%
246 \setcounter{LM@month}{#2}%
247 \setcounter{LM@day}{#3}%
248 }
249
250 %% turn a number/counter into an italian month
251 \def\@itmonth#1{\ifcase#1\or gennaio\or febbraio\or marzo\or aprile\or
252 maggio\or giugno\or luglio\or agosto\or settembre\or ottobre\or novembre\or
253 dicembre\else\textbf{??}\fi}
254 \def\itmonth#1{\expandafter\@itmonth\csname c@#1\endcsname}
255
256 \renewcommand{\maketitle}{%
257   \begingroup
258     \renewcommand\thefootnote{}%
259     \def\@makefnmark{}%
260     \long\def\@makefntext##1{\parindent 1em\noindent##1}%
261     \newpage
262     \global\@topnum\z@   % Prevents figures from going at top of page.
263     \@maketitle
264     \thispagestyle{empty}\@thanks
265   \endgroup
266   \setcounter{footnote}{0}%
267   \global\let\thanks\relax
268   \global\let\maketitle\relax
269   \global\let\@maketitle\relax
270   \global\let\@thanks\@empty
271   \global\let\@author\@empty
272   \global\let\@shortauthor\@empty
273   \global\let\@date\@empty
274   \global\let\@title\@empty
275   \global\let\title\relax
276   \global\let\author\relax
277   \global\let\date\relax
278   \global\let\and\relax
279   \global\let\MSC\relax
280   \global\let\@MSC\relax
281   \global\let\keywords\relax
282   \global\let\@keywords\relax
283   \global\let\titlenote\relax
284   \global\let\@titlenote\relax
285 }
286
287 %% insert the article information in the top right corner
288 \def\@articleinfo{%
289 \noindent\footnotesize LE MATEMATICHE\\
290 Vol.~\LM@Vol~(\LM@Year)~--~Fasc.~\LM@Num,~pp.~\LM@FirstPg--\LM@LastPg
291 }
292
293 \newif\ifsubmissiondate
294 \submissiondatetrue
295
296 \newif\ifshortauthors\shortauthorsfalse
297 %% Make the title page
298 \def\@maketitle{%
299   \newpage
300   \@articleinfo
301   %% Submission date (at the bottom)
302   \ifsubmissiondate
303     \thanks{%
304       \hskip0.8cm Entrato in redazione \arabic{LM@day} \itmonth{LM@month} \arabic{LM@year}\smallskip}%
305   \fi
306   %% MSC, if present
307   \ifx\@MSC\empty\else\thanks{%
308   \textit{AMS 2000 Subject Classification:} \@MSC
309   }\fi%
310   %% Keywords, if present
311   \ifx\@keywords\empty\else\thanks{%
312   \textit{Keywords:} \@keywords
313   }\fi%
314   \vskip 4.5truecm%
315   \begin{center}%
316   \let \footnote \thanks
317     {\def\\{\protect\linebreak}%
318     \fontsize{12}{15}\selectfont\bfseries \MakeUppercase{\@title}
319     %% Title note, if present
320     \the\@titlenote
321     \par}%
322     \vskip 0.5truecm%
323     {\fontsize{11.5}{14}\selectfont
324       \begin{tabular}[t]{c}%
325         \let\authorline@sep\tabularnewline
326         \ifshortauthors\@shortauthor\else\@author\fi
327       \end{tabular}\par
328     }%
329   \end{center}%
330   \par
331   \vskip 0.5truecm}
332
333 \renewenvironment{abstract}{%
334 \small\quotation
335 }{%
336 \endquotation
337 }
338
339 % In case the author forgets it:
340 \AtBeginDocument{\maketitle}
341
342 \expandafter\IfFileExists\expandafter{\jobname.pub}{%
343   \InputIfFileExists{\jobname.pub}{\typeout{Volume data loaded}}\relax%
344   \c@page=\LM@FirstPg\relax
345   \AtEndDocument{%
346     \@bsphack
347     \protected@write\@auxout{}%
348       {\string\xdef\string\LM@LastPg{\thepage}}%
349     \@esphack
350   }%
351 }{}