| 1 |
\documentclass{article} |
| 2 |
|
| 3 |
\def\id{my previous definition} |
| 4 |
|
| 5 |
\usepackage{pseudo} |
| 6 |
|
| 7 |
\usepackage{tcolorbox} |
| 8 |
\tcbuselibrary{skins,theorems} |
| 9 |
|
| 10 |
\usepackage{noindentafter} |
| 11 |
\NoIndentAfterEnv{pseudo} |
| 12 |
\NoIndentAfterEnv{pseudo*} |
| 13 |
|
| 14 |
\title{Tests for the \textsf{pseudo} package} |
| 15 |
\author{Magnus Lie Hetland} |
| 16 |
|
| 17 |
\begin{document} |
| 18 |
\maketitle |
| 19 |
|
| 20 |
\noindent |
| 21 |
This document is an attempt to use the features of the \textsf{pseudo} package |
| 22 |
without any other dependencies (as opposed to the \textsf{pseudo} |
| 23 |
documentation), e.g., to determine whether it's usable with an older \TeX\ |
| 24 |
distribution. |
| 25 |
|
| 26 |
\section*{Fonts and styling} |
| 27 |
|
| 28 |
The previous definition of \verb|\id| is: \id\\ |
| 29 |
\let\id\pseudoid |
| 30 |
|
| 31 |
\bigskip |
| 32 |
\noindent |
| 33 |
\begin{tabular}{@{}ll@{}} |
| 34 |
\verb|\cmd| & \verb|\pseudocmd|\\ |
| 35 |
\kw{while} & \pseudokw{while}\\ |
| 36 |
\cn{false} & \pseudocn{false}\\ |
| 37 |
\id{rank} & \pseudoid{rank}\\ |
| 38 |
\st{Hello!} & \pseudost{Hello!}\\ |
| 39 |
\pr{Euclid}(a b) & \pseudopr{Euclid}(a b)\\ |
| 40 |
\fn{length}(A) & \pseudofn{length}(A)\\ |
| 41 |
\fn{length}[A] & \pseudofn{length}[A]\\ |
| 42 |
\ct{Important!} & \pseudoct{Important!}\\ |
| 43 |
\end{tabular} |
| 44 |
|
| 45 |
{\pseudoset{ |
| 46 |
kwfont=KW:~, |
| 47 |
cnfont=CN:~, |
| 48 |
idfont=ID:~, |
| 49 |
stfont=ST:~, |
| 50 |
st-left=[, |
| 51 |
st-right=], |
| 52 |
prfont=PR:~, |
| 53 |
fnfont=FN:~, |
| 54 |
ctfont=CT:~, |
| 55 |
ct-left=[, |
| 56 |
ct-right=], |
| 57 |
} |
| 58 |
\bigskip |
| 59 |
\noindent |
| 60 |
\begin{tabular}{@{}ll@{}} |
| 61 |
\verb|\cmd| & \verb|\pseudocmd|\\ |
| 62 |
\kw{while} & \pseudokw{while}\\ |
| 63 |
\cn{false} & \pseudocn{false}\\ |
| 64 |
\id{rank} & \pseudoid{rank}\\ |
| 65 |
\st{Hello!} & \pseudost{Hello!}\\ |
| 66 |
\pr{Euclid}(a b) & \pseudopr{Euclid}(a b)\\ |
| 67 |
\fn{length}(A) & \pseudofn{length}(A)\\ |
| 68 |
\fn{length}[A] & \pseudofn{length}[A]\\ |
| 69 |
\ct{Important!} & \pseudoct{Important!}\\ |
| 70 |
\end{tabular}} |
| 71 |
|
| 72 |
% The one on the line is ignored: |
| 73 |
\begin{pseudo}[hpad, dim-color=red, kw][dim-color=blue, dim] |
| 74 |
foo \\[hl] |
| 75 |
bar |
| 76 |
\end{pseudo} |
| 77 |
|
| 78 |
Should be \verb|\fn{test}[A]| followed by \verb|(B)| in normalfont: |
| 79 |
\fn{test}[A](B) |
| 80 |
|
| 81 |
\bigskip |
| 82 |
\noindent |
| 83 |
Should be \verb|\fn{test}(A)| followed by \verb|[B]| in normalfont: |
| 84 |
\fn{test}(A)[B] |
| 85 |
|
| 86 |
\section*{Declarations and definitions} |
| 87 |
|
| 88 |
\DeclarePseudoComment \Imp {Important!} |
| 89 |
\DeclarePseudoConstant \False {false} |
| 90 |
\DeclarePseudoFunction \Ln {length} |
| 91 |
\DeclarePseudoIdentifier \Rank {rank} |
| 92 |
\DeclarePseudoKeyword \While {while} |
| 93 |
\DeclarePseudoNormal \Error {halt with an error message} |
| 94 |
\DeclarePseudoProcedure \Euclid {Euclid} |
| 95 |
\DeclarePseudoString \Hello {Hello!} |
| 96 |
|
| 97 |
\begin{pseudo*} |
| 98 |
$x = y$ \qquad \Imp \\ |
| 99 |
\False \\ |
| 100 |
\Ln(A) or \Ln[A] \\ |
| 101 |
\Rank \\ |
| 102 |
\While \\ |
| 103 |
\Error \\ |
| 104 |
\Euclid(a, b) \\ |
| 105 |
\Hello |
| 106 |
\end{pseudo*} |
| 107 |
|
| 108 |
\pseudodefinestyle{mystyle}{ |
| 109 |
font = \Large |
| 110 |
} |
| 111 |
|
| 112 |
\begin{pseudo*}[mystyle] |
| 113 |
Hello, world! |
| 114 |
\end{pseudo*} |
| 115 |
|
| 116 |
\section*{Notation} |
| 117 |
|
| 118 |
$A[1\..n] \== B[2\..n+1]$ \\ |
| 119 |
$A[1\dts n] \eqs B[2\dts n+1]$ \\ |
| 120 |
|
| 121 |
\noindent |
| 122 |
$\id{foo-bar:baz}$ |
| 123 |
|
| 124 |
\noindent |
| 125 |
{\pseudoset{eqs-pad=10mu, eqs-scale=2, eqs-sep=5mu}$x\==y$} |
| 126 |
|
| 127 |
\begin{pseudo*}[kw] |
| 128 |
keyword \tn{normal} keyword \nf normal |
| 129 |
\end{pseudo*} |
| 130 |
|
| 131 |
\section*{Numbering and indentation} |
| 132 |
|
| 133 |
\begin{pseudo}[start=2, label=(\Roman*), label-align=l, ref=\Roman*] |
| 134 |
one \\ |
| 135 |
two \label{linetwo} \\* |
| 136 |
? & three \\ |
| 137 |
\end{pseudo} |
| 138 |
|
| 139 |
\begin{pseudo}* |
| 140 |
\hd{Header}(\id{args}) \\ |
| 141 |
first line |
| 142 |
\end{pseudo} |
| 143 |
|
| 144 |
Reference to line~\ref{linetwo}. |
| 145 |
|
| 146 |
\begin{pseudo}[hpad=1cm, hsep=.1cm, indent-length=2cm, indent-level=1] |
| 147 |
A \\+ |
| 148 |
B \\++ |
| 149 |
C \\- |
| 150 |
D \\--- |
| 151 |
E |
| 152 |
\end{pseudo} |
| 153 |
|
| 154 |
\begin{pseudo*}[indent-text={otherwise\ }] |
| 155 |
if this \\+ |
| 156 |
then that \\- |
| 157 |
otherwise something else |
| 158 |
\end{pseudo*} |
| 159 |
|
| 160 |
\section*{Layout} |
| 161 |
|
| 162 |
Here's a compact piece of pseudocode: |
| 163 |
\begin{pseudo*}[kw, compact] |
| 164 |
print \st{42} |
| 165 |
\end{pseudo*} |
| 166 |
|
| 167 |
Automatically compact: |
| 168 |
\fbox{\begin{pseudo*} |
| 169 |
In a box. |
| 170 |
\end{pseudo*}} |
| 171 |
|
| 172 |
\begin{pseudo}[left-margin=\parindent] |
| 173 |
indented |
| 174 |
\end{pseudo} |
| 175 |
|
| 176 |
\begin{pseudo}[line-height=2] |
| 177 |
lines \\ |
| 178 |
far \\ |
| 179 |
apart |
| 180 |
\end{pseudo} |
| 181 |
|
| 182 |
\begin{pseudo}[topsep=1cm, partopsep=1cm] |
| 183 |
custom topsep and partopsep |
| 184 |
\end{pseudo} |
| 185 |
|
| 186 |
Adjustments based on depth: |
| 187 |
|
| 188 |
\bigskip |
| 189 |
|
| 190 |
{ |
| 191 |
\pseudoset{hl-warn=false} |
| 192 |
|
| 193 |
\parskip0pt % Default |
| 194 |
\topsep0pt |
| 195 |
\partopsep0pt |
| 196 |
\noindent |
| 197 |
\begin{minipage}[t]{2em} |
| 198 |
. |
| 199 |
|
| 200 |
\begin{pseudo*}[hl] |
| 201 |
(x) \\ |
| 202 |
x \\ |
| 203 |
x \\ |
| 204 |
(x) |
| 205 |
\end{pseudo*}% |
| 206 |
\end{minipage}% |
| 207 |
% |
| 208 |
% |
| 209 |
% |
| 210 |
\begin{minipage}[t]{2em} |
| 211 |
. |
| 212 |
|
| 213 |
\begin{pseudo*}[hl] |
| 214 |
x \\ |
| 215 |
x \\ |
| 216 |
x \\ |
| 217 |
x |
| 218 |
\end{pseudo*}% |
| 219 |
\end{minipage}% |
| 220 |
% |
| 221 |
% |
| 222 |
% |
| 223 |
\begin{minipage}[t]{2em}% |
| 224 |
. |
| 225 |
|
| 226 |
\begin{tabular}[t]{@{}l@{}} |
| 227 |
x \\ |
| 228 |
x \\ |
| 229 |
x \\ |
| 230 |
x |
| 231 |
\end{tabular}% |
| 232 |
\end{minipage} |
| 233 |
% |
| 234 |
% |
| 235 |
% |
| 236 |
\begin{minipage}[t]{2em}% |
| 237 |
. |
| 238 |
|
| 239 |
x |
| 240 |
|
| 241 |
\begin{tabular}[t]{@{}l@{}} |
| 242 |
x \\ |
| 243 |
x |
| 244 |
\end{tabular}% |
| 245 |
|
| 246 |
\prevdepth=.3\baselineskip |
| 247 |
|
| 248 |
x |
| 249 |
\end{minipage}% |
| 250 |
% |
| 251 |
% |
| 252 |
% |
| 253 |
\begin{minipage}[t]{2em} |
| 254 |
. |
| 255 |
|
| 256 |
x |
| 257 |
|
| 258 |
\begin{pseudo*}[hl] |
| 259 |
x \\ |
| 260 |
x |
| 261 |
\end{pseudo*}% |
| 262 |
|
| 263 |
x |
| 264 |
\end{minipage}% |
| 265 |
% |
| 266 |
% |
| 267 |
% |
| 268 |
\begin{minipage}[t]{2em} |
| 269 |
. |
| 270 |
|
| 271 |
g |
| 272 |
|
| 273 |
\begin{pseudo*}[hl] |
| 274 |
x \\ |
| 275 |
x |
| 276 |
\end{pseudo*}% |
| 277 |
|
| 278 |
x |
| 279 |
\end{minipage}% |
| 280 |
% |
| 281 |
% |
| 282 |
% |
| 283 |
\begin{minipage}[t]{2em} |
| 284 |
. |
| 285 |
|
| 286 |
x |
| 287 |
|
| 288 |
\begin{pseudo*}[hl] |
| 289 |
x \\ |
| 290 |
x |
| 291 |
\end{pseudo*}% |
| 292 |
|
| 293 |
A |
| 294 |
\end{minipage}% |
| 295 |
% |
| 296 |
% |
| 297 |
% |
| 298 |
\begin{minipage}[t]{2em} |
| 299 |
. |
| 300 |
|
| 301 |
(x) |
| 302 |
|
| 303 |
\begin{pseudo*}[hl] |
| 304 |
x \\ |
| 305 |
x |
| 306 |
\end{pseudo*}% |
| 307 |
|
| 308 |
(x) |
| 309 |
\end{minipage}% |
| 310 |
% |
| 311 |
% |
| 312 |
% |
| 313 |
\begin{minipage}[t]{2em} |
| 314 |
. |
| 315 |
|
| 316 |
\strut x |
| 317 |
|
| 318 |
\begin{pseudo*}[hl] |
| 319 |
x \\ |
| 320 |
x |
| 321 |
\end{pseudo*}% |
| 322 |
|
| 323 |
\strut x |
| 324 |
\end{minipage}% |
| 325 |
} |
| 326 |
|
| 327 |
\section*{Overlays etc.} |
| 328 |
|
| 329 |
Ignored outside \textsf{beamer}. |
| 330 |
|
| 331 |
\begin{pseudo}[pause, kwfont<3>=\nf, unknown<3>=42] |
| 332 |
foo \\<2> |
| 333 |
% bar \\ <3> % Dosn't work in older xparse versions |
| 334 |
baz |
| 335 |
\end{pseudo} |
| 336 |
|
| 337 |
\clearpage |
| 338 |
|
| 339 |
\section*{Boxes and floats; spacing} |
| 340 |
|
| 341 |
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod |
| 342 |
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. |
| 343 |
|
| 344 |
\begin{tcolorbox}[pseudo/tworuled] |
| 345 |
Test: $f(x)$ |
| 346 |
\end{tcolorbox} |
| 347 |
|
| 348 |
\begin{tcolorbox}[pseudo/tworuled] |
| 349 |
Foobar |
| 350 |
\end{tcolorbox} |
| 351 |
|
| 352 |
\noindent |
| 353 |
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd |
| 354 |
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. |
| 355 |
|
| 356 |
\begin{pseudo} |
| 357 |
foo \\ |
| 358 |
bar \\ |
| 359 |
baz |
| 360 |
\end{pseudo} |
| 361 |
|
| 362 |
\begin{pseudo} |
| 363 |
foo \\ |
| 364 |
bar \\ |
| 365 |
baz |
| 366 |
\end{pseudo} |
| 367 |
|
| 368 |
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod |
| 369 |
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At |
| 370 |
vero eos et accusam et justo duo dolores et ea rebum. |
| 371 |
|
| 372 |
\begin{tcolorbox}[pseudo/filled, float] |
| 373 |
Testing. $x\== y$. |
| 374 |
\end{tcolorbox} |
| 375 |
|
| 376 |
\section*{Extra space} |
| 377 |
|
| 378 |
\begin{pseudo}[indent-mark, extra-space=1.5ex] |
| 379 |
Alpha \\+ |
| 380 |
Beta \\+[1cm] |
| 381 |
Gamma |
| 382 |
\end{pseudo} |
| 383 |
|
| 384 |
|
| 385 |
% Should emit three warnings: |
| 386 |
% \pseudoslash |
| 387 |
% \pseudoslash |
| 388 |
% \pseudoslash |
| 389 |
|
| 390 |
% Should emit three warnings: |
| 391 |
% \pseudoeq |
| 392 |
% \pseudoeq |
| 393 |
% \pseudoeq |
| 394 |
|
| 395 |
|
| 396 |
% Things that could also be tested: |
| 397 |
% begin-tabular |
| 398 |
% bol |
| 399 |
% bol-append |
| 400 |
% bol-prepend |
| 401 |
% eol |
| 402 |
% eol-append |
| 403 |
% eol-prepend |
| 404 |
% preamble |
| 405 |
% prefix |
| 406 |
% pseudoeq |
| 407 |
% RestorePseudoBackslash |
| 408 |
% setup |
| 409 |
% setup-append |
| 410 |
% setup-prepend |
| 411 |
% starred |
| 412 |
|
| 413 |
\end{document} |