Debian Codegraph @

texmf-dist/source/latex/topletter/TOPletter.dtx

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