Fix bugs reported by Fengjing Xiao
[clqr.git] / clqr.macros.tex
blob475c53601995d61d7c0611defce872cf0c760a02
1 % Copyright (C) 2008, 2009, 2010, 2011, 2014, 2018 Bert Burgemeister
3 % Permission is granted to copy, distribute and/or modify this
4 % document under the terms of the GNU Free Documentation License,
5 % Version 1.2; with no Invariant Sections, no Front-Cover Texts and
6 % no Back-Cover Texts. For details see file COPYING.
8 \newlength{\LISTlinewidth}
9 \newenvironment{LIST}[1]%
11 \LISTlinewidth=\linewidth%
12 \begin{flushleft}%
13 \begin{list}{}%
14 {\setlength{\itemindent}{-#1}\setlength{\leftmargin}{#1}}%
15 %\parskip0pt\itemsep0pt%
17 {\end{list}%
18 \end{flushleft}%
21 %\renewcommand{\topfraction}{1}
22 \renewcommand{\bottomfraction}{1}
23 %\renewcommand*{\figureformat}{}
24 %\renewcommand*{\captionformat}{}
25 \renewcommand{\thefootnote}{\fnsymbol{footnote}}
27 \setlength{\parfillskip}{5cm plus1cm minus3cm}
28 \setlength{\arraycolsep}{0pt}
31 \def\startexplanation{$\triangleright$\hskip1.4ex}
32 \newlength{\ITwidth}
33 \newlength{\ITrest}
34 \newlength{\ITtab}\ITtab=3em
36 \def\IT#1 #2 {%
37 \settowidth{\ITwidth}{#1\unskip\hskip1em\hskip\ITtab}%
38 \ITrest=\LISTlinewidth\advance\ITrest by -\ITwidth%
39 \loop\ifdim\ITrest > \ITtab%
40 \advance\ITrest by -\ITtab%
41 \repeat%
43 \settowidth{\ITwidth}{%
44 #1\unskip\hskip1em\hskip\ITrest%
45 \startexplanation#2%
47 \item{}%
48 \ifdim\ITwidth < \LISTlinewidth% Entry fits into a single line
49 #1\unskip\hskip1em\hskip\ITrest%
50 \startexplanation#2%
51 \else%
52 #1%
53 \unskip\penalty-10000%
54 \parbox[t]{\linewidth}{\startexplanation#2}%
55 \fi%
58 % Emphasize
59 \newcommand{\EM}[1]{%
60 \text{{\fontfamily{cmr}\fontseries{b}\fontshape{n}\selectfont#1}}}
63 % Literal Text
64 \newcommand{\LIT}[1]{\text{{\fontfamily{cmtt}\selectfont#1}}}
66 % Variable Text
67 \newcommand{\VAR}[1]{\text{{\fontfamily{cmr}\fontshape{it}\selectfont#1\/}}}
69 % Not Evaluated
70 \newcommand{\NEV}[1]{\text{{$\widehat{#1}$}}}
72 % Subjected to Destruction
73 \newcommand{\DES}[1]{\text{{$\widetilde{#1}$}}}
75 % Default Value
76 \newcommand{\DF}[1]{%
77 \text{\textsubscript{%
78 \setlength{\fboxsep}{.5pt}\setlength{\fboxrule}{.2bp}\fbox{#1}}}}
80 % Optional Part, [], two sizes
81 \newcommand{\OP}[1]{{\text{$\big[$}{#1}\text{$\big]$}}}
82 \newcommand{\Op}[1]{{\text{$[$}{#1}\text{$]$}}}
84 % Or, |
85 \newcommand{\XOR}{\hspace{1pt}\text{\rule[-.9ex]{.25pt}{3ex}}\hspace{1pt}}
86 %\newcommand{\XOR}{\text{$\mid$}\hspace{0pt}}
88 % Optional Parts, *
89 \newcommand{\OPn}[1]{{{#1}\text{${}^{*}$}}}
91 % Required Parts, +
92 \newcommand{\RP}[1]{{{#1}\text{${}^{+}$}}}
94 % Implicit PROGN, P*
95 \newcommand{\PROGN}[1]{%
96 {{#1}\text{${}^{%
97 {\raisebox{.5ex}[0pt][0pt]{\tiny\sffamily\mdseries\makebox[0pt][l]{\hspace{-.6ex}P}}*}}$}}}
99 % Group of Objects {}, three sizes
100 \newcommand{\GOO}[1]{{\text{$\Big\{$}{#1}\text{$\Big\}$}}}
101 \newcommand{\GOo}[1]{{\text{$\big\{$}{#1}\text{$\big\}$}}}
102 \newcommand{\Goo}[1]{{\text{$\{$}{#1}\text{$\}$}}}
103 % Optional Group of Objects, {}*, three sizes
104 \newcommand{\GOOs}[1]{{$\Big\{${#1}$\Big\}^{\!\!*}$}} % this one can
105 % have line breaks
106 \newcommand{\GOos}[1]{\text{{$\big\{${#1}$\big\}^{\!\!*}$}}}
107 \newcommand{\Goos}[1]{\text{{$\{${#1}$\}^{\!*}$}}}
108 % Required Group of Objects, {}+, three sizes
109 \newcommand{\GOOp}[1]{{\text{$\Big\{$}{#1}\text{$\Big\}^{\!\!+}$}}}
110 \newcommand{\GOop}[1]{{\text{$\big\{$}{#1}\text{$\big\}^{\!\!+}$}}}
111 \newcommand{\Goop}[1]{{\text{$\{$}{#1}\text{$\}^{\!+}$}}}
113 % Vertically Arranged Group of Alternatives, {
114 % usage: \xorGOO{line1\\ line2...}{closing delimiter}
115 \newcommand{\xorGOO}[2]{\text{\(%
116 \left\{\!%
117 \begin{array}{l}%
119 \end{array}\!%
120 \right#2%
121 \)}}
123 % Vertically Arranged Group of Optional Objects, {|
124 % usage: \orGOO{line1\\line2}{closing delimiter}
125 \newcommand{\orGOO}[2]{\text{\(%
126 \left\{\!\left|%
127 \begin{array}{l}%
129 \end{array}\!%
130 \right.\right#2%
131 \)}}
133 % Vertically Arranged Group of Objects, No Opening {
134 % usage: \arrGOO{line1\\line2}{closing delimiter}
135 \newcommand{\arrGOO}[2]{\text{\(\!%
136 \left.%
137 \begin{array}{l}%
139 \end{array}\!%
140 \right#2%
141 \)}}
144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 % All sorts of tags attached to lisp keywords
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 \newcommand{\MARKNAME}[2]{%
151 \text{\textsubscript{\sffamily\slshape\mdseries\lowercase{#2}}%
152 {\sffamily\bfseries\selectfont\lowercase{#1}}}}
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 % Generic Keyword, Lowercase
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 \newcommand{\kwd}[1]{\text{{\sffamily\bfseries\selectfont%
158 \lowercase{#1}}}}
160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 % Generic Keyword, Uppercase
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 \newcommand{\KWD}[1]{\text{{\sffamily\bfseries\selectfont%
164 \uppercase{#1}}}}
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
167 % Macro
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
169 \newcommand{\MC}[1]{%
170 \MARKNAME{#1}{m}}
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 % Special Operator
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 \newcommand{\SO}[1]{%
176 \MARKNAME{#1}{s}}
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 % Function
180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 \newcommand{\FU}[1]{%
182 \MARKNAME{#1}{f\/}}
184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
185 % Generic Function
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 \newcommand{\GFU}[1]{%
188 \MARKNAME{#1}{g}}
190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 % Variable
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
193 \newcommand{\V}[1]{%
194 \MARKNAME{#1}{v}}
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
197 % Constant
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 \newcommand{\CNS}[1]{%
200 \MARKNAME{#1}{c}}
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 % Loop Keyword
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 \newcommand{\LKWD}[1]{\text{{\sffamily\bfseries\selectfont\lowercase{#1}}}}
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 % Return Values, First, nth, Second, Third
209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 \renewcommand{\ULthickness}{.2pt}
211 \newcommand{\retval}[1]{\uline{#1}}
212 \newcommand{\retvaln}[2]{{%
213 {\raisebox{-1.7ex}[0pt][1.4ex]{\tiny\sffamily\upshape\mdseries\makebox[0pt][l]{\hspace{-.1em}#1}}\uline{#2}}}}
214 \newcommand{\retvalii}[1]{\retvaln{2}{#1}}
215 \newcommand{\retvaliii}[1]{\retvaln{3}{#1}}
217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
218 % T and NIL
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 \newcommand{\T}{\text{\ttfamily T}}
221 \newcommand{\NIL}{\text{\ttfamily NIL}}
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
224 % ~ (slightly lowered)
225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 \newcommand{\TLD}{{\protect\raisebox{-.8ex}{\textasciitilde}}}
228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
229 % * (lowered version)
230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 \newcommand{\A}{\textasteriskcentered}
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
234 % Starred commands send their argument into index:
235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
236 \WithSuffix\newcommand\kwd*[1]{\kwd{#1}\uppercase{\index{#1}}}
237 \WithSuffix\newcommand\KWD*[1]{\KWD{#1}\uppercase{\index{#1}}}
238 \WithSuffix\newcommand\MC*[1]{\MC{#1}\uppercase{\index{#1}}}
239 \WithSuffix\newcommand\SO*[1]{\SO{#1}\uppercase{\index{#1}}}
240 \WithSuffix\newcommand\FU*[1]{\FU{#1}\uppercase{\index{#1}}}
241 \WithSuffix\newcommand\GFU*[1]{\GFU{#1}\uppercase{\index{#1}}}
242 \WithSuffix\newcommand\V*[1]{\V{#1}\uppercase{\index{#1}}}
243 \WithSuffix\newcommand\CNS*[1]{\CNS{#1}\uppercase{\index{#1}}}
244 \WithSuffix\newcommand\LKWD*[1]{\LKWD{#1}\uppercase{\index{#1}}}
246 \hyphenation{white-space pa-ra-me-ters}
248 %%% Local Variables:
249 %%% mode: latex
250 %%% TeX-master: "clqr"
251 %%% End: