| 1 |
\documentclass{article} |
| 2 |
|
| 3 |
\usepackage{program} |
| 4 |
|
| 5 |
\catcode`\!=\active % Make ! active |
| 6 |
\let!=| % Set it to be the same as | |
| 7 |
\let|=\origbar % Restore | to the old value |
| 8 |
\catcode`\!=12 % These two lines make ! active |
| 9 |
\mathcode`\!="8000 % only in maths mode. |
| 10 |
|
| 11 |
\makeatletter |
| 12 |
\def\@svariable{% |
| 13 |
\catcode`\!\active |
| 14 |
\lccode`\~`\!% |
| 15 |
\lowercase{\def~{\endgroup% if we were not in mmode, do italic corr: |
| 16 |
\ifwasinmmode\let\next=\/% was \relax |
| 17 |
\else\let\next=\variablefontend\fi |
| 18 |
\next |
| 19 |
\egroup}% |
| 20 |
\let\@dovar~}% |
| 21 |
\leavevmode\null} |
| 22 |
\makeatother |
| 23 |
|
| 24 |
\begin{document} |
| 25 |
|
| 26 |
This document illustrates how to use the exclamation mark (!), or any other character, instead of vertical bar |
| 27 |
as the variable name delimiter. This may useful of you are typesetting programs which use a lot of vertical bars. |
| 28 |
|
| 29 |
\[ \left|\frac{\partial \varphi (X)}{\partial g}\right| |
| 30 |
= \max_{i\in R(X)} \nabla f_i(X) g^T |
| 31 |
\] |
| 32 |
|
| 33 |
Testing! |
| 34 |
|
| 35 |
\[ !foo_bar! = x + y \] |
| 36 |
|
| 37 |
\[ !foo!_{!bar!} = x + y \] |
| 38 |
|
| 39 |
Note that the $!bar!$ subscript is not at a smaller size. If you want a small |
| 40 |
subscript, write: |
| 41 |
|
| 42 |
\[ !foo!_{\scriptvar!bar!} = x + y \] |
| 43 |
|
| 44 |
\begin{program} |
| 45 |
!choose ! choose X_0 ; |
| 46 |
X := X_0 ; |
| 47 |
\DO \textnormal{determine } |R(X)| |
| 48 |
\textnormal{determine } |G(X)| |
| 49 |
\textnormal{determine } |!foo_bar!(X)| |
| 50 |
\textnormal{determine } |Z*| |
| 51 |
\IF |Z*|=0 \THEN \EXIT \FI |
| 52 |
\textnormal{determine direction of steepest descent } g=-|Z*|/{\parallel |Z*|\parallel} |
| 53 |
\textnormal{determine }\alpha>0,\textnormal{ for which }\varphi(X+\alpha g)\textnormal{ is minimum} |
| 54 |
X := X + \alpha g |
| 55 |
\OD |
| 56 |
\end{program} |
| 57 |
|
| 58 |
\end{document} |