Debian Codegraph @

texmf-dist/source/latex/base/alltt.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 % \iffalse
30 %%
31 %% File `alltt.dtx'.
32 %% Copyright (C) 1987 by Leslie Lamport
33 %% Copyright (C) 1994-2021 LaTeX Project, Johannes Braams
34 %% all rights reserved.
35 %%
36 %<*dtx>
37 \ProvidesFile{alltt.dtx}
38 %</dtx>
39 %<package>\NeedsTeXFormat{LaTeX2e}
40 %<package>\ProvidesPackage{alltt}
41 %<driver>\ProvidesFile{alltt.drv}
42 %\ProvidesFile{alltt.dtx}
43 [2024/07/07 v2.0g defines alltt environment]
44 %
45 %<*driver>
46 \documentclass{ltxdoc}
47 \usepackage{alltt}
48 \begin{document}
49 \providecommand{\Lenv}[1]{\textsf{#1}}
50 \providecommand{\pkg}[1]{\texttt{#1}}
51 \providecommand{\file}[1]{\texttt{#1}}
52 \DocInput{alltt.dtx}
53 \end{document}
54 %</driver>
55 % \fi
56 %
57 % \changes{v2.0g}{1997/06/16}{A few documentation fixes (PR 2520)}
58 % \changes{v2.0d}{1995/04/02}{A few documentation fixes (PR 1517)}
59 % \changes{v2.0g}{2021-01-29}{Added a warning about OT1 versus T1 font
60 % encoding}
61 %
62 % \GetFileInfo{alltt.dtx}
63 % \title{The \texttt{alltt} environment\thanks{This file
64 % has version number \fileversion, last
65 % revised \filedate.}}
66 % \author{Johannes Braams}
67 % \date{\filedate}
68 % \MaintainedByLaTeXTeam{latex}
69 % \maketitle
70 %
71 % \begin{abstract}
72 % This package defines the \Lenv{alltt} environment, which is like
73 % the \Lenv{verbatim} environment except that |\|, |{|, and |}|
74 % have their usual meanings.
75 %
76 % Thus, other commands and environments can appear within an
77 % \Lenv{alltt} environment.
78 % \end{abstract}
79 %
80 % \section{Introduction}
81 %
82 % \DescribeEnv{alltt}
83 % Here are some things you may want to do in an \Lenv{alltt}
84 % environment:
85 % \begin{itemize}
86 % \item Change fonts--e.g., by typing |\emph{emphasized text}|
87 %
88 % \item Insert text from a file \file{foo.tex} by typing
89 % |\input{foo}|. Beware that each |<return>| starts a new line, so
90 % if \file{foo.tex} ends with a |<return>| you can wind up with an
91 % extra blank line if you're not careful.
92 %
93 % \item Insert a math formula. Note that |$| just produces a dollar
94 % sign, so you'll have to type |\(...\)| or |\[...\]|. Also, |^|
95 % and |_| just produce their characters; use |\sp| or |\sb| for
96 % super- and subscripts, as in |\(x\sp{2}\)|.
97 % \end{itemize}
98 %
99 % \textbf{NB} When you are using \textsf{OT1} encoded fonts you might
100 % be surprised when you switch to italics, because those fonts have
101 % a different set of glyphs:
102 % \begin{alltt}
103 % The glyph at the position of the $ in a slanted font: \textsl{$}.
104 % The glyph at the position of the $ in an italic font: \textit{$}.
105 % \end{alltt}
106 %
107 % \MaybeStop{}
108 %
109 % \section{The Implementation}
110 %
111 % \begin{macrocode}
112 %<*package>
113 % \end{macrocode}
114 %
115 % \begin{environment}{alltt}
116 % The \Lenv{alltt} environment is similar to the \Lenv{verbatim}
117 % environment, except that |\|, |{| and |}| have their usual
118 % behaviour.
119 % \changes{v2.0b}{1994/10/29}{Added a missing \cs{dospecials}}
120 % \changes{v2.0c}{1995/01/27}{Reset \cs{dospecials} after its changed
121 % version is executed}
122 % \changes{v2.0e}{1995/05/13}{brought definition up to date with the
123 % verbatim environment}
124 % \changes{v2.0e}{1995/05/13}{Save and restore (in math mode) the
125 % definition of the \texttt{'} character}
126 % \begin{macrocode}
127 \begingroup
128 \lccode`\~=`\'
129 \lowercase{\endgroup
130 \newenvironment{alltt}{%
131 \trivlist
132 \item\relax
133 \if@minipage
134 \else
135 \vskip\parskip
136 \fi
137 \leftskip\@totalleftmargin
138 \rightskip\z@skip
139 \parindent\z@
140 \parfillskip\@flushglue
141 \parskip\z@skip
142 \@@par
143 \@tempswafalse
144 \def\par{%
145 \if@tempswa
146 \leavevmode\null\@@par\penalty\interlinepenalty
147 \else
148 \@tempswatrue
149 \ifhmode\@@par\penalty\interlinepenalty\fi
150 \fi}
151 \obeylines
152 \verbatim@font
153 \let\org@prime~%
154 \@noligs
155 % \end{macrocode}
156 % \changes{v2.0f}{1995/07/24}{Added setting of the \cs{catcode} of the
157 % \texttt{'} character}
158 % \begin{macrocode}
159 \everymath\expandafter{\the\everymath
160 \catcode`\'=12 \let~\org@prime}
161 \everydisplay\expandafter{\the\everydisplay
162 \catcode`\'=12 \let~\org@prime}
163 \let\org@dospecials\dospecials
164 \g@remfrom@specials{\\}
165 \g@remfrom@specials{\{}
166 \g@remfrom@specials{\}}
167 \let\do\@makeother
168 \dospecials
169 \let\dospecials\org@dospecials
170 \frenchspacing\@vobeyspaces
171 \everypar \expandafter{\the\everypar \unpenalty}}
172 {\endtrivlist}}
173 % \end{macrocode}
174 % \end{environment}
175 %
176 % \begin{macro}{\g@remfrom@specials}
177 % In the old implementation of the \pkg{alltt} package a fixed
178 % |\dospecials| was used. However nowadays the |\dospecials|
179 % command might contain more special characters at run-time then as
180 % was defined in the format. Therefore we remove the necessary
181 % special character from |\dospecials| at the start of the
182 % \Lenv{alltt} environment. For this we need a macro. Remember that
183 % the list of special characters in |\dospecials| contains the
184 % control sequence |\do| between the characters. We use that to
185 % check whether a character has to be removed.
186 %
187 % The macro |\g@remfrom@specials| takes one argument, the character
188 % to be removed from the list.
189 % \begin{macrocode}
190 \def\g@remfrom@specials#1{%
191 % \end{macrocode}
192 % We build up a new list in |\@new@speicals|.
193 % \begin{macrocode}
194 \def\@new@specials{}
195 % \end{macrocode}
196 % The command |\@remove| compares its argument with the argument of\\
197 % |\g@remfrom@specials|.
198 % \begin{macrocode}
199 \def\@remove##1{%
200 \ifx##1#1\else
201 % \end{macrocode}
202 % When they are not the same the argument of |\@remove| is added
203 % (together with |\do|) to the new list.
204 % \begin{macrocode}
205 \g@addto@macro\@new@specials{\do ##1}\fi}
206 % \end{macrocode}
207 % Now we |\let| |\do| be equal to |\@remove| and execute
208 % |\dospecials|.
209 % \begin{macrocode}
210 \let\do\@remove\dospecials
211 % \end{macrocode}
212 % All that's left is to make |\dospecials| point to the new list.
213 % \begin{macrocode}
214 \let\dospecials\@new@specials
215 }
216 % \end{macrocode}
217 % \end{macro}
218 %
219 % \begin{macrocode}
220 %</package>
221 % \end{macrocode}
222 %
223 % \Finale
224 \endinput