summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/grverb/grverb.dtx
blob: a13028d7a26d1024957ce8865f180fe7c2acec7b (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
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%\iffalse
%
% (c) copyright  1999 Apostolos Syropoulos
% This software is derived from original software by the LaTeX3 Project.
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
% However, the above copyright notice does not apply in the case of
% ``Crete University Press'' as this publisher is not allowed to
% use or alter this file in any way.
%
% Please report errors or suggestions for improvement to
%    
%    Apostolos Syropoulos
%    366, 28th October Str.
%    GR-671 00 Xanthi, GREECE
%    apostolo@ocean1.ee.duth.gr or apostolo@obelix.ee.duth.gr
%
%\fi
% \CheckSum{145}
% \iffalse This is a Metacomment
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\GetFileInfo{grverb.drv}
\begin{document}
   \DocInput{grverb.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% \fi
%
%\title{The `grverb' package}
%\author{Apostolos Syropoulos\\366, 28th October Str.\\
%GR-671 00 Xanthi, HELLAS\\ 
%Email:\texttt{apostolo@obelix.ee.duth.gr}\\ or \\
%\hphantom{Email:}\texttt{apostolo@ocean1.ee.duth.gr}}
% \date{1999/12/06}
%\maketitle
% 
%\MakeShortVerb{\|}
%\StopEventually{}
%\section{Introduction}
%
%   One major drawback of the |greek| option of the babel package is that
% one cannot easily write both Latin and Greek verbatim text. This is 
% particularly useful for computer listenings and, more generally, in computer
% science related texts. This package solves this problem by introducing the
% environment |grverbatim| and the command |grverb| whose functionality is 
% identical to the functionality of the corresponding standards. A public
% domain font is used by both the command and the environment. The font
% conforms to the ISO-8859-7 encoding for the Greek language..
% 
%\section{The code}
%  The first thing we do is to identify the package.
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[1996/01/01]
\ProvidesPackage{grverb}[1999/12/06\space v1.0]
\typeout{Package: `grverb' v1.0\space <1999/12/06> (A. Syropoulos)}
%    \end{macrocode}
% Since, we are going to use most characters with slot numbers above 127, we
% need a macro to assign to a range of characters catcode 11 (letter). The
% following macro is a modified version of macro |\inpenc@loop| which is
% defined in the package inputenc.
% 
%\begin{macro}{\@gr@inpenc@loop}
%    \begin{macrocode}
\def\@gr@inpenc@loop#1#2{%
  \@tempcnta`#1\relax
  \loop
    \catcode\@tempcnta11
  \ifnum\@tempcnta<`#2\relax
     \advance\@tempcnta\@ne
  \repeat}
%    \end{macrocode}
%\end{macro}
% The package uses the (public domain) font ``Greek-CourierPlain'' as the 
% default verbatim font. Since, this font is not known to the NFSS, we need 
% to write down the necessary definitions. We introduce a new family and
% since the design size of the new verbatim font is slightly larger than
% that of the cb fonts (i.e., the standart fonts used with the |greek| option
% of the babel package), we need to shrink a little bit the character size
% so that they match with the rest of the text.
% 
%    \begin{macrocode}
\DeclareFontFamily{U}{grtt}{}
\DeclareFontShape{U}{grtt}{m}{n}{
 <-> s * [0.9] grcour8a}{}
%    \end{macrocode}
%
%  We now define the new environment. The code is actually derived from 
% code which appears in the file |ltmiscen.dtx| in the standard \LaTeX2e
% distribution. We define the new environment |grverbatim| which uses
% the new verbatim font, instead of the standard one, and which assigns
% to particular list of characters catcode 11. Note, that these changes
% are local, so not to affect the behavior of \LaTeX.
%\begin{macro}{\grverbatim}
%\begin{macro}{\endgrverbatim}
%    \begin{macrocode} 
\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=12 \catcode `\}=12
\catcode`\\=12 |gdef|@grxverbatim#1\end{grverbatim}[#1|end[grverbatim]]
|endgroup
\def\@grverbatim{\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}%
  \let\do\@makeother \dospecials
  \obeylines \gr@verbatim@font \@noligs
  \everypar \expandafter{\the\everypar \unpenalty}%
}
\def\grverbatim{\begingroup\@gr@inpenc@loop\^^A\^^H%
                           \@gr@inpenc@loop\^^K\^^K%
                           \@gr@inpenc@loop\^^N\^^_%
                           \@gr@inpenc@loop\^^?\^^ff%
         \@grverbatim \frenchspacing\@vobeyspaces \@grxverbatim}
\def\endgrverbatim{\if@newlist \leavevmode\fi\endtrivlist\endgroup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%  We don't use the standard verbatim font, so we define a command to use
% the new verbatim font. This allows us to use the usual verbatim commands
% and environments without any problem.
%\begin{macro}{\gr@verbatim@font}
%    \begin{macrocode}
\def\gr@verbatim@font{\fontencoding{U}\fontfamily{grtt}\fontseries{m}%
\selectfont}
%    \end{macrocode}
%\end{macro}
% The last thing we do is to define the new command |\grverb|. The command is
% actually a modified version of the |\verb| command. The new thing is that
% many non-letter characters become letters and we use the Greek verbatim
% font instead of the standard one.
%\begin{macro}{\grverb}
%    \begin{macrocode}
\def\grverb{\relax\ifmmode\hbox\else\leavevmode\null\fi
  \bgroup
    \@gr@inpenc@loop\^^A\^^H%
    \@gr@inpenc@loop\^^K\^^K%
    \@gr@inpenc@loop\^^N\^^_%
    \@gr@inpenc@loop\^^?\^^ff%
    \verb@eol@error \let\do\@makeother \dospecials
    \gr@verbatim@font\@noligs \@verb}
%</package>
%    \end{macrocode}
%\end{macro}
% \section*{Acknowledgment}
% I thank Antonios Tsolomitis for bringing to my attention this particular
% problem and for testing the proposed solution.
% \section*{Dedication}
% I would like to dedicate this piece of work to my son 
% \begin{center}Demetrios-Georgios.\end{center}
% \Finale
%
\endinput