From: Otared Kavian <otared@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: mathmatrix and internal lines
Date: Thu, 26 Nov 2020 20:43:49 +0100 [thread overview]
Message-ID: <2201965F-382F-495F-AE59-A2CB23815544@gmail.com> (raw)
In-Reply-To: <25488D75-D587-4E06-8680-5CBB19508E81@centralesupelec.fr>
Hi Jean-Philippe,
A few weeks ago I saw briefly the discussion about Hans' message regarding \noalign and the the new definitions of \HR and \VR that you are sending. Indeed your solution works great !
Just for the case other people may have the same question about writing block matrix, I copy below the whole example which can be found later in the mail archive.
(For mkiv, I don't know how to do the same thing…).
%%% begin block-matrix.tex
% in LMTX defining \HR and \VR to create block matrices:
\pushoverloadmode
\noaligned\tolerant\protected\def\HR[#1]{\noalign{\hrule #1}}
\popoverloadmode
\def\VR{\dosingleempty\doVR}
\def\doVR[#1]{\NC \hskip-0.5em \vrule #1 \hskip-0.5em \NC}
\definemathmatrix[mymatrix]
[left={\left(\,},
right={\, \right)}]
\starttext
\startformula
\startmymatrix
\NC A \VR B \NR
\HR
\NC C \VR D \NR
\stopmymatrix
\stopformula
\stoptext
%%% end block-matrix.tex
Best regards: Otared K.
> On 26 Nov 2020, at 19:46, Jean-Philippe Rey <jean-philippe.rey@centralesupelec.fr> wrote:
>
> Hi Otared,
>
> Thank you very much.
>
> I used your example to write the following macros. They are far from perfect but suit my needs. A few days ago, Hans warned not to use \noalign in LMTX, so I used the trick he gave to the list even if I don't really understand it.
>
> === LMTX version ============
> %D \macros{HR, VR}
> %D \type{\HR} draws a horizontal rule between two rows of a matrix
> %D \type{\VR} is used in place of \type{\NC} to draw a vertical rule between two columns of a matrix
> %D each macro takes an optional parameter giving the rule dimensions
> %D Example
> %D \type{\startmatrix \NC A \VR[depth 2mm] B \NR \HR[height 0.6pt] \NC C \VR D \NR \stopmatrix}
>
> \pushoverloadmode
> \noaligned\tolerant\protected\def\HR[#1]{\noalign{\hrule #1}}
> \popoverloadmode
>
> \def\VR{\dosingleempty\doVR}
> \def\doVR[#1]{\NC \hskip-0.5em \vrule #1 \hskip-0.5em \NC}
> ===========================
>
> === MkIV version ============
> %D \macros{HR, VR}
> %D \type{\HR} draws a horizontal rule between two rows of a matrix
> %D \type{\VR} is used in place of \type{\NC} to draw a vertical rule between two columns of a matrix
> %D it takes an optional parameter giving the rule dimensions
> %D Example
> %D \type{\startmatrix \NC A \VR[depth 2mm] B \NR \HR \NC C \VR D \NR \stopmatrix}
>
> \def\HR{\noalign{\hrule}}
>
> \def\VR{\dosingleempty\doVR}
> \def\doVR[#1]{\NC \hskip-0.5em \vrule #1 \hskip-0.5em \NC}
> ===========================
>
> For the MkIV version I haven't been able to add an optional parameter to \HR the code
>
> \def\HR{\dosingleempty\doHR}
> \def\doHR[#1]{\noalign{\hrule #1}}
>
> complains about "Misplaced \noalign"
>
> Best regards,
>
>
>
>> Le 26 nov. 2020 à 13:40, Otared Kavian <otared@gmail.com> a écrit :
>>
>> Hi Jean-Philippe,
>>
>> The following is better than the one I sent earlier:
>>
>> \definemathmatrix[mymatrix]
>> [left={\left(\,},
>> right={\ \right)}]
>>
>> \starttext
>> \startformula
>> \startmymatrix
>> \NC A \NC\hskip-.5em \vrule \NC\hskip-.5em B \NR
>> \noalign{\hrule}
>> \NC C \NC \hskip-.5em\vrule \NC \hskip-.5em D \NR
>> \stopmymatrix
>> \stopformula
>> \stoptext
>>
>> Best regards: Otared K.
>>
>>> On 26 Nov 2020, at 10:19, Jean-Philippe Rey <jean-philippe.rey@centralesupelec.fr> wrote:
>>>
>>> Dear list,
>>>
>>> I would like to draw matrices with internal lines as can be done with LaTeX (cf pdf output) :
>>>
>>> ========================
>>> \documentclass{article}
>>> \begin{document}
>>> $M =\left( \begin{array}{c|c}
>>> A & B \\
>>> \hline
>>> C & D \\
>>> \end{array} \right)$
>>> \end{document}
>>> ========================
>>>
>>> I didn't find out how to use mathmatrix to achieve this. My best result to date is
>>>
>>> ========================
>>> \starttext
>>> $M = \left( \bTABLE[frame=off]
>>> \bTR
>>> \bTD[rightframe=on, bottomframe=on] $A$ \eTD
>>> \bTD[bottomframe=on] $B$ \eTD
>>> \eTR\bTR
>>> \bTD[rightframe=on] $C$ \eTD
>>> \bTD $D$ \eTD
>>> \eTR
>>> \eTABLE \right)$
>>> \stoptext
>>> ========================
>>>
>>> The code is rather ugly, and I get a spurious space at the bottom of the table.
>>>
>>> Any hints?
>>>
>>> Thank you,
>
> --
> Jean-Philippe Rey
> jean-philippe.rey@centralesupelec.fr
> 91192 Gif-sur-Yvette Cedex - France
> Empreinte PGP : 807A 5B2C 69E4 D4B5 783A 428A 1B5E E83E 261B BF51
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
___________________________________________________________________________________
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:[~2020-11-26 19:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-26 9:19 Jean-Philippe Rey
2020-11-26 9:58 ` Otared Kavian
2020-11-26 12:40 ` Otared Kavian
2020-11-26 18:46 ` Jean-Philippe Rey
2020-11-26 19:43 ` Otared Kavian [this message]
2020-11-26 22:23 ` Hans Hagen
2020-11-27 9:07 ` Otared Kavian
2020-11-27 9:19 ` Hans Hagen
2020-11-29 7:48 ` Otared Kavian
2020-11-29 18:59 ` Jean-Philippe Rey
2020-11-29 20:01 ` Otared Kavian
2020-11-30 8:14 ` Taco Hoekwater
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=2201965F-382F-495F-AE59-A2CB23815544@gmail.com \
--to=otared@gmail.com \
--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).