summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/upquote/upquote.dtx
blob: 8fd012d22ac34d320f6f0d648bb9a7dcc63738dd (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
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{upquote}
%<package>   [2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbatim]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{upquote}
\usepackage{url}
\DisableCrossrefs
\RecordChanges
\setcounter{secnumdepth}{-1}  % suppress part and section numbers
\begin{document}
  \DocInput{upquote.dtx}
\end{document}
%</driver>
% \fi
% 
% \CheckSum{40}
%
%\GetFileInfo{upquote.sty}
%
%\title{\textsf{upquote} -- upright-quote and grave-accent glyphs\linebreak
%  in verbatim\thanks{This file describes version \fileversion,
%  last revised \filedate.}}
%\author{Michael A. Covington\thanks{Artificial Intelligence Center,
%  The University of Georgia, \texttt{http://www.ai.uga.edu/\char126mc/}} ,
%  Frank Mittelbach,
%  Markus G.~Kuhn\thanks{University of Cambridge, Computer Laboratory,
%  \texttt{http://www.cl.cam.ac.uk/\char126mgk25/}}}
%\date{\filedate}
%
%\maketitle
%
%\section{Introduction}
%
%By default, the \LaTeX\ \verb+\verb+ macro and \texttt{verbatim}
%environment display ASCII characters 27 and 60 as \texttt{'} and
%\texttt{`}, respectively, in line with how these two characters are
%used to typeset opening and closing quotation marks elsewhere in
%\TeX. However, the character-set standards define character 27 to
%represent a straight single quotation mark \texttt{\char13} and
%character 60 as a grave accent \texttt{\char18}. This is what most
%modern fonts show, and what readers of software source code are now
%likely to expect~\cite{Cov94,Kuh99}. The curly quotation mark
%characters \texttt{`} and \texttt{'} are instead associated with
%Unicode positions U+2018 and U+2019.
%
%\section{Usage}
%
%Add \verb+\usepackage{upquote}+ to the preamble (preferably after any
%packages that change fonts or font encoding), and the behaviour of
%the macros \verb+\verb+ and \verb+\verb*+ and the environments
%\texttt{verbatim} and \texttt{verbatim*} will change such that ASCII
%characters 27 and 60 appear as \texttt{\char13} and \texttt{\char18}
%rather than \texttt{'} and \texttt{`}. This does not affect \verb+\tt+,
%\verb+\texttt+, etc.
%
%When the Computer Modern typewriter font \texttt{cmtt} in Knuth's
%original OT1 encoding is used (i.e., \verb+\encodingdefault=OT1+,
%\verb+\ttdefault=cmtt+), then the two replacement glyphs are taken
%from that same font, where they are already available at positions
%13 and 18. If any other font or font encoding is used, then the
%\texttt{textcomp} package is loaded and its \verb+\textquotesingle+
%and \verb+\textasciigrave+ macros are used to typeset these characters.
%
%This package loads \texttt{textcomp.sty} only if the use of a
%non-\texttt{cmtt} font or a non-OT1 font encoding was already evident
%at the point where \texttt{upquote.sty} was loaded. If such changes
%happen later, add |\usepackage{textcomp}| yourself.
%
%\StopEventually{
%  \begin{thebibliography}{1}
%    \bibitem{Cov94} M.~Covington, \emph{Computer Languages in Type},
%        Journal of Scholarly Publishing, 26.1:34--41, 1994.
%    \bibitem{Kuh99} M.~Kuhn, \emph{ASCII and Unicode quotation marks},
%        1999.\\ \url{http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html}
%  \end{thebibliography}
%}
%
% \part{Appendix}
% \appendix
% \section{Implementation}
%
%\changes{v1.0}{2000/12/11}{Fix bug that replaced '0 and `0}
%\changes{v1.1}{2003/06/19}{Switched to textcomp package}
%\changes{v1.2}{2012/04/04}{Use textcomp only with fonts other than the default cmtt with OT1}
%\changes{v1.3}{2012/04/19}{Bug fix: removed two spurious space characters from \@noligs}
%
%We check |\encodingdefault| and |\ttdefault| to see whether the
%glyphs that are already in \texttt{cmtt} as |\char13|
%(\texttt{\char13}) and |\char18| (\texttt{\char18}) can be used, or
%whether textcomp has to be loaded to access such glyphs.
%
%    \begin{macrocode}
\newcommand\upquote@cmtt{cmtt}
\newcommand\upquote@OTone{OT1}
\ifx\encodingdefault\upquote@OTone
  \ifx\ttdefault\upquote@cmtt\else\RequirePackage{textcomp}\fi
\else
  \RequirePackage{textcomp}
\fi
%    \end{macrocode}
%The |\@noligs| macro is called by |\verb| and |\begin{verbatim}| to
%turn the characters \texttt{` < > , ' -} into active characters that
%merely print themselves rather than activating ligatures.
%
%This package merely adds code to \verb+\@noligs+ that changes the
%glyphs used for \texttt{`} and \texttt{'}.
%    \begin{macrocode}
\begingroup
\catcode`'=\active               
\catcode``=\active               
\g@addto@macro\@noligs
   {\let'\textquotesingle
    \let`\textasciigrave
    \ifx\encodingdefault\upquote@OTone
    \ifx\ttdefault\upquote@cmtt
    \def'{\char13 }%
    \def`{\char18 }%
    \fi\fi}
\endgroup
%    \end{macrocode}
%We check |\encodingdefault| and |\ttdefault| again at each invocation
%of |\verb| or |\begin{verbatim}|, such that users can change fonts
%and encodings within a document.
%\Finale