summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex-dev/base/alltt.dtx
blob: 0810cd730230b6a638f57f3e36eb0c106d330a55 (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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
% \iffalse meta-comment
%
% Copyright (C) 1993-2021
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
% -------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.txt'. See also `legal.txt' for additional
% information.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
% \iffalse
%%
%% File `alltt.dtx'.
%% Copyright (C) 1987 by Leslie Lamport
%% Copyright (C) 1994--2020 LaTeX3 project, Johannes Braams
%%                       all rights reserved.
%%
%<*dtx>
\ProvidesFile{alltt.dtx}
%</dtx>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{alltt}
%<driver>\ProvidesFile{alltt.drv}
%\ProvidesFile{alltt.dtx}
              [2020/11/23 v2.0g defines alltt environment]
%
%<*driver>
\documentclass{ltxdoc}
\begin{document}
\providecommand{\Lenv}[1]{\textsf{#1}}
\providecommand{\pkg}[1]{\texttt{#1}}
\providecommand{\file}[1]{\texttt{#1}}
\DocInput{alltt.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{v2.0g}{1997/06/16}{A few documentation fixes (PR 2520)}
% \changes{v2.0d}{1995/04/02}{A few documentation fixes (PR 1517)}
%
%  \GetFileInfo{alltt.dtx}
%  \title{The \texttt{alltt} environment\thanks{This file
%        has version number \fileversion, last
%        revised \filedate.}}
%  \author{Johannes Braams}
%  \date{\filedate}
%  \MaintainedByLaTeXTeam{latex}
%  \maketitle
%
%    \begin{abstract}
%    This package defines the \Lenv{alltt} environment, which is like
%    the \Lenv{verbatim} environment except that |\|, |{|, and |}|
%    have their usual meanings.
%
%    Thus, other commands and environments can appear within an
%    \Lenv{alltt} environment.
%    \end{abstract}
%
%  \section{Introduction}
%
%  \DescribeEnv{alltt}
%   Here are some things you may want to do in an \Lenv{alltt}
%   environment:
%   \begin{itemize}
%   \item Change fonts--e.g., by typing |{\em emphasized text\/}|
%
%   \item Insert text from a file \file{foo.tex} by typing
%    |\input{foo}|. Beware that each |<return>| starts a new line, so
%    if \file{foo.tex} ends with a |<return>| you can wind up with an
%    extra blank line if you're not careful.
%
%   \item Insert a math formula.  Note that |$| just produces a dollar
%   sign, so you'll have to type |\(...\)| or |\[...\]|.  Also, |^|
%   and |_| just produce their characters; use |\sp| or |\sb| for
%   super- and subscripts, as in |\(x\sp{2}\)|.
%   \end{itemize}
%
%  \StopEventually{}
%
%  \section{The Implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%  \begin{environment}{alltt}
%    The \Lenv{alltt} environment is similar to the \Lenv{verbatim}
%    environment, except that |\|, |{| and |}| have their usual
%    behaviour.
% \changes{v2.0b}{1994/10/29}{Added a missing \cs{dospecials}}
% \changes{v2.0c}{1995/01/27}{Reset \cs{dospecials} after its changed
%    version is executed}
% \changes{v2.0e}{1995/05/13}{brought definition up to date with the
%    verbatim environment}
% \changes{v2.0e}{1995/05/13}{Save and restore (in math mode) the
%    definition of the \texttt{'} character}
%    \begin{macrocode}
\begingroup
\lccode`\~=`\'
\lowercase{\endgroup
\newenvironment{alltt}{%
  \trivlist
  \item\relax
    \if@minipage
    \else
      \vskip\parskip
    \fi
    \leftskip\@totalleftmargin
    \rightskip\z@skip
    \parindent\z@
    \parfillskip\@flushglue
    \parskip\z@skip
    \@@par
    \@tempswafalse
    \def\par{%
      \if@tempswa
        \leavevmode\null\@@par\penalty\interlinepenalty
    \else
      \@tempswatrue
      \ifhmode\@@par\penalty\interlinepenalty\fi
    \fi}
    \obeylines
    \verbatim@font
    \let\org@prime~%
    \@noligs
%    \end{macrocode}
% \changes{v2.0f}{1995/07/24}{Added setting of the \cs{catcode} of the
%    \texttt{'} character}
%    \begin{macrocode}
    \everymath\expandafter{\the\everymath
      \catcode`\'=12 \let~\org@prime}
    \everydisplay\expandafter{\the\everydisplay
      \catcode`\'=12 \let~\org@prime}
    \let\org@dospecials\dospecials
    \g@remfrom@specials{\\}
    \g@remfrom@specials{\{}
    \g@remfrom@specials{\}}
    \let\do\@makeother
    \dospecials
    \let\dospecials\org@dospecials
    \frenchspacing\@vobeyspaces
    \everypar \expandafter{\the\everypar \unpenalty}}
{\endtrivlist}}
%    \end{macrocode}
%  \end{environment}
%
%  \begin{macro}{\g@remfrom@specials}
%    In the old implementation of the \pkg{alltt} package a fixed
%    |\dospecials| was used. However nowadays the |\dospecials|
%    command might contain more special characters at run-time then as
%    was defined in the format. Therefore we remove the necessary
%    special character from |\dospecials| at the start of the
%    \Lenv{alltt} environment. For this we need a macro. Remember that
%    the list of special characters in |\dospecials| contains the
%    control sequence |\do| between the characters. We use that to
%    check whether a character has to be removed.
%
%    The macro |\g@remfrom@specials| takes one argument, the character
%    to be removed from the list.
%    \begin{macrocode}
\def\g@remfrom@specials#1{%
%    \end{macrocode}
%    We build up a new list in |\@new@speicals|.
%    \begin{macrocode}
  \def\@new@specials{}
%    \end{macrocode}
%    The command |\@remove| compares its argument with the argument of\\
%    |\g@remfrom@specials|.
%    \begin{macrocode}
  \def\@remove##1{%
    \ifx##1#1\else
%    \end{macrocode}
%    When they are not the same the argument of |\@remove| is added
%    (together with |\do|) to the new list.
%    \begin{macrocode}
    \g@addto@macro\@new@specials{\do ##1}\fi}
%    \end{macrocode}
%    Now we |\let| |\do| be equal to |\@remove| and execute
%    |\dospecials|.
%    \begin{macrocode}
  \let\do\@remove\dospecials
%    \end{macrocode}
%    All that's left is to make |\dospecials| point to the new list.
%    \begin{macrocode}
  \let\dospecials\@new@specials
  }
%    \end{macrocode}
%  \end{macro}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \Finale
\endinput