Multiplication table (with lines) in ConTeXt?
I want to typeset a multiplication table, where there will be a horizontal line after the first row, and a vertical line after the first column. In LaTeX, I can use: \[ \begin{array}{c|ccccccc} \times&0&1&2&3&4&5&6\\ \hline 0&0&0&0&0&0&0&0\\ 1&0&1&2&3&4&5&6\\ 2&0&2&4&6&1&3&5\\ 3&0&3&6&2&5&1&4\\ 4&0&4&1&5&2&6&3\\ 5&0&5&3&1&6&4&2\\ 6&0&6&5&4&3&2&1 \end{array} \] What is the canonical way of including lines in a mathematical array in ConTeXt? Thanks, Alasdair
On Wed, 4 May 2011, Alasdair McAndrew wrote:
I want to typeset a multiplication table, where there will be a horizontal line after the first row, and a vertical line after the first column. In LaTeX, I can use:
\[ \begin{array}{c|ccccccc} \times&0&1&2&3&4&5&6\\ \hline 0&0&0&0&0&0&0&0\\ 1&0&1&2&3&4&5&6\\ 2&0&2&4&6&1&3&5\\ 3&0&3&6&2&5&1&4\\ 4&0&4&1&5&2&6&3\\ 5&0&5&3&1&6&4&2\\ 6&0&6&5&4&3&2&1 \end{array} \]
What is the canonical way of including lines in a mathematical array in ConTeXt?
\startsetups table:frame \setupTABLE[each][each][frame=off, align=middle] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups \startTABLE[setups=table:frame] \NC $\times$ \NC 1 \NC 2 \NC ... \NC \NR .... \stopTABLE Aditya
Am 04.05.2011 um 06:45 schrieb Aditya Mahajan:
\startsetups table:frame \setupTABLE[each][each][frame=off, align=middle] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups
\startTABLE[setups=table:frame] \NC $\times$ \NC 1 \NC 2 \NC ... \NC \NR .... \stopTABLE
and for the lazy people: \starttext \startsetups table:multiplication \setupTABLE[each][each][frame=off,align=middle,width=2em,height=2em] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups \startluacode context.bTABLE{setups="table:multiplication"} for i=0,6 do context.bTR() for j=0,6 do context.bTD() if i==0 and j==0 then context("×") elseif i==0 or j==0 then context(i+j) else context(i*j) end context.eTD() end context.eTR() end context.eTABLE() \stopluacode \stoptext Wolfgang
It looks like it should work, but when I try it I get a very squashed table, with lines between all rows and columns... FWIW, I'm using MKII: "ConTeXt ver: 2011.02.25 22:03 MKII fmt: 2011.3.14 int: english/english" -Alasdair On Wed, May 4, 2011 at 5:05 PM, Wolfgang Schuster < schuster.wolfgang@googlemail.com> wrote:
Am 04.05.2011 um 06:45 schrieb Aditya Mahajan:
\startsetups table:frame \setupTABLE[each][each][frame=off, align=middle] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups
\startTABLE[setups=table:frame] \NC $\times$ \NC 1 \NC 2 \NC ... \NC \NR .... \stopTABLE
and for the lazy people:
\starttext
\startsetups table:multiplication \setupTABLE[each][each][frame=off,align=middle,width=2em,height=2em] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups
\startluacode context.bTABLE{setups="table:multiplication"} for i=0,6 do context.bTR() for j=0,6 do context.bTD() if i==0 and j==0 then context("×") elseif i==0 or j==0 then context(i+j) else context(i*j) end context.eTD() end context.eTR() end context.eTABLE() \stopluacode
\stoptext
Wolfgang
___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
-- Blog: http://amca01.wordpress.com Web: http://bit.ly/Alasdair Facebook: http://www.facebook.com/alasdair.mcandrew
Am Mittwoch, den 04.05.2011, 20:10 +1000 schrieb Alasdair McAndrew:
It looks like it should work, but when I try it I get a very squashed table, with lines between all rows and columns... FWIW, I'm using MKII:
"ConTeXt ver: 2011.02.25 22:03 MKII fmt: 2011.3.14 int: english/english"
It works perfectly using MK IV. ConTeXt ver: 2011.04.30 17:02 MKIV fmt: 2011.5.1 int: english/english Thanks, Paul PS: Please do not top post or at least remove the unneeded full quote.
Am 04.05.2011 um 12:10 schrieb Alasdair McAndrew:
It looks like it should work, but when I try it I get a very squashed table, with lines between all rows and columns... FWIW, I'm using MKII:
To separate the content and style of a table Hans added a “setups” key to \bTABLE/\startTABLE in MkIV but as you use MkII this setting has no effect. You can apply the style to the table with the \setups command: % engine=pdftex \startsetups table:multiplication \setupTABLE[each][each][frame=off,align=middle,width=2em,height=2em] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups \starttext \start\setups[table:multiplication] \startTABLE \NC $\times$ \NC 0 \NC 1 \NC 2 \NC 3 \NC 4 \NC 5 \NC 6 \NC\NR \NC 0 \NC 0 \NC 0 \NC 0 \NC 0 \NC 0 \NC 0 \NC 0 \NC\NR \NC 1 \NC 0 \NC 1 \NC 2 \NC 3 \NC 4 \NC 5 \NC 6 \NC\NR \NC 2 \NC 0 \NC 2 \NC 4 \NC 6 \NC 1 \NC 3 \NC 5 \NC\NR \NC 3 \NC 0 \NC 3 \NC 6 \NC 2 \NC 5 \NC 1 \NC 4 \NC\NR \NC 4 \NC 0 \NC 4 \NC 1 \NC 5 \NC 2 \NC 6 \NC 3 \NC\NR \NC 5 \NC 0 \NC 5 \NC 3 \NC 1 \NC 6 \NC 4 \NC 2 \NC\NR \NC 6 \NC 0 \NC 6 \NC 5 \NC 4 \NC 3 \NC 2 \NC 1 \NC\NR \stopTABLE \stop \stoptext Wolfgang
Am Mittwoch, den 04.05.2011, 09:05 +0200 schrieb Wolfgang Schuster:
Am 04.05.2011 um 06:45 schrieb Aditya Mahajan:
\startsetups table:frame \setupTABLE[each][each][frame=off, align=middle] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups
\startTABLE[setups=table:frame] \NC $\times$ \NC 1 \NC 2 \NC ... \NC \NR .... \stopTABLE
and for the lazy people:
\starttext
\startsetups table:multiplication \setupTABLE[each][each][frame=off,align=middle,width=2em,height=2em] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups
\startluacode context.bTABLE{setups="table:multiplication"} for i=0,6 do context.bTR() for j=0,6 do context.bTD() if i==0 and j==0 then context("×") elseif i==0 or j==0 then context(i+j) else context(i*j)
Alasdair takes modula 7 if I understood correctly. So it can be if i*j < 7 then context(i*j) else context((i*j) % 7) end (Nice symmetry in the resulting table.)
end context.eTD() end context.eTR() end context.eTABLE() \stopluacode
\stoptext
Thank you Wolfang, I just wanted to reply and recommend using Lua. As always you were too fast. ;-) Thanks, Paul
I gave the mod 7 table as an example; what I in fact want to display is the Cayley table for the dihedral group D_4. By the way - how do I upgrade to Mk IV? I just downloaded the installer for ConTeXt Minimals and let it do its thing. This is getting very complicated... -Alasdair On Wed, May 4, 2011 at 8:43 PM, Paul Menzel < paulepanter@users.sourceforge.net> wrote:
Am Mittwoch, den 04.05.2011, 09:05 +0200 schrieb Wolfgang Schuster:
Am 04.05.2011 um 06:45 schrieb Aditya Mahajan:
\startsetups table:frame \setupTABLE[each][each][frame=off, align=middle] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups
\startTABLE[setups=table:frame] \NC $\times$ \NC 1 \NC 2 \NC ... \NC \NR .... \stopTABLE
and for the lazy people:
\starttext
\startsetups table:multiplication \setupTABLE[each][each][frame=off,align=middle,width=2em,height=2em] \setupTABLE[row][first][bottomframe=on] \setupTABLE[column][first][rightframe=on] \stopsetups
\startluacode context.bTABLE{setups="table:multiplication"} for i=0,6 do context.bTR() for j=0,6 do context.bTD() if i==0 and j==0 then context("×") elseif i==0 or j==0 then context(i+j) else context(i*j)
Alasdair takes modula 7 if I understood correctly. So it can be
if i*j < 7 then context(i*j) else context((i*j) % 7) end
(Nice symmetry in the resulting table.)
end context.eTD() end context.eTR() end context.eTABLE() \stopluacode
\stoptext
Thank you Wolfang, I just wanted to reply and recommend using Lua. As always you were too fast. ;-)
Thanks,
Paul
___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
Am 04.05.2011 um 12:49 schrieb Alasdair McAndrew:
I gave the mod 7 table as an example; what I in fact want to display is the Cayley table for the dihedral group D_4.
By the way - how do I upgrade to Mk IV? I just downloaded the installer for ConTeXt Minimals and let it do its thing.
Compile your document with “context <filename>” instead of “texexec <filename>”. Wolfgang
Dear Alasdair, please adhere to the posting style the people helping you use [1]. Please use the interleaved style [2]. Am Mittwoch, den 04.05.2011, 20:49 +1000 schrieb Alasdair McAndrew:
I gave the mod 7 table as an example; what I in fact want to display is the Cayley table for the dihedral group D_4.
Interesting. When you have that finished, it would be great if you could share your TeX file.
By the way - how do I upgrade to Mk IV? I just downloaded the installer for ConTeXt Minimals and let it do its thing.
This is getting very complicated...
Please open a new thread about that topic. Do not forget to include useful information like what operating system you use. Thanks, Paul [1] http://en.opensuse.org/openSUSE:Mailing_list_netiquette [2] https://secure.wikimedia.org/wikipedia/en/wiki/Posting_style#Interleaved_sty...
participants (4)
-
Aditya Mahajan
-
Alasdair McAndrew
-
Paul Menzel
-
Wolfgang Schuster