summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/manuscript/manuscript.dtx
blob: b77c9d43ec0196541112498de3b171b8366e140d (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
% \CheckSum{138}
% \iffalse
%% Copyright (C) 2002 Matej Cepl
%% $Id: manuscript.dtx,v 1.6 2005/09/02 12:08:35 matej Exp $
%% This program may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%
% \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         \~}
%
%<*package>
\NeedsTeXFormat{LaTeX2e}[1996/06/01]
\ProvidesPackage{manuscript}
%</package>
%<*!package>
\ProvidesFile {manuscript.dtx}
%</!package>
   [2015/01/19 1.7 emulate typesetting of typewriter]
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\RecordChanges
\CodelineIndex
\begin{document}
   \DocInput{manuscript.dtx}
\end{document}
%</driver>
%<*!driver>
% \fi

% \DoNotIndex{\@empty,\@ifundefined,\AtBeginDocument,\def,\else}
% \DoNotIndex{\ExecuteOptions,\fi,\huge,\hyphenpenalty,\ifMS@ps}
% \DoNotIndex{\LARGE,\let,\MS@psfalse,\MS@pstrue,\MS@maketitle}
% \DoNotIndex{\newif,\ProcessOptions,\relax,\renewcommand,\RequirePackage}
% \DoNotIndex{\typearea,\usefont}
% \DoNotIndex{\MS@quote,\MS@questquote,\MS@next,\MS@dblq,\MS@sglq}
% \changes{1.0}{2002 May 20}{Initial version}
% \changes{1.2}{2002 May 22}{\cs{fileversion} and \cs{filedate}
% which does not seem to work at all being replaced by \cs{RCS}
% command from \texttt{rcs} package.}
% \changes{1.4}{2002 May 23}{With help of Stepan Kasal (stepan at
% matsrv dot mat dot cas dot cz) I have managed to get
% \cs{fileversion} working, so I have get rid off rcs.sty again.}
% \changes{1.5}{2003 June 26}{Something happened to all |fi|.}
% \changes{1.7}{2015 Januar 19}{New upload to CTAN and fix \TeX{} logo}
% \GetFileInfo{manuscript.dtx}
% \title{\bfseries \texttt{Manuscript}---A Package Emulating
% Typewriter ``Typesetting''}
% \author{Mat\v{e}j Cepl, \texttt{matej at ceplovi dot cz}}
% \date{This document describes package \texttt{manuscript}\\
%       version \fileversion, from \filedate}
% \maketitle
% \MakeShortVerb{\|}
%
% \changes{1.5}{2003 June 26}{Whole this section was
% substantially rewritten---coming from defensive to the
% offensive |:-)|.}
% \section{Purpose}
% Purpose of this package is to emulate appearance of the
% document written on classical typewriter as much as possible.
% So far, whenever backward requirement of some institutions
% (especially universities) to provide paper or thesis in the
% layout developed in times before personal computers emerges on
% any \TeX{}-related public forum, it is met with strong (and
% sometimes even angry) resistance and many advise how to
% overcome resistance of the institution. I totally agree with
% the basic premise of this attempt (of course, \TeX\ was created
% for making ``masterpieces of typography'' not to emulate
% typewriters).
%
% \changes{1.6}{2011 January 27}{Some typos corrected.}
% Having said that, this package goes exactly in the opposite
% direction than these people advise. Instead of trying to avoid
% typewriter-driven layout, it tries to emulate it as much as
% possible. Of course, the most important motivation for such
% package is challenge and curiosity how far I can get
% using just \TeX\ tools in this endeavor. However, there are
% also some real reasons why this package might be useful. First
% of all there are situations when the directives of backward
% layout are non-negotiable (e.\,g.,~in commercial setting or
% with too stiff university). Moreover, my conciliatory character
% leads me more to honor other cultures (and although very
% short-lived and feeble, there \emph{was} a typographical
% culture of typewriters) rather then rejecting them. Actually,
% during work on this package my appreciation of strict
% puritanical simplicity of typewriters just grew
% (and of course, it is obvious that in some aspects typesetting
% documents with this package would create documents of the
% quality never possible with a real typewriter---just \TeX{}'s
% optimal line breaking with few divided words makes a lot of
% difference).
%
% If you like it, enjoy!  If not, sorry, just use another
% package.
%
% Another objective was to secure compatibility both with
% classical |article|-like packages as well as with packages from
% |Koma-script| family.
%
% \StopEventually{\PrintIndex\PrintChanges}
%
% \section{The Coding}
%
% \begin{macro}{MS@ps}
% The first of all we need to create new condition |MS@ps| to
% control package options---whether font Courier should be used
% (if true) or |cmtt|. We cannot use |ifthen| package as it
% redefines catcodes and conflicts with the redefinition of
% quotes for |cmtt| font (see below).
%    \begin{macrocode}
\newif\ifMS@ps
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareOption}
% \begin{macro}{\ExecuteOptions}
% \begin{macro}{\ProcessOptions}
% Declare the options by setting |MS@ps| variable. The options
% |cm| and |cr| set use of font |cmtt| or Courier, respectively.
% We want to use Courier as default option.
%    \begin{macrocode}
\DeclareOption{cm}{\MS@psfalse}
\DeclareOption{cr}{\MS@pstrue}
\ExecuteOptions{cr}
\ProcessOptions\relax
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% We need to read some additional packages which are needed for
% good working of the package: |setspace| because whole document
% should be doublespaced (except for footnotes etc.), |fontenc|
% because we should be able to print all European characters (it
% could be redefined in the document itself \emph{after} loading
% |manuscript| package, and |ragged2e| because of linebreaking
% and ragged justification.
%    \begin{macrocode}
\RequirePackage{setspace}
\RequirePackage[T1]{fontenc}
\RequirePackage[NewCommands]{ragged2e}
\RequirePackage{soul}
%    \end{macrocode}
%
% \begin{macro}{\rmdefault}
% \changes{1.5}{2003 June 26}{With CM-Super we need not \cs{ae}
% package anymore.}
% We need to set up the default font for Roman characters based
% on the boolean variable |MS@ps|.
%    \begin{macrocode}
\ifMS@ps
   \renewcommand{\rmdefault}{pcr}
\else
   \renewcommand{\rmdefault}{cmtt}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\descfont}
% \begin{macro}{\sectfont}
% \changes{1.4}{2002 May 25}{Courier is better, so that this hack
% is better to be used only for \texttt{cmtt} font.}
%
% There is no bold in |cmtt|, so that I redefine also some
% fonts---usefull only for koma-script package, because I do not
% care too much for |article| |:-)|.
%    \begin{macrocode}
\@ifundefined{scr@parskip}{}{%
   \renewcommand*{\descfont}{\scshape}
   \renewcommand*{\sectfont}{\large\scshape} }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\MS@q*}
% \begin{macro}{``}
% \begin{macro}{'}
% This is the most obscure part of the package.\footnote{I have
% recieved substantial help with the deep \TeX\ work from
% Ond\v{r}ej ``Koala'' V\'acha. Thank you.} There are no problems
% with |Courier| font, but |cmtt| does not have some characters
% needed for normal writing---especially quotes. We have to
% change catcode of , and ` characters and redefine couples of
% these characters to be printed in |cmss| font in the Old
% Knuth's coding OT1.
%
% Moreover, and it was the bug in the previous version, we have
% to distinguish between single quote and double quote, where
% each of them should be printed as different character. Now, it
% is getting to be really messy |:-)|.
%
% \changes{1.5}{2003 June 26}{CM-Super fonts work even without
% this kludge.}
% \changes{1.4}{2002 May 22}{There is really no need to use
% \cs{gdef}, when \cs{def} is sufficient.}
% \changes{1.2}{2002 May 22}{Macro \cs{`} is protected.
% Unbelieavable construction in the \cs{change} changed to use
% \cs{cs} macro.}
% \changes{1.1}{2002/05/21}{Whole group of
% \cs{MS@*} macros in this section was added. The previous
% version did not allow use of single apostrophe.}
%    \begin{macrocode}
\iffalse
   \catcode96=13
   \def``{{\usefont{OT1}{cmss}{m}{n}\symbol{92}}}
   \catcode39=13
   \def'{\protect\MS@quote}
   \def\MS@quote{\futurelet \nextchar \MS@questquote}
   \def\MS@questquote{\ifx `\nextchar \let\MS@next=\MS@dblq
      \else \let\MS@next=\MS@sglq
      \fi \MS@next}
   \def\MS@dblq{{\usefont{OT1}{cmss}{m}{n}\symbol{125}}}
   \def\MS@sglq{{\usefont{OT1}{cmss}{m}{n}\symbol{39}}}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\sfdefault}
% \begin{macro}{\ttdefault}
% Of course, in typewritter there are no different fonts for
% sans-serif characters and there is no distinction between
% normal and |tt| characters, thus both of these are set to be
% same as roman characters.
%    \begin{macrocode}
\renewcommand{\sfdefault}{\rmdefault}
\renewcommand{\ttdefault}{\rmdefault}
%    \end{macrocode}
% \end{macro}
% \end{macro}

% \begin{macro}{typearea}
% Of course, typewritter should follow classical ``one inch on
% all sides'' margins (later, variant supporting European
% equivalent on A4 paper may be added). The best is to use
% special package |fullpage|. However, that does not work well
% with |koma-script| family of packages, there we have to
% distinguish between the two and use macro |\typearea| native of
% |koma-script|.
%    \begin{macrocode}
\@ifundefined{typearea}
   {\RequirePackage{fullpage}}
   {\typearea[0pt]{13}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textbf}
% \begin{macro}{\bfseries}
% \begin{macro}{\emph}
% \begin{macro}{\em}
% Italic characters are not enough distinctive in |cmtt| font, so
% we shall redefine macro |\emph| to be same as in the
% typewritter age---underlining characters.
% \changes{1.5}{2003 June 26}{It is handy redefine |em| as
% well---thanks to Petr Ol\v{s}\'ak for this. Also redefine
% bold to small caps.}
%    \begin{macrocode}
\renewcommand{\textbf}[1]{\textsc{#1}}
\def\bfseries{\scshape}

\AtBeginDocument{%
   \setul{0.3ex}{0.15ex}
   \renewcommand{\emph}[1]{\ul{#1}}
   \def\em{\egroup \expandafter \ul \expandafter{\iffalse}\fi}
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}

% \begin{macro}{\spaceskip}
% There are some additional characteristics which should be
% set-up emulating behavior of typewritter: footnotes should be
% set in the normal-size font, document should be double-spaced,
% ragged right. Space between characters have to be set via
% |\spaceskip|---it is zero on default for |tt| fonts.
%    \begin{macrocode}
\let\footnotesize\@empty
\doublespacing
\AtBeginDocument{%
   \raggedright
   \parindent 1em
   \spaceskip .333333 em plus .333333 em minus .111111 em }
%    \end{macrocode}
% \end{macro}
%

% \begin{macro}{\thefootnote}
% \begin{macro}{\@makefnmark}
% \begin{macro}{\@makefntext}
% If the idea of the whole package is to emulate typewriter
% style, then we have to do something about footnotes. There is
% obviously nothing like superscripted footnote mark on
% typewriters. Moreover, I have also changed indentation of the
% body of footnote.
%
% \changes{1.5}{2003 June 26}{Whole redefinition of footnotes
% added.}
%    \begin{macrocode}
\def\thefootnote{\@arabic\c@footnote/}
\def\@makefnmark%
   {\hbox{\normalfont\@thefnmark}}
\renewcommand\@makefntext[1]{%
    \leftskip 1.8em \noindent
    \llap{\normalfont\@thefnmark\ }#1}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@maketitle}
% \changes{1.5}{2003 June 26}{When \cs{titlepage} option is on,
% we need not singlespacing.}
% The standard titlehead of the document is really ugly when
% doublespaced. Therefore we should redefine |\@maketitle| macro.
% However, the trick below (creation of new macro which envelopes
% the original macro) is better, because it is compatible both
% with standard |article|-like classes and |koma-script| family.
% Redefinition of |\huge| is a kind of ugly hack, but it should
% be enough robust and simple to be OK.
%    \begin{macrocode}
\let\MS@maketitle=\@maketitle
  \if@titlepage
      \def\@maketitle{%
         \hyphenpenalty=5000
         \let\huge\LARGE
         \MS@maketitle }
  \else
      \def\@maketitle{%
         \singlespacing
         \hyphenpenalty=5000
         \let\huge\LARGE
         \MS@maketitle }
   \fi
%    \end{macrocode}
% \end{macro}
%
% That's all folks! |:-)|
% \Finale
%\iffalse
%</!driver>
%\fi