% \CheckSum{84}
% \iffalse
%% Copyright (C) 2002 Matej Cepl
%% $Id: manuscript.dtx,v 1.3 2002/05/22 17:47:02 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]
%<*dtx>
\ProvidesFile {manuscript.dtx}
%</dtx>
%<+package>\ProvidesPackage{manuscript}
%[2002/05/21 v1.1 emulate typesetting of typewriter]

%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\RecordChanges
\CodelineIndex
\usepackage{rcs}
\RCS $Revision: 1.3 $
\RCS $Date: 2002/05/22 17:47:02 $
\begin{document}
	\DocInput{manuscript.dtx}
\end{document}
%</driver>
% \fi

% \DoNotIndex{\@empty,\@ifundefined,\AtBeginDocument,\def,\else}
% \DoNotIndex{\ExecuteOptions,\fi,\gdef,\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.}

% \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 \RCSRevision, from \RCSDate}
% \maketitle
% \MakeShortVerb{\|}
% 
% \section{Purpose}
% Purpose of this package is to emulate appearance of the
% document written on classical typewriter as much as possible.
% 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).
%^^A<*package>
%    \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. Package |soul| is used for
% redefinition of |\emph| later.
%    \begin{macrocode}
\RequirePackage{setspace}
\RequirePackage[T1]{fontenc}
\RequirePackage[NewCommands]{ragged2e}
\RequirePackage{soul}
%    \end{macrocode}
% 
% \begin{macro}{\rmdefault}
% 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}{aett}
%    \end{macrocode}
% \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 \texttt{<koala at fi dot muni dot
% cz>}. 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.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 apostroph.}
%    \begin{macrocode}
	\catcode96=13
	\gdef``{{\usefont{OT1}{cmss}{m}{n}\symbol{92}}}
	\catcode39=13
	\gdef'{\protect\MS@quote}
	\gdef\MS@quote{\futurelet \nextchar \MS@questquote}
	\gdef\MS@questquote{\ifx `\nextchar \let\MS@next=\MS@dblq
		\else \let\MS@next=\MS@sglq
		\fi \MS@next}
	\gdef\MS@dblq{{\usefont{OT1}{cmss}{m}{n}\symbol{125}}}
	\gdef\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 disctinction 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}{\emph}
% Italic characters are not enough distinctive in tt font, so we
% shall redefine macro |\emph| to be same as in the typewritter
% age---underlining characters.
%    \begin{macrocode}
\renewcommand{\emph}[1]{\ul{#1}}
%    \end{macrocode}
% \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[0sp]{13}}
%    \end{macrocode}
% \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
	\spaceskip .333333 em plus .333333 em minus .111111 em }
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\@maketitle}
% 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
\def\@maketitle{%
	\singlespacing
	\hyphenpenalty=5000
	\let\huge\LARGE
	\MS@maketitle }
%    \end{macrocode}
%^^A</package>
% \end{macro}
% 
% That's all folks! |:-)|
% \Finale
