-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttquot.sty
executable file
·162 lines (150 loc) · 6.04 KB
/
ttquot.sty
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
\NeedsTeXFormat{LaTeX2e}[2.09]
\ProvidesPackage{ttquot}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ttquot.sty
%
% This style is intended to make it easier to write text on technical
% subjects, so that the text is readable even when it is TeX source.
%
% One of the most common problems is switching conveniently into the
% typewriter font and back. This style file makes the ordinary double
% quotation mark (") serve this function. Note that the meaning of \tt
% may be different in math and text mode, for example if the "times"
% package is being used.
%
% This package also makes underscore characters (_) switch into
% emphasized mode and back, unless inside " quotes or in math mode. This
% makes ordinary variable names easier to type in typewriter font, and
% makes emphasized mode obey a common ASCII text convention.
%
% Options:
% sfcode
% Makes text inside quotation marks come out in \sf font.
% small
% Makes text inside quotation marks come out \small (except in math
% mode.) This is especially useful when using the times package, because
% the Courier and Helvetica fonts are larger than Times.
% stdbraces
% By default, the commands \{ and \} emit ordinary characters 123 and
% 125 inside quotation marks. This works well if you are in \tt font,
% but not so well in a font (e.g., \sf) lacking these characters. Use
% stdbraces to defeat it.
% bfemph
% Make underscore turn on boldface instead of italics.
%
% The following macros are defined and may be used or overridden.
%
% \ttquot@activate Turn on ttquot processing. On by default.
% \ttquot@deactivate Turn off ttquot processing.
% \ttquot@ttmode The 'code' environment introduced by "
% \ttquot@emmode The 'emphasized' environment introduced by _
% \ttquot@setup Commands that are emitted in the " environment.
% \ttquot@ttfont The font part of tt@setup, By default, \tt.
% \ttquot@ttsize The font size part of tt@setup, By default, nothing.
% \ttquot@emfont The commands that are emitted in the _ environment.
% By default, \em
% \ttquot@braces Another command emitted in the " environment.
% By default, changes braces to use tt font chars.
% The "stdbraces" option defeats this.
% \ttquot@mark Always represents the plain character (")
% \ttquot@us Represents the original meaning of (_)
%
% This style file is maintained by Andrew Myers (andru@cs.cornell.edu)
%
% Change log:
% Fri Nov 6 14:35:49 EST 1992 Added this documentation andru
% Tue Nov 10 23:05:44 EST 1992 Changed underscore to do \em andru
% Wed Nov 11 17:00:00 EST 1992 Fixed various bugs, added * andru
% Tue Feb 16 23:48:20 EST 1993 Fixed "number" bug, added \* andru
% Tue Mar 23 13:39:39 EST 1993 Got rid of a little cruft andru
% Tue Apr 26 16:07:18 EDT 1994 Made _ work in other fonts andru
% Wed Oct 12 17:39:49 EDT 1994 Made activate/deactivate work andru
% Wed Feb 08 15:00:31 EST 1995 Made * work again andru
% Wed Jun 7 18:08:23 EDT 1995 Got rid of * andru
% Sun Aug 4 15:58:16 EDT 2002 Rewrite using environments andru
% Thu Aug 15 11:39:12 EDT 2002 More documentation andru
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Options
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareOption{sfcode}{\def\ttquot@ttfont{\sf}}
\DeclareOption{small}{\def\ttquot@ttsize{\ifmmode\else\small\fi}}
\DeclareOption{stdbraces}{\def\ttquot@braces{}}
\DeclareOption{bfemph}{\def\ttquot@emfont{\bf}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Save original definitions
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\ttquot@mark="% Catch original definition of quotation mark
\let\ttquot@us=_% Catch original definition of underscore
% Change character codes to make them active temporarily.
\catcode`\"=\active%
\catcode`\_=\active%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Change " to place its contents inside {\ttquot@ttfont ... }
% Also, underscores are underscores, not subscripts
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{ttquot@ttmode}{%
\ttquot@setup%
\def_{\ifmmode\ttquot@us\else\_\fi}%
\def"{\end{ttquot@ttmode}}%
}%
{}
\def\ttquot@setup{\ttquot@ttfont\ttquot@ttsize\ttquot@braces}
\def\ttquot@ttfont{\tt}
\def\ttquot@braces{\def\{{\char123}\def\}{\char125}}
\def\ttquot@ttsize{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Change _ to place its contents inside {\ttquot@emfont ... }
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{ttquot@emmode}{%
\ttquot@emfont%
\def_{\end{ttquot@emmode}}%
}%
{}
\gdef\ttquot@emfont{\em}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Change LaTeX's verbatim mode to use \ttquot@ttfont
% instead of \tt; also, do right thing with _
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\@verbatim{\trivlist \item[]\if@minipage\else\vskip\parskip\fi
\leftskip\@totalleftmargin\rightskip\z@
\parindent\z@\parfillskip\@flushglue\parskip\z@
\@tempswafalse \def\par{\if@tempswa\hbox{}\fi\@tempswatrue\@@par}
\obeylines \ttquot@ttfont
\@noligs \let\do\@makeother \dospecials
\catcode`\_=13%
\def_{\_}%
\catcode``=13%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Macros to turn the package on and off
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef\ttquot@activate{%
\catcode`\"=\active%
\catcode`\_=\active%
\def"{\begin{ttquot@ttmode}}%
\def_{\ifmmode\ttquot@us\else\begin{ttquot@emmode}\fi}%
}
\gdef\ttquot@deactivate{%
\def"{\ttquot@mark}%
\def_{\ttquot@us}%
\catcode`\"=12%
\catcode`\_=8%
}
% Restore character codes to avoid messing up other packages.
% Character codes will be turned back on at beginning of document.
\catcode`\"=12
\catcode`\_=8
\ProcessOptions
\AtBeginDocument{\ttquot@activate}