summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/topletter/TOPletter.dtx
blob: cda33cd1bdb3efd87875b066fec9d7bec7893ab6 (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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
% \iffalse meta-comment
%
%  Copyright (C) 2015 by Marco Torchiano <marco.torchiano@polito.it>
% ------------------------------------------------------------------
% 
% This file may be distributed and/or modified under the conditions of
% the Apache License, either version 2.0 of this license
% or (at your option) any later version.  The latest version of this
% license is in:
% 
%    http://choosealicense.com/licenses/apache-2.0/
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{TOPletter.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}
%<class>\ProvidesClass{TOPletter}
%<*class>
    [2018/07/10 v0.3.0 Corporate Letter PoliTo LaTeX class]
%</class>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{hyperref}
\usepackage{mdframed}
\EnableCrossrefs         
%\CodelineIndex
\PageIndex
\RecordChanges
\OnlyDescription
\begin{document}
  \DocInput{TOPletter.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
% \CheckSum{292}
%
% \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
%   Lower-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
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.2}{2015/03/13}{Initial version}
% \changes{v0.2.1}{2015/03/13}{Minor changes and fixes to examples}
% \changes{v0.3.0}{2018/07/10}{Added possibility to add protocol number}
%
% \GetFileInfo{TOPletter.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment,\\, \bf,\begin, \cond, \condb}
% \DoNotIndex{\centering,\ClassError,\DeclareOption,\def,\definecolor}
% \DoNotIndex{\else,\end,\familydefault,\fancyfoot,\fancyhead,\fancyhf}
% \DoNotIndex{\fancypagestyle,\fi,\fontseries,\fontsize,\footrulewidth}
% \DoNotIndex{\footskip,\headheight,\headrulewidth,\href,\hspace}
% \DoNotIndex{\ifdefined,\IfFileExists,\IfLanguageName,\includegraphics}
% \DoNotIndex{\Large,\linebreak,\LoadClass,\makeatletter,\makeatother}
% \DoNotIndex{\makebox,\MessageBreak,\pagestyle,\parbox,\ProcessOption}
% \DoNotIndex{\protect,\raisebox,\relax,\renewcommand,\RequirePacakge}
% \DoNotIndex{\rule,\selectfont,\setlength,\sfdefault,\sffamily,\small}
% \DoNotIndex{\textwidth,\today,\topl@language,\toplData,\toplDest}
% \DoNotIndex{\toplEmail,\toplFax,\toplHome,\toplLuogo,\toplLogo}
% \DoNotIndex{\toplNome,\toplRuolo,\toplSignature,\toplStruttura}
% \DoNotIndex{\toplSubject,\toplSubjectLabel,\toplTelefono}
% \DoNotIndex{\toplTipoStruttura,\vspace,\color,\RequirePackage}
%
% \title{The \textsf{TOPletter} class\thanks{This document
%   corresponds to \textsf{TOPLetter}~\fileversion, dated \filedate.}}
% \author{Marco Torchiano \\ \texttt{marco.torchiano@polito.it}}
%
% \maketitle
%
% \section{Introduction}
%
% The \textsf{TOPletter} class provides the basic functions needed for typesetting 
% a letter using LaTeX and conforming to the official Corporate Image guidelines for
% Politecnico di Torino~\footnote{
% \url{http://www.politocomunica.polito.it/corporate_image/marchio_e_identita_visiva}}. 
% The class can be used for letters written both in Italian and in English languages.
%
%
%
% \section{Usage}
%
% The usage of the document class is extremely straightforward:
% \begin{itemize}
% \item the TOPletter document class must be declared as the base for
% the document. i.e. using |\documentclass{TOPletterA}|.
%
% \item the customization macros must be used to define the
%       details of the letter, i.e. organization details, personal
%		information, and letter subject.
%
% \item the body of the letter can be written as a regular \LaTeX document.
% \end{itemize}
% An example of a document using the \textsf{TOPletter} class is provided
% in section \ref{sec:example} below.
%
%
% \subsection{Organizational Unit}
% 
% \DescribeMacro{\dipartimentoDi}\noindent
% The name of the department can be specified using the 
% |\dipartimentoDi|\marg{department name} macro.
% 
% \noindent\DescribeMacro{\struttura}
% By default the organizational unit is a {\em department}, but
% it is possible to set the type of the organizational unit using
% |\struttura|\marg{structure type} macro.
% 
% \subsection{Personal Info}
% 
% \noindent\DescribeMacro{\nome}
% |\nome|\marg{name and surname}
% Defines the name of the person, it should include both first and
% last names as they will appear in the header of the letter and 
% at the end of the letter (after the date).
% 
% \noindent\DescribeMacro{\ruolo}
% |\ruolo|\marg{role}
% defines the role of the person, e.g. {\em Full Professor}.
% 
% \noindent\DescribeMacro{\telefono}
% |\telefono|\marg{phone number}
% defines the office phone number.
% 
% \noindent\DescribeMacro{\email}
% |\email|\marg{email}
% defines the email address of the person
% 
% The above information is mandatory and an error is reported
% if any is missing.
%
% \noindent\DescribeMacro{\homepage}
% |\homepage|\marg{url}
% defines the (optional) URL of the personal home page.
% 
% \noindent\DescribeMacro{\fax}
% |\fax|\marg{fax}
% defines the (optional) fax number.
% 
% \noindent\DescribeMacro{\firma}
% |\firma|\marg{image file}
% defines an image file (typically a PNG) that contains a scanned signature of the person.
%
% \subsection{Letter Details}
% 
% \noindent\DescribeMacro{\soggetto}
% |\soggetto|\marg{subject}
% defines the subject of the letter, that will appear, at the top of the letter
% preceded by the word "{\em Subject:}" (or "{\em Soggetto:}" if the language is italian).
%
% The above macro is the only mandatory for the letter details.
%
% \noindent\DescribeMacro{\destinatario}
% |\destinatario|\marg{recipient}
% defines the recipient of the letter, if no recipient is provided the 
% letter will be addressed to "{\em To whom it may concern}"
% (or "{\em A chi di competenza}" if the languaga is italian).
% 
% \noindent\DescribeMacro{\luogo}
% |\luogo|\marg{place}
% defines the place that accompanies the date, it is by default "{\em Torino}" 
% 
% \noindent\DescribeMacro{\data}
% |\data|\marg{date}
% defines a date to be used at the bottom of the letter instead of the current date.
% 
% \noindent\DescribeMacro{\esoggetto}
% |\esoggetto|\marg{label}
% changes the word that precedes the subject topic, replaces the default "{\em Subject:}".
%
% \noindent\DescribeMacro{\protocollo}
% |\protocollo|\marg{label}
% define a protol number if empty, only the ``{\em Prot:}'' will appear at top left.
%
% \subsection{Logo}
% 
% \noindent\DescribeMacro{\logo}
% |\logo|\marg{image file}
% defines the image file containing the logo used in the header of the letter.
% The logo must be square with at least 400x400 pixel resolution.
% The default is the Politecnico di Torino logo.
%
% \subsection{Language}
% The document language can be specified as either |italian| or |english|
% as class parameter e.g. as |\documentclass[italian]{TOPletter}|.
% The default language is |italian|.
%
% The language can be detected using the |\IfLanguageName| macro to adapt the
% document contents to the specific language. This can be useful if a template
% file is used for both languages, for instance if we want to adapt the OU type
% and name according to the language we can add in the tex file the following:
%
% \begin{verbatim}
% \IfLanguageName{italian}{ %% department italian name:
%   \dipartimentoDi{Automatica e Informatica}
% }{%% department english name:
%   \dipartimentoDi{Control and Computer Engineering}
% }
% \end{verbatim}
% Automatically, based on the document language (defined as documentclass parameter),
% the correct naming for the department will be used.
%
%
%
% \section{Example}
% \label{sec:example}
% This section reports a very basic example of a short template used for writing a
% bilingual letter.
% \begin{mdframed}
% \begin{verbatim}
% \documentclass[english]{TOPletter}
% %% Load any additional package
% \usepackage{lipsum}
% 
% \IfLanguageName{italian}{ %% italian names
%   \dipartimentoDi{Disegno e Animazione}
%   \ruolo{Produttore}
% }{%% english names
%   \dipartimentoDi{Comics and Cartoons}
%   \ruolo{Producer}
% }
%
% %% personal details
% \nome{Walt DISNEY}
% \telefono{+1 555 123 4567}
% \email{walt.disney@polito.it}
% \homepage{http://www.polito.it/wdisney/}
%
% %% Subject
% \soggetto{Sample letter}
%
% \begin{document}
% %% Letter content
% This is the typical appearance of a PoliTo letter.
%
% \lipsum
% \end{document}
% \end{verbatim}
% \end{mdframed}
%
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \iffalse
%<*class>
% \fi
% \section{Implementation}
%
% This class is based on the standard class article, it uses an A4 paper
% format since it is the standard in EU, the default font size is set to 11pt.
%    \begin{macrocode}
\LoadClass[a4paper,11pt]{article}
%    \end{macrocode}
% The class is designe to work with two languages |italian| and |english|.
%
%    \begin{macrocode}
\def\topl@language{main=italian,english}
\DeclareOption{italian}{\def\topl@language{main=italian,english}}
\DeclareOption{english}{\def\topl@language{main=english,italian}}
\ProcessOptions\relax
%    \end{macrocode}
%
% \subsection{Used packages}
%    \begin{macrocode}
\RequirePackage[a4paper,bottom=8cm,top=2cm,left=2cm,right=2cm]{geometry}
\RequirePackage{graphicx}
\RequirePackage{color}
\RequirePackage{helvet}
\RequirePackage{changepage}
\RequirePackage{setspace}
\RequirePackage{fancyhdr}
\RequirePackage[utf8]{inputenc}
\RequirePackage{hyperref}
\RequirePackage[\topl@language]{babel}
\RequirePackage{iflang}
%    \end{macrocode}
%
% \subsection{Colors}
% Offical PoliTo colors defined in the Corporate Image Guidelines.
% 
%    \begin{macrocode}
\definecolor{orange}{cmyk}{0,.70,1.00,0} %C0/M70/Y100/K0
\definecolor{blue}{cmyk}{1.00,.80,0,.30} %C100/M80/Y0/K30
%    \end{macrocode}
% and we define accordingly the font faces and colors and a few
% macros to set text color quickly.
%
%    \begin{macrocode}
\renewcommand*\familydefault{\sfdefault}
\newcommand{\cond}[1]{\fontseries{mc}\selectfont {#1}}
\newcommand{\condb}[1]{\fontseries{bc}\selectfont {#1}}
\newcommand{\orange}[1]{\color{orange}{#1}}
\newcommand{\blue}[1]{\color{blue}{#1}}
\newcommand{\red}[1]{\color{red}{#1}}
%    \end{macrocode}
% \subsection{Headers and footer}
% Define the height of the head and the extra space at the bottom of the page:
%    \begin{macrocode}
\setlength{\headheight}{4.1cm}
\setlength{\footskip}{2cm}
%    \end{macrocode}
% The header part of the logo is define using the |fancyhdr| package.
%    \begin{macrocode}
\fancypagestyle{plain}{
\fancyhf{} % empty plus
%    \end{macrocode}
% The header contains only the left part, and it is equal on both
% even and odd pages. In particular it contains the square logo
% followed by the name of the department.
%    \begin{macrocode}
\fancyhead[LE,LO]{
\makebox[2.15cm]{\includegraphics[width=2cm,height=2cm]{\toplLogo}}
{\color{blue}\rule{0.4pt}{2cm}}
\hspace{1pt}
\parbox[b]{5cm}{
\condb{\fontsize{10.5pt}{10pt}\selectfont 
{\blue POLITECNICO\linebreak
	   \raisebox{3pt}{DI TORINO}}}\\
{\fontsize{7.5pt}{6pt}\selectfont \cond {\blue{%
\raisebox{-14pt}{\toplTipoStruttura}\\ \toplStruttura{} }}}%
}\\
%    \end{macrocode}
% After that we have the name and role of the person writing the letter
%    \begin{macrocode}
{\sffamily \small 
\vspace{0.8cm}
\hspace{2.5cm}\color{blue}{\cond{\toplRuolo{}}}\\
\hspace{2.5cm}\color{orange}{\condb{\toplNome{}}}}}
%    \end{macrocode}
% The footer is the same on odd and even pages and contains a reference to
% the structure and the address
%    \begin{macrocode}
\fancyfoot[LE,LO]{\small \cond{\color{blue}{{\bf \toplTipoStruttura \toplStruttura}\\
Politecnico di Torino - Corso Duca degli Abruzzi 24 - 10129 Torino - Italia\\
tel:\toplTelefono{} \ifdefined\toplFax\hspace{4pt} fax:\toplFax\fi} \\
\color{orange}{\href{mailto:\toplEmail}{\toplEmail}\hspace{4pt}%
 \ifdefined\toplHome\href{\toplHome}{\toplHome}%
 \fi \hspace{4pt} \href{http://www.polito.it}{http://www.polito.it}}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\pagestyle{plain}
%    \end{macrocode}
% \subsection{Language specific issues}
% The name of the structure is different in english and in italian,
% the two default version -- i.e. Dipartimento and Department -- are 
% predefined depending on the language:
%    \begin{macrocode}
\IfLanguageName{italian}{
	\newcommand{\toplTipoStruttura}{Dipartimento di }
	\newcommand{\toplDest}{A chi di competenza}
	\newcommand{\toplSubjectLabel}{Oggetto}
}{
	\newcommand{\toplTipoStruttura}{Department of }
	\newcommand{\toplDest}{To whom it may concern}
	\newcommand{\toplSubjectLabel}{Subject}
}
%    \end{macrocode}
% \subsection{Letter customization parameters}
% There are several parameters that can be used to customize the letter:
%    \begin{macrocode}
\newcommand{\dipartimentoDi}[1]{\def\toplStruttura{#1}}
\newcommand{\struttura}[1]{\def\toplTipoStruttura{#1}}
\newcommand{\ruolo}[1]{\makeatletter\def\toplRuolo{#1}\makeatother}
\newcommand{\nome}[1]{\makeatletter\def\toplNome{#1}\makeatother}
\newcommand{\telefono}[1]{\makeatletter\def\toplTelefono{#1}\makeatother}
\newcommand{\fax}[1]{\makeatletter\def\toplFax{#1}\makeatother}
\newcommand{\email}[1]{\makeatletter\def\toplEmail{#1}\makeatother}
\newcommand{\homepage}[1]{\def\toplHome{#1}}
\newcommand{\soggetto}[1]{\def\toplSubject{#1}}
\newcommand{\esoggetto}[1]{\def\toplSubjectLabel{#1}}
\newcommand{\destinatario}[1]{\def\toplDest{#1}}
\newcommand{\firma}[1]{\def\toplSignature{#1}}
\newcommand{\logo}[1]{\def\toplLogo{#1}}
\newcommand{\luogo}[1]{\def\toplLuogo{#1}}
\newcommand{\data}[1]{\def\toplData{#1}}
\newcommand{\protocollo}[1]{\def\toplProtocollo{#1}}
\def\toplLogo{LogoPolitoBlu.pdf}
\def\toplLuogo{Torino}
\def\toplData{\today}
%    \end{macrocode}
% \subsection{Checks}
% Several checks of completeness are performed at the beginning of the document.
%    \begin{macrocode}
\AtBeginDocument{
\ifdefined\toplEmail \else
\ClassError{TOPLetter} {Manca l'email}
{L'email deve essere definito con \protect\email{}.}
\fi
\ifdefined\toplTelefono \else
\ClassError{TOPLetter} {Manca il numero di telefono}
{Il numero di telefono deve essere definito con \protect\telefono{}.}
\fi
\ifdefined\toplNome \else
\ClassError{TOPLetter} {Manca il nome}
{Il nome della persona deve essere definito con \protect\nome{}.}
\fi
\ifdefined\toplRuolo \else
\ClassError{TOPLetter} {Manca il ruolo}
{Il ruolo deve essere definito con \protect\ruolo{}.}
\fi
\ifdefined\toplStruttura \else
\ClassError{TOPLetter} {Manca il nome della struttura}
{Il nome della struttura deve essere definito con \protect\struttura{}.}
\fi
\IfFileExists{\toplLogo} {} 
{
\ClassError{TOPLetter} {Il file di logo '\toplLogo' non e' stato trovato.}
{Il file deve avere come nome 'PoliLogoBlu.png' oppure essere definito
tramite il comando \protect\logo{}.\MessageBreak
Il file deve essere quadrato e con risoluzione sufficiente,
almeno 400x400 pixel.
}
}
%    \end{macrocode}
% \subsection{Begin of the letter}
% The initial part of the letter includes the recipient of  the letter
%    \begin{macrocode}
\ifdefined\toplProtocollo
Prot. \toplProtocollo
\vspace{1cm}
\fi
\begin{adjustwidth}{10cm}{}
	\toplDest
\end{adjustwidth}
\vspace{1cm}
%    \end{macrocode}
% After the recicpient the subject of the letter is specified
%    \begin{macrocode}
\ifdefined\toplSubject
\begin{center}
{\Large {\bf \toplSubjectLabel: \toplSubject }}
\end{center}
\fi
}
%    \end{macrocode}
% \subsection{End of the letter}
% at the end of the letter we have the place and date, followed by the signature,
% if defined.
%    \begin{macrocode}
\AtEndDocument{
\vspace{2cm}
\hspace{.6\textwidth}
\parbox{5cm}{
\centering
\toplLuogo, \toplData\\
\toplNome\\
\ifdefined\toplSignature
	\includegraphics[width=4cm]{\toplSignature}
\fi
}
}
%    \end{macrocode}
%% \iffalse
%</class>
% \fi
% \Finale
% \iffalse
%<*sampleIt>
% \fi
\documentclass{TOPletter}
%% Carica package necessari
\usepackage{lipsum}

%% dipartimento
\dipartimentoDi{Disegno e Animazione}

%% dettagli personali
\ruolo{Fumettista }
\nome{Walt DISNEY}
\telefono{+1 555 123 4567}
\email{walt.disney@polito.it}
\homepage{http://www.polito.it/wdisney/}
\firma{Walt_Disney_1942_signature.pdf}
%% Subject
\soggetto{Esempio di lettera}
\protocollo{}
\begin{document}
%% Letter content
Ecco l'aspetto di una lettera PoliTo...

\lipsum

\end{document}
% \iffalse
%</sampleIt>
%<*sampleEn>
% \fi
\documentclass[english]{TOPletter}
%% Load any additional package
\usepackage{lipsum}

\IfLanguageName{italian}{ %% italian names
  \dipartimentoDi{Disegno e Animazione}
  \ruolo{Produttore}
}{%% english names
  \dipartimentoDi{Comics and Cartoons}
  \ruolo{Producer}
}

%% personal details
\nome{Walt DISNEY}
\telefono{+1 555 123 4567}
\email{walt.disney@polito.it}
\homepage{http://www.polito.it/wdisney/}

%% Subject
\soggetto{Sample letter}

\begin{document}
%% Letter content
This is the typical appearance of a PoliTo letter.

\lipsum
\end{document}
% \iffalse
%</sampleEn>
% \fi
\endinput