Debian Codegraph @

texmf-dist/source/latex/upquote/upquote.dtx

raw
1 % \iffalse
2 %<package>\NeedsTeXFormat{LaTeX2e}
3 %<package>\ProvidesPackage{upquote}
4 %<package> [2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbatim]
5 %
6 %<*driver>
7 \documentclass{ltxdoc}
8 \usepackage{upquote}
9 \usepackage{url}
10 \DisableCrossrefs
11 \RecordChanges
12 \setcounter{secnumdepth}{-1} % suppress part and section numbers
13 \begin{document}
14 \DocInput{upquote.dtx}
15 \end{document}
16 %</driver>
17 % \fi
18 %
19 % \CheckSum{40}
20 %
21 %\GetFileInfo{upquote.sty}
22 %
23 %\title{\textsf{upquote} -- upright-quote and grave-accent glyphs\linebreak
24 % in verbatim\thanks{This file describes version \fileversion,
25 % last revised \filedate.}}
26 %\author{Michael A. Covington\thanks{Artificial Intelligence Center,
27 % The University of Georgia, \texttt{http://www.ai.uga.edu/\char126mc/}} ,
28 % Frank Mittelbach,
29 % Markus G.~Kuhn\thanks{University of Cambridge, Computer Laboratory,
30 % \texttt{http://www.cl.cam.ac.uk/\char126mgk25/}}}
31 %\date{\filedate}
32 %
33 %\maketitle
34 %
35 %\section{Introduction}
36 %
37 %By default, the \LaTeX\ \verb+\verb+ macro and \texttt{verbatim}
38 %environment display ASCII characters 27 and 60 as \texttt{'} and
39 %\texttt{`}, respectively, in line with how these two characters are
40 %used to typeset opening and closing quotation marks elsewhere in
41 %\TeX. However, the character-set standards define character 27 to
42 %represent a straight single quotation mark \texttt{\char13} and
43 %character 60 as a grave accent \texttt{\char18}. This is what most
44 %modern fonts show, and what readers of software source code are now
45 %likely to expect~\cite{Cov94,Kuh99}. The curly quotation mark
46 %characters \texttt{`} and \texttt{'} are instead associated with
47 %Unicode positions U+2018 and U+2019.
48 %
49 %\section{Usage}
50 %
51 %Add \verb+\usepackage{upquote}+ to the preamble (preferably after any
52 %packages that change fonts or font encoding), and the behaviour of
53 %the macros \verb+\verb+ and \verb+\verb*+ and the environments
54 %\texttt{verbatim} and \texttt{verbatim*} will change such that ASCII
55 %characters 27 and 60 appear as \texttt{\char13} and \texttt{\char18}
56 %rather than \texttt{'} and \texttt{`}. This does not affect \verb+\tt+,
57 %\verb+\texttt+, etc.
58 %
59 %When the Computer Modern typewriter font \texttt{cmtt} in Knuth's
60 %original OT1 encoding is used (i.e., \verb+\encodingdefault=OT1+,
61 %\verb+\ttdefault=cmtt+), then the two replacement glyphs are taken
62 %from that same font, where they are already available at positions
63 %13 and 18. If any other font or font encoding is used, then the
64 %\texttt{textcomp} package is loaded and its \verb+\textquotesingle+
65 %and \verb+\textasciigrave+ macros are used to typeset these characters.
66 %
67 %This package loads \texttt{textcomp.sty} only if the use of a
68 %non-\texttt{cmtt} font or a non-OT1 font encoding was already evident
69 %at the point where \texttt{upquote.sty} was loaded. If such changes
70 %happen later, add |\usepackage{textcomp}| yourself.
71 %
72 %\StopEventually{
73 % \begin{thebibliography}{1}
74 % \bibitem{Cov94} M.~Covington, \emph{Computer Languages in Type},
75 % Journal of Scholarly Publishing, 26.1:34--41, 1994.
76 % \bibitem{Kuh99} M.~Kuhn, \emph{ASCII and Unicode quotation marks},
77 % 1999.\\ \url{http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html}
78 % \end{thebibliography}
79 %}
80 %
81 % \part{Appendix}
82 % \appendix
83 % \section{Implementation}
84 %
85 %\changes{v1.0}{2000/12/11}{Fix bug that replaced '0 and `0}
86 %\changes{v1.1}{2003/06/19}{Switched to textcomp package}
87 %\changes{v1.2}{2012/04/04}{Use textcomp only with fonts other than the default cmtt with OT1}
88 %\changes{v1.3}{2012/04/19}{Bug fix: removed two spurious space characters from \@noligs}
89 %
90 %We check |\encodingdefault| and |\ttdefault| to see whether the
91 %glyphs that are already in \texttt{cmtt} as |\char13|
92 %(\texttt{\char13}) and |\char18| (\texttt{\char18}) can be used, or
93 %whether textcomp has to be loaded to access such glyphs.
94 %
95 % \begin{macrocode}
96 \newcommand\upquote@cmtt{cmtt}
97 \newcommand\upquote@OTone{OT1}
98 \ifx\encodingdefault\upquote@OTone
99 \ifx\ttdefault\upquote@cmtt\else\RequirePackage{textcomp}\fi
100 \else
101 \RequirePackage{textcomp}
102 \fi
103 % \end{macrocode}
104 %The |\@noligs| macro is called by |\verb| and |\begin{verbatim}| to
105 %turn the characters \texttt{` < > , ' -} into active characters that
106 %merely print themselves rather than activating ligatures.
107 %
108 %This package merely adds code to \verb+\@noligs+ that changes the
109 %glyphs used for \texttt{`} and \texttt{'}.
110 % \begin{macrocode}
111 \begingroup
112 \catcode`'=\active
113 \catcode``=\active
114 \g@addto@macro\@noligs
115 {\let'\textquotesingle
116 \let`\textasciigrave
117 \ifx\encodingdefault\upquote@OTone
118 \ifx\ttdefault\upquote@cmtt
119 \def'{\char13 }%
120 \def`{\char18 }%
121 \fi\fi}
122 \endgroup
123 % \end{macrocode}
124 %We check |\encodingdefault| and |\ttdefault| again at each invocation
125 %of |\verb| or |\begin{verbatim}|, such that users can change fonts
126 %and encodings within a document.
127 %\Finale