summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/jknappen/sgmlcmpt.sty
blob: 4c29323024d4cef22ce881f2fccb912a3ad85b06 (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
% sgmlcmpt.sty
%
% (c) Copyleft 1999 J"org Knappen
% Licence: GNU licence version 2
% Documentation: See after \endinput
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sgmlcmpt}[1999/06/01]
\newcommand*\amp{\&}
\newcommand*\lt{<}
\newcommand*\gt{>}
\newcommand*\clmn{&}
\endinput

Unfortunately, one cannot embed LaTeX formulae into SGML as #PCDATA. The
reason is, that a LaTeX formula can contain the characters "<" and "&" which
have a special meaning in SGML.

This little package defines four control sequences to circumvent the
restriction: 

\lt   < (less than)
\gt   > (greater than)
\amp  \& (ampersand sign)
\clmn & (column separator)

\gt is only provided for aesthetical reasons; the asymmetry between \lt 
and > looks ugly to the author of this package. 

The usual catcodes for >, <, and & are assumed while the package is read in.

The following little sed script will make all your TeX formulae SGML #PCDATA

s/</\\lt /g
s/>/\\gt /g
s/\\&/{\\amp}/g
s/&/\\clmn /g

Fine print

Note the spaces inserted after \lt,\gt, and \clmn: They guarantee that the
control words are ended properly. There shouldn't be any spaces eaten up, since
">" and "<" are not intended to be input in text (horizontal) mode. With 
standard TeX fonts they produce surprising results anyway. Leading spaces after
a column separator are ignored by TeX, so no problem here.

Turning the control symbol \& into a control word \amp may cause the loss of
significant spaces, therefore the additional group here. The group should
cause no harm, since \& is alreday of math type "other". It may suppress
a hypothetical ligature or kern between the ampersand sign and a following
character in text mode depending on how many passes TeX needs in order to
typeset the paragraph. The standard TeX fonts don't contain such ligatures
or kerns.

J"org Knappen, Barbarossaring 43, D-55118 Mainz, Allemagne
Author of the Book: Schnell ans Ziel mit LaTeX2e, Oldenbourg-Verlag
M"unchen, 1997, ISBN 3-486-24199-0.
% /sgmlcmpt.sty