From: Hans Hagen <pragma@wxs.nl>
To: ntg-context@ntg.nl
Subject: Re: Border matrix
Date: Mon, 28 Aug 2017 19:29:29 +0200 [thread overview]
Message-ID: <3c381955-0226-9d95-09f0-4d06afb40cba@wxs.nl> (raw)
In-Reply-To: <CANy7Hna-LNXJadbckPaoXJC6iVQQMxF0StoT+d=BTWjDg5H8vw@mail.gmail.com>
On 8/28/2017 6:33 PM, Fabrice L wrote:
> Hi,
>
> I’have a lot of courses notes in MKII. I’m trying to move to MKIV. I
> have a problem that I’m not able to resolve, to make a border matrix
> with brackets. In MKII, I was using a macro, found somewhere, which
> works great, but no longer works; here is the macro:
>
> % Border matrix: first line and column are label
> \catcode`\@=11\relax
> \newdimen\p@renwd
> \font\tenex=cmex10 \setbox0=\hbox{\tenex B} \p@renwd=\wd0
> \def\bbordermatrix#1{\begingroup \m@th
> \setbox\z@\vbox{\def\cr{\crcr\noalign{\kern2\p@\global\let\cr\endline}}%
> \ialign{$##$\hfil\kern2\p@\kern\p@renwd&\thinspace\hfil$##$\hfil
> &&\quad\hfil$##$\hfil\crcr
> \omit\strut\hfil\crcr\noalign{\kern-\baselineskip}%
> #1\crcr\omit\strut\cr}}%
> \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
> \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
> \setbox\tw@\hbox{$\kern\wd\@ne\kern-\p@renwd\left[\kern-\wd\@ne
> \global\setbox\@ne\vbox{\box\@ne\kern2\p@}%
> \vcenter{\kern-\ht\@ne\unvbox\z@\kern-\baselineskip}\,\right]$}%
> \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
> \catcode`\@=12\relax
Such a plain macro needs to be made bodyfotn size aware and such.
> but MKIV gives me the error:
>
> \bbordermatrix #1->\begingroup \m@th
>
> \setbox \z@ \vbox {\def \cr {\crcr
> \noa...
>
> l.26 i & j & k & l \cr}
>
>
> 16 \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
>
> 17 \catcode`\@=12\relax
>
>
> I look for solutions on the list, but did not find anything.Here is a
> minimal example:
>
> \starttext
> A border matrix:
> \startformula
> \bbordermatrix{
> a & b & c & d \cr
> e & f & G & h \cr
> i & j & k & l \cr}
> \stopformula
> \stoptext
>
> As I have in my notes hundreds of such matrix, it is really difficult to
> change the input format.
>
> Do you know, or can you point me, to a solution ? I’m in a dead end..
> Thanks a lot.
I'll add this:
\unprotect
\unexpanded\def\math_border_matrix#1#2#3% adapted plain
{\begingroup
%
\pushmacro\cr
%
\setbox\scratchbox\hbox\bgroup
\mr B%
\egroup
\scratchdimenone\wd\scratchbox
%
\scratchdimentwo.2\bodyfontsize
%
\mathsurround\zeropoint
%
\setbox\scratchboxone\vbox\bgroup
\def\cr{%
\crcr
\noalign\bgroup
\kern\scratchdimentwo
\global\let\cr\endline
\egroup
}%
\ialign{%
\startimath\alignmark\alignmark\stopimath
\hfil
\kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
\aligntab
\thinspace
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\aligntab
\aligntab
\quad
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\crcr
\omit
\strut
\hfil
\crcr
\noalign{\kern-\baselineskip}%
#3\crcr
\omit
\strut
\cr
}%
\egroup
\setbox\scratchboxtwo\vbox\bgroup
\unvcopy\scratchboxone
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\unhbox\globalscratchbox
\unskip
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\startimath
\kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
\left#1\relax
\kern-\wd\globalscratchbox
\global\setbox\globalscratchbox\vbox\bgroup
\box\globalscratchbox
\kern\scratchdimentwo
\egroup
\vcenter\bgroup
\kern-\ht\globalscratchbox
\unvbox\scratchboxone
\kern-\baselineskip
\egroup
\thinspace
\right#2\relax
\stopimath
\egroup
\null
\thickspace
\vbox\bgroup
\kern\ht\globalscratchbox
\box\scratchboxtwo
\egroup
%
\popmacro\cr
%
\endgroup}
\unexpanded\def\bordermatrix {\math_border_matrix()}
\unexpanded\def\bbordermatrix{\math_border_matrix[]}
\protect
\starttext
A plain border matrix:
\startformula
\bordermatrix{
a & b & c & d \cr
e & f & G & h \cr
i & j & k & l \cr}
\stopformula
\startformula
\bbordermatrix{
a & b & c & d \cr
e & f & G & h \cr
i & j & k & l \cr}
\stopformula
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2017-08-28 17:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 16:33 Fabrice L
2017-08-28 17:29 ` Hans Hagen [this message]
2017-08-28 17:44 ` Fabrice L
[not found] ` <7c38cc04-4408-9799-7a27-fcd1c3a47f6b@wxs.nl>
2018-04-19 20:05 ` Fabrice L
2018-04-19 20:14 ` Wolfgang Schuster
2018-04-20 3:07 ` Fabrice L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c381955-0226-9d95-09f0-4d06afb40cba@wxs.nl \
--to=pragma@wxs.nl \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).