summaryrefslogtreecommitdiff
path: root/macros/optex/demo
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-04-27 03:00:54 +0000
committerNorbert Preining <norbert@preining.info>2021-04-27 03:00:54 +0000
commit95b070aee1a6351879af117f723c84d50b48338d (patch)
tree214e27cd933a5d3216ef0d0db495cbca43415e3c /macros/optex/demo
parent03117c94362b2fed2fd4aabe50f3106fbf1e0a70 (diff)
CTAN sync 202104270300
Diffstat (limited to 'macros/optex/demo')
-rw-r--r--macros/optex/demo/op-mathalign.tex367
-rw-r--r--macros/optex/demo/op-slides.tex31
2 files changed, 383 insertions, 15 deletions
diff --git a/macros/optex/demo/op-mathalign.tex b/macros/optex/demo/op-mathalign.tex
new file mode 100644
index 0000000000..b2524ee80d
--- /dev/null
+++ b/macros/optex/demo/op-mathalign.tex
@@ -0,0 +1,367 @@
+%% This is part of the OpTeX project, see http://petr.olsak.net/optex
+
+% Math alignment examples inspired by https://www.ntg.nl/maps/34/06.pdf
+
+\fontfam[newcm]
+\margins/1 a4 (2,2,2,2)cm
+\hyperlinks\Blue\Blue
+
+\refdecl{
+ \def\Xpos#1#2#3{\sxdef{pos:#1}{{#2}{#3}\_currpage}}
+}
+\def\setpos[#1]{\openref\pdfsavepos
+ \_ewref\Xpos{{#1}\unexpanded{{\the\pdflastxpos}{\the\pdflastypos}}}}
+
+\def\posx [#1]{\_ea \posi \romannumeral-`\.\trycs{pos:#1}{{0}{0}{0}{0}}sp}
+\def\posy [#1]{\_ea \posii \romannumeral-`\.\trycs{pos:#1}{{0}{0}{0}{0}}sp}
+\def\pospg[#1]{\_ea \posiii \romannumeral-`\.\trycs{pos:#1}{{0}{0}{0}{0}}}
+
+\def\posi #1#2#3#4{#1}
+\def\posii #1#2#3#4{#2}
+\def\posiii #1#2#3#4{#3}
+
+\newcount\tomarginno
+\def\toright#1{\_incr\tomarginno {\setpos[tr:\the\tomarginno]%
+ \rlap{\kern-\posx[tr:\the\tomarginno]\kern\hoffset\kern\hsize\llap{#1}}}}
+\def\toleft#1{\_incr\tomarginno {\setpos[tr:\the\tomarginno]%
+ \rlap{\kern-\posx[tr:\the\tomarginno]\kern\hoffset\rlap{#1}}}}
+
+\def\eqm{\toright\eqmark}
+
+\def\\{\begingroup
+ \_setverb \obeylines \scanlatex
+}
+\def\scanlatex#1//{\tt #1\endgroup \scanoptex}
+\long\def\scanoptex#1$${\begingroup
+ \_setverb \obeylines \scanoptexA
+}
+\ea\def\ea\scanoptexA\ea#\ea1\detokenize{$$}{\bigskip \tt
+ \detokenize{$$}#1\detokenize{$$}\endgroup
+ $$\catcode`\^^M=9 \scantextokens{#1}$$
+ \bigskip
+}
+
+\tit Math alignment examples
+
+The document \url{https://www.ntg.nl/maps/34/06.pdf} shows examples how to
+do special math alignments in display mode in ConTeXt (and in \LaTeX/ for
+comparison). We present the same examples here. They are created in
+\OpTeX/ and the \LaTeX/ source is shown for comparison.
+
+Note that several examples here use the macro \code{\\eqm} for placing
+an equation mark. The macro is defined~by
+
+\begtt
+\def\eqm{\toright\eqmark}
+\endtt
+%
+and the \code{\\toright} macro is defined in
+\ulink[http://petr.olsak.net/optex/optex-tricks.html#torighteq]{\OpTeX/ trick 0028}
+which is based on
+\ulink[http://petr.olsak.net/optex/optex-tricks.html#setpos]{\OpTeX/ trick 0020}.
+I.e. the following macros are used here:
+
+\begtt
+\refdecl{
+ \def\Xpos#1#2#3{\sxdef{pos:#1}{{#2}{#3}\_currpage}}
+}
+\def\setpos[#1]{\openref\pdfsavepos
+ \_ewref\Xpos{{#1}\unexpanded{{\the\pdflastxpos}{\the\pdflastypos}}}}
+
+\def\posx [#1]{\_ea \posi \romannumeral-`\.\trycs{pos:#1}{{0}{0}{0}{0}}sp}
+\def\posy [#1]{\_ea \posii \romannumeral-`\.\trycs{pos:#1}{{0}{0}{0}{0}}sp}
+\def\pospg[#1]{\_ea \posiii \romannumeral-`\.\trycs{pos:#1}{{0}{0}{0}{0}}}
+
+\def\posi #1#2#3#4{#1}
+\def\posii #1#2#3#4{#2}
+\def\posiii #1#2#3#4{#3}
+
+\newcount\tomarginno
+\def\toright#1{\_incr\tomarginno {\setpos[tr:\the\tomarginno]%
+ \rlap{\kern-\posx[tr:\the\tomarginno]\kern\hoffset\kern\hsize\llap{#1}}}}
+\def\toleft#1{\_incr\tomarginno {\setpos[tr:\the\tomarginno]%
+ \rlap{\kern-\posx[tr:\the\tomarginno]\kern\hoffset\rlap{#1}}}}
+\endtt
+%
+and we have to run \TeX/ twice.
+
+\notoc\nonum\sec Contents
+
+\centerline{\vbox{\hsize=.5\hsize
+\maketoc
+}}
+
+\vfil\break
+
+\let\_firstnoindent=\relax
+\mathsboff \catcode`\_=12 \everytable{\catcode`\_=11}
+
+\sec Gather
+
+\\
+\begin{gather}
+ v = u + at, \\
+ d = ut + \frac12 at^2.
+\end{gather}
+//
+
+$$
+ \displaylines{
+ v = u + at, \eqm \cr
+ d = ut + {1\over2} at^2. \eqm
+ }
+$$
+
+\sec Left gather
+
+\\
+\begin{align}
+ & v = u + at, \\
+ & d = ut + \frac12 at^2.
+\end{align}
+//
+
+$$
+ \eqalignno{
+ & v = u + at, & \eqmark \cr
+ & d = ut + {1\over2} at^2. & \eqmark
+ }
+$$
+
+\sec Right gather
+
+\\
+\begin{align}
+ v = u + at , & \\
+ d = ut + \frac12 atˆ2. &
+\end{align}
+//
+
+$$
+ \eqalignno{
+ v = u + at, && \eqmark \cr
+ d = ut + {1\over2} at^2. && \eqmark
+ }
+$$
+
+\sec Align
+
+\\
+\begin{align}
+ v &= u + at, \\
+ d &= ut + \frac12 at^2.
+\end{align}
+//
+
+$$
+ \eqalignno{
+ v &= u + at, & \eqmark \cr
+ d &= ut + {1\over2} at^2. & \eqmark
+ }
+$$
+
+\sec Split
+
+\\
+\begin{equation} \begin{split}
+ (x+1)^8 ={} & x^8 + 8 x^7 + 28 x^6 + 56 x^5 + 70 x^4 \\
+ & + 56 x^3 + 28 x^2 + 8 x + 1.
+\end{split} \end{equation}
+//
+
+$$
+ \eqalign{
+ (x+1)^8 = {}& x^8 + 8 x^7 + 28 x^6 + 56 x^5 + 70 x^4 \cr
+ & + 56 x^3 + 28 x^2 + 8 x + 1.
+ } \eqmark
+$$
+
+\sec Alignat
+
+\\
+\begin{alignat}{2}
+ \nabla\cdot \mathbf E &= \frac{\rho}{\varepsilon_0}, \qquad
+& \nabla\times \mathbf E &= -\frac{\partial \mathbf B}{\partial t},\\
+ \nabla\cdot \mathbf B &= 0,
+& \nabla\times \mathbf B &= \mu_0{\mathbf j}+\varepsilon_0\mu_0
+ \frac{\partial \mathbf E}{\partial t}.
+\end{alignat}
+//
+
+$$
+ \eqalign{
+ \nabla\cdot {\bf E} &= {\rho\over\varepsilon_0}, \qquad
+ && \nabla\times {\bf E} &= -{\partial {\bf B}\over\partial t}, \eqm\cr
+ \nabla\cdot {\bf B} &= 0,
+ && \nabla\times {\bf B} &= \mu_0{\bf j}+\varepsilon_0\mu_0
+ {\partial {\bf E}\over \partial t}. \eqm
+ }
+$$
+
+\sec Flalign
+
+\\
+\begin{flalign*}
+ \nabla\cdot \mathbf E &= \frac{\rho}{\varepsilon_0},
+& \nabla\times \mathbf E &= -\frac{\partial \mathbf B}{\partial t}.\\
+ \nabla\cdot \mathbf B &= 0,
+& \nabla\times \mathbf B &= \mu_0{\mathbf j}+\varepsilon_0\mu_0
+ \frac{\partial \mathbf E}{\partial t}.
+\end{flalign*}
+//
+
+$$
+ \eqspace=10em
+ \eqalign{
+ \nabla\cdot {\bf E} &= {\rho\over\varepsilon_0}, \qquad
+ && \nabla\times {\bf E} &= -{\partial {\bf B}\over\partial t}, \cr
+ \nabla\cdot {\bf B} &= 0,
+ && \nabla\times {\bf B} &= \mu_0{\bf j}+\varepsilon_0\mu_0
+ {\partial {\bf E}\over \partial t}.
+ }
+$$
+
+\sec Intertext
+
+\\
+\begin{align*}
+ \cos 2\theta &= \cos^2 \theta + \sin^2 \theta \\
+ \intertext{replace $\sin^2 \theta$ by $1 - \cos^2 \theta$}
+ &= 2\cos^2 \theta - 1
+\end{align*}
+//
+
+$$
+ \eqalignno{
+ \cos 2\theta &= \cos^2 \theta + \sin^2 \theta \cr
+ \noalign{\hbox{replace $\sin^2 \theta$ by $1 - \cos^2 \theta$}}
+ &= 2\cos^2 \theta - 1
+ }
+$$
+
+\sec Linear equations
+
+\\
+\begin{alignat}{5}
+ x_1 & {} + {}& x_2 &{} + {}& 6x_3 &{} = {}& 170, \\
+ 3x_1 & {} - {}& 110x_2 &{} - {}& x_3 &{} = {}& 4, \\
+ 14x_1 & {} + {}& 13x_2 &{} + {}& 10x_3 &{} = {}& 25.
+\end{alignat}
+//
+
+$$
+ \thistable{\tablinespace=0pt \tabiteml={${}}\tabitemr={{}$}
+ \tabstrut={\lower1.5ex\vbox to3.5ex{}}}
+ \table{3{rc}r}{
+ x_1 &+& x_2 &+& 6x_3 &=& 170, \eqm \cr
+ 3x_1 &-& 110x_2 &-& x_3 &=& 4, \eqm \cr
+ 14x_1 &+& 13x_2 &+& 10x_3 &=& 25. \eqm
+ }
+$$
+
+\sec Matrix and Arrays
+
+\\
+\begin{equation*}
+\setlength{\arraycolsep}{1em}
+ \begin{array}{ccc}
+ A & B & C \\
+ AA & BB & CC \\
+ AAA & BBB & CCC
+ \end{array}
+\end{equation*}
+//
+
+$$
+ \matrix{
+ A & B & C \cr
+ AA & BB & CC \cr
+ AAA & BBB & CCC
+ }
+$$
+
+\\
+\begin{equation*}
+\setlength{\arraycolsep}{1em}
+ \begin{array}{lcr}
+ A & B & C \\
+ AA & BB & CC \\
+ AAA & BBB & CCC
+ \end{array}
+\end{equation*}
+//
+
+$$
+ \thistable{\tabstrut{}\tabiteml={\kern.5em${}}\tabitemr={{}$\kern.5em}}
+ \table{lcr}{
+ A & B & C \cr
+ AA & BB & CC \cr
+ AAA & BBB & CCC
+ }
+$$
+
+\sec Pmatrix
+
+\\
+\begin{equation*}
+ A = \begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix}
+\end{equation*}
+//
+
+$$
+ \pmatrix {1\cr 2\cr 3}
+$$
+
+\sec Delarray package
+
+\\
+\begin{equation*}
+ \begin{array}[b]({c}) 1 \\ 2 \\ 3 \end{array}
+ \begin{array}[c]({c}) 1 \\ 2 \\ 3 \end{array}
+ \begin{array}[t]({c}) 1 \\ 2 \\ 3 \end{array}
+\end{equation*}
+//
+
+$$
+ \def\mybox#1{\hbox{$\displaystyle{#1}$}}
+ \raise3ex\mybox{\pmatrix {1\cr 2\cr 3}}
+ \pmatrix {1\cr 2\cr 3}
+ \lower3ex\mybox{\pmatrix {1\cr 2\cr 3}}
+$$
+
+\sec Cases
+
+\\
+\begin{equation*}
+ |x| =
+ \begin{cases}
+ x, & \text{if $x \ge 0$;} \\
+ -x, & \text{otherwise.}
+ \end{cases}
+\end{equation*}
+//
+
+$$
+ |x| = \cases { x & if $x \ge 0$; \cr
+ -x & otherwise }
+$$
+
+\\
+\begin{equation*}
+ f(x) =
+ \begin{dcases}
+ \int_0ˆx g(y)\,dy, & \text{if $x \ge 0$;} \\
+ \int_{-x}ˆ0 g(y)\,dy, & \text{otherwise.}
+ \end{dcases}
+\end{equation*}
+//
+
+$$
+ \let\ds=\displaystyle
+ f(x) = \cases { \ds \int_0^x g(y)\,dy, & if $x \ge 0$; \cr \noalign{\medskip}
+ \ds \int_{-x}^0 g(y)\,dy, & otherwise. }
+$$
+
+
+
+\end
diff --git a/macros/optex/demo/op-slides.tex b/macros/optex/demo/op-slides.tex
index 50bcdaffa6..d1424b0d91 100644
--- a/macros/optex/demo/op-slides.tex
+++ b/macros/optex/demo/op-slides.tex
@@ -151,22 +151,22 @@ The previous page was created by:
\sec Notes to `\slideshow`
-* When `\slideshow` is active then you cannot reference sections by
- hyperlinked `\ref`. Only `\pgref` works (and goes to the last layer
- of the referenced page).
-* If the text overfull the page (slide) then it follows to the next page without
+* When `\slideshow` is active then references created by `\ref`
+ point to the first uncovering \"virtual" page where the destination is
+ and references created by `\pgref` point to the last \"virtual" page.
+* If the text overfulls the page (slide) then it follows to the next page without
saying explicitly `\pg;`. But `\slideshow` cannot work in this case.\pg+
* If `\slideshow` then each part of page between two `\pg`'s or between
`\slideshow` and the first `\pg` is processed in a local group.
* If not `\slideshow` then the document is not separated to groups.
- This can lead to different results. So, you can put `\slideopen` command
+ This can create different results. So, you can put `\slideopen` command
instead of `\slideshow`. Then local groups are opened exactly as when
`\slideshow` is used but `\slideshow` is not activated. Example:
\begtt
\slides
\def\foo...{...} % global definitions.
-%\slideshow % printing version, no slide show.
+%\slideshow
\slideopen % opens group for first page.
... first page
\pg; % closes group and opens group for second page.
@@ -216,7 +216,7 @@ The previous page was created by:
* `\putpic <right> <up> <width> <height> {<image-file>}`
puts the image with desired <width> and <height> at the position like
- `\puttext` puts the text.
+ `\puttext` puts the text.\pg+
\putpic .8\hsize 20mm 30mm \nospec {op-ring.png}
* The ring above is the result of
@@ -249,10 +249,11 @@ If you really need something unsupported by `\pg+` then you can use
\endlayers
\endtt
-* The <layered text> should include conditions like
- `\ifnum\layernum...` or `\ifcase\layernum`.
- It is printed <number> times to more slide pages (layers) with the same
- surrounding text. See next page...
+* The `\layers` opens <number> following pages with the same
+ surrounding text. The counter `\layernum` is incemented from one to
+ <number> . The <layered text> should use `\layernum` including
+ conditions like `\ifnum\layernum` or `\ifcase\layernum`.
+ See next page...
\pg; %------------------------------------------------------------------
@@ -265,10 +266,10 @@ partially show):
\def\use#1#2{\ifnum\layernum#1\relax#2\fi}
\def\pshow#1{\use{=#1}\Red \use{<#1}\Transparent \ignorespaces}
\endtt
-`\use{=3}{do something}` does something only if `\layernum=3`.
+`\use{=<num>}{<something>}` does <something> only if `\layernum=<num>`.\kern-1em
The `{\pshow<num> <text>}` prints <text> in Red when current layer is equal
-to <num> or it prints <text> normally when current layers is greater than <num>.
+to <num> or it prints <text> normally when the current layer is greater than <num>.
The transparent (invisible) text is used in other cases.
The following dance:
@@ -288,7 +289,7 @@ was generated by
\pg+
* The <layered text> is treated as a macro parameter. So, you cannot use verbatim
nor `\sec` titles here. Maximal one `\layers` environment can be per one
- page (terminated by `\pg+` or `\pg;` or `\pg.`
+ page (terminated by `\pg+` or `\pg;` or `\pg.`).
\pg; %------------------------------------------------------------------
@@ -298,7 +299,7 @@ The \LaTeX{} package {\bf\Blue Beamer} gives much more features and many themes
are prepared for Beamer, {\bf\Red but}
\pg+
* the user of Beamer is forced to {\em program} his/her document using
- dozens of \code{\\begin{foo}} and \code{\\end{foo}} and many another
+ dozens of \code{\\begin{foo}} and \code{\\end{foo}} and many other
programming constructions,\pg+
* plain \TeX{} gives you a possibility to simply
{\em write} your document with minimal markup. The result is more compact.