ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Booktabs equivalent in Context
@ 2007-08-03 21:10 Aditya Mahajan
  2007-08-04  7:28 ` Patrick Gundlach
  2007-08-08 12:03 ` Johannes Graumann
  0 siblings, 2 replies; 14+ messages in thread
From: Aditya Mahajan @ 2007-08-03 21:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

The question of how to get tables equivalent to latex's booktabs 
package has been discussed quite a few times in the past. Booktabs 
package provides (top|mid|bottom)rule commands and a cmidrule command. 
The top and bottom rules are 0.08em thick, the midrule is 0.05em thick, 
and the cmidrules are 0.03em thick. The cmidrules do not extend beyond 
the columns edge. Here is an example of how to do something similar 
using tables in context <http://wiki.contextgarden.net/Table#Booktabs>.

To me this looks exactly similar to the example in the booktabs manual. 
Am I missing something, or is it fair to say that context can generate 
booktabs like tables?

Patrick, any commnets?

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-03 21:10 Booktabs equivalent in Context Aditya Mahajan
@ 2007-08-04  7:28 ` Patrick Gundlach
  2007-08-06  1:13   ` Aditya Mahajan
  2007-08-08 12:03 ` Johannes Graumann
  1 sibling, 1 reply; 14+ messages in thread
From: Patrick Gundlach @ 2007-08-04  7:28 UTC (permalink / raw)
  To: ntg-context

Hello Aditya,

> To me this looks exactly similar to the example in the booktabs manual. 
> Am I missing something, or is it fair to say that context can generate 
> booktabs like tables?


Any way to shorten the rule \DL[2]? IMO this is critical for nicely
set tables.

But the rest looks very, very good! So many thanks for that!

I once had to typeset a huge table, with huge in the sense of 'lots of
rows and lots of columns' on a A4 single page. This would not have
been possible without the help of \cmidrule which is a rule between
two rows but restricted to a number of columns and with the ability to
trim the rule on the left, the right or both sides.


Gnu      stuffed
-------- -----------
Emu      stuffed

So the first rule should be aligned left with the other rules in that
table, the two rules must not touch each other (this is the trick to
avoid the ugly vertical rules!) In booktabs speak this would be
\cmidrule(r){1-1} and \cmidrule(l){2-2}. (booktabs.pdf on a LaTeX
installation). 

Is there something like \arraystretch(?) which is a factor that every
vertical whitespace in a table is multiplied with? This way you can
increase/decrease the height of a table without big trouble.

Patrick
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-04  7:28 ` Patrick Gundlach
@ 2007-08-06  1:13   ` Aditya Mahajan
  2007-08-11 21:05     ` Patrick Gundlach
  0 siblings, 1 reply; 14+ messages in thread
From: Aditya Mahajan @ 2007-08-06  1:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sat, 4 Aug 2007, Patrick Gundlach wrote:

> Hello Aditya,
>
>> To me this looks exactly similar to the example in the booktabs manual.
>> Am I missing something, or is it fair to say that context can generate
>> booktabs like tables?
>
>
> Any way to shorten the rule \DL[2]? IMO this is critical for nicely
> set tables.
>
> But the rest looks very, very good! So many thanks for that!
>
> I once had to typeset a huge table, with huge in the sense of 'lots of
> rows and lots of columns' on a A4 single page. This would not have
> been possible without the help of \cmidrule which is a rule between
> two rows but restricted to a number of columns and with the ability to
> trim the rule on the left, the right or both sides.
>
>
> Gnu      stuffed
> -------- -----------
> Emu      stuffed
>
> So the first rule should be aligned left with the other rules in that
> table, the two rules must not touch each other (this is the trick to
> avoid the ugly vertical rules!) In booktabs speak this would be
> \cmidrule(r){1-1} and \cmidrule(l){2-2}. (booktabs.pdf on a LaTeX
> installation).

Ah. Thank you for the explaination. I now understand the need for 
cmidrule. It should be possible to get something like this with TaBlE, 
but in the absense of the original PCTEX manual, I have not been able 
to understand how to set tables. thrd-tab.tex says that you can 
actually control the tokens for columns using alternate vrules, but I 
have not been able to get it to work.

> Is there something like \arraystretch(?) which is a factor that every
> vertical whitespace in a table is multiplied with? This way you can
> increase/decrease the height of a table without big trouble.

If you are happy with an integer scaling, and do not use \Lower (it 
may be possible to do this more correctly, with distance={{a}{b}{c}}, 
and action for unknown set so that we call 
\OpenUp{a}{b}\def\LOW{\Lower{c}}).

\unprotected\def\defineTABLEunits
   {\processaction
      [\@@tidistance]
      [  \v!none=>\OpenUp00\def\LOW{\Lower6 },
        \v!small=>\OpenUp00\def\LOW{\Lower6 }, % == baseline
       \v!medium=>\OpenUp11\def\LOW{\Lower7 },
          \v!big=>\OpenUp22\def\LOW{\Lower8 },
      \v!unknown=>\expandafter\OpenUp\@@tidistance]%AM: Added
    \doifelse\@@tidistance\v!none
      {\chardef\TABLErowfactor\zerocount}
      {\chardef\TABLErowfactor\plustwo  }}

\setuptables[rulethickness=0.03em]

\startbuffer
\starttable[s0|l|i2l|i2r|]
   \HL[3]
   \NC \Use2[c]{Item}             \NC            \NC \AR
   \DL[2]                         \DC                \DR
   \NC Animal    \NC Description  \NC Price (\$) \NC \AR
   \HL[2]
   \NC Gnat      \NC per gram     \NC 13.65      \NC \AR
   \NC           \NC each         \NC  0.01      \NC \AR
   \NC Gnu       \NC stuffed      \NC 92.50      \NC \AR
   \NC Emu       \NC stuffed      \NC 33.33      \NC \AR
   \NC Armadillo \NC frozen       \NC  8.99      \NC \AR
   \HL[3]
\stoptable
\stopbuffer

\starttext

\getbuffer

\setuptables[distance=big]

\getbuffer
\setuptables[distance={{1}{10}}]

\getbuffer

\setuptables[distance=55]
\getbuffer

\stoptext

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-03 21:10 Booktabs equivalent in Context Aditya Mahajan
  2007-08-04  7:28 ` Patrick Gundlach
@ 2007-08-08 12:03 ` Johannes Graumann
  2007-08-08 22:23   ` Aditya Mahajan
  1 sibling, 1 reply; 14+ messages in thread
From: Johannes Graumann @ 2007-08-08 12:03 UTC (permalink / raw)
  To: ntg-context

Hello,

I'm one of the booktab-equivalent requesters and in my case the request is
motivated by the (sadly German-only)
http://www.ctan.org/tex-archive/info/german/tabsatz/tabsatz.pdf
Please compare examples on pages 4 and 5 for the cmidrule functionality I'm
missing in ConTeXt. The clarity you can give classy looking tables with
trimmed cmidrules is even more evident in the example on page 9. There's
lots of more use of this in the document, but it gets too esoteric to be
easily grasped quickly (IMHO).

Joh

Aditya Mahajan wrote:

> Hi,
> 
> The question of how to get tables equivalent to latex's booktabs
> package has been discussed quite a few times in the past. Booktabs
> package provides (top|mid|bottom)rule commands and a cmidrule command.
> The top and bottom rules are 0.08em thick, the midrule is 0.05em thick,
> and the cmidrules are 0.03em thick. The cmidrules do not extend beyond
> the columns edge. Here is an example of how to do something similar
> using tables in context <http://wiki.contextgarden.net/Table#Booktabs>.
> 
> To me this looks exactly similar to the example in the booktabs manual.
> Am I missing something, or is it fair to say that context can generate
> booktabs like tables?
> 
> Patrick, any commnets?
> 
> Aditya
>
___________________________________________________________________________________
> 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  : https://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-08 12:03 ` Johannes Graumann
@ 2007-08-08 22:23   ` Aditya Mahajan
  2007-08-09  5:06     ` Hamid Kamrani
  0 siblings, 1 reply; 14+ messages in thread
From: Aditya Mahajan @ 2007-08-08 22:23 UTC (permalink / raw)
  To: ntg-context

Quoting Johannes Graumann <johannes_graumann@web.de>:

> Aditya Mahajan wrote:
>
>> Hi,
>>
>> The question of how to get tables equivalent to latex's booktabs
>> package has been discussed quite a few times in the past. Booktabs
>> package provides (top|mid|bottom)rule commands and a cmidrule command.
>> The top and bottom rules are 0.08em thick, the midrule is 0.05em thick,
>> and the cmidrules are 0.03em thick. The cmidrules do not extend beyond
>> the columns edge. Here is an example of how to do something similar
>> using tables in context <http://wiki.contextgarden.net/Table#Booktabs>.
>>
>> To me this looks exactly similar to the example in the booktabs manual.
>> Am I missing something, or is it fair to say that context can generate
>> booktabs like tables?

> Hello,
>
> I'm one of the booktab-equivalent requesters and in my case the request is
> motivated by the (sadly German-only)
> http://www.ctan.org/tex-archive/info/german/tabsatz/tabsatz.pdf
> Please compare examples on pages 4 and 5 for the cmidrule functionality I'm
> missing in ConTeXt. The clarity you can give classy looking tables with
> trimmed cmidrules is even more evident in the example on page 9. There's
> lots of more use of this in the document, but it gets too esoteric to be
> easily grasped quickly (IMHO).

Here is one attempt, which works correctly. Of course the best solution 
is to forget about the \omit and set the halign preamble correctly. But 
I have not been able to figure that out yet.

\starttext

\def\CMID{\normalTABLEshortrule}

\unprotect
\def\TableNC
  {\checkTABLEautorow
   \nextTABLEgrayline
   \ifnum\currentTABLEcolumn>\maxTABLEcolumn
     \setTABLEerror\TABLEmissingrow
     \handleTABLEerror
   \else
     \global\advance\currentTABLEcolumn \plusone
     \ifnum\currentTABLEcolumn=1\relax
       \normalTABLEquote
     \else
       \fancyTABLEquote
      \fi
   \fi}

\def\fancyTABLEquote      {\unskip\!ttRightGlue&\omit\hskip2em&} % "
\protect

\setuptables[rulethickness=0.03em]

\starttable[s0|l|l|]
  \HL[3]
  \NC Monat     \NC 1965  \NC 1966  \AR
  \NC \CMID     \NC \CMID \NC \CMID \DR
  \NC September \NC 2000  \NC 1700 \AR
  \HL[3]
\stoptable

\stoptext


Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-08 22:23   ` Aditya Mahajan
@ 2007-08-09  5:06     ` Hamid Kamrani
  2007-08-09  6:43       ` Wolfgang Schuster
  0 siblings, 1 reply; 14+ messages in thread
From: Hamid Kamrani @ 2007-08-09  5:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Aditya,

In the example you give with CMID you have only two column preambles
whereas the table has 3 columns and if one adds the missing preamble
then one gets an error. Some how your new code breaks the calculation
for number of columns.

-Hamid

On 8/8/07, Aditya Mahajan <adityam@umich.edu> wrote:
> Quoting Johannes Graumann <johannes_graumann@web.de>:
>
> > Aditya Mahajan wrote:
> >
> >> Hi,
> >>
> >> The question of how to get tables equivalent to latex's booktabs
> >> package has been discussed quite a few times in the past. Booktabs
> >> package provides (top|mid|bottom)rule commands and a cmidrule command.
> >> The top and bottom rules are 0.08em thick, the midrule is 0.05em thick,
> >> and the cmidrules are 0.03em thick. The cmidrules do not extend beyond
> >> the columns edge. Here is an example of how to do something similar
> >> using tables in context <http://wiki.contextgarden.net/Table#Booktabs>.
> >>
> >> To me this looks exactly similar to the example in the booktabs manual.
> >> Am I missing something, or is it fair to say that context can generate
> >> booktabs like tables?
>
> > Hello,
> >
> > I'm one of the booktab-equivalent requesters and in my case the request is
> > motivated by the (sadly German-only)
> > http://www.ctan.org/tex-archive/info/german/tabsatz/tabsatz.pdf
> > Please compare examples on pages 4 and 5 for the cmidrule functionality I'm
> > missing in ConTeXt. The clarity you can give classy looking tables with
> > trimmed cmidrules is even more evident in the example on page 9. There's
> > lots of more use of this in the document, but it gets too esoteric to be
> > easily grasped quickly (IMHO).
>
> Here is one attempt, which works correctly. Of course the best solution
> is to forget about the \omit and set the halign preamble correctly. But
> I have not been able to figure that out yet.
>
> \starttext
>
> \def\CMID{\normalTABLEshortrule}
>
> \unprotect
> \def\TableNC
>   {\checkTABLEautorow
>    \nextTABLEgrayline
>    \ifnum\currentTABLEcolumn>\maxTABLEcolumn
>      \setTABLEerror\TABLEmissingrow
>      \handleTABLEerror
>    \else
>      \global\advance\currentTABLEcolumn \plusone
>      \ifnum\currentTABLEcolumn=1\relax
>        \normalTABLEquote
>      \else
>        \fancyTABLEquote
>       \fi
>    \fi}
>
> \def\fancyTABLEquote      {\unskip\!ttRightGlue&\omit\hskip2em&} % "
> \protect
>
> \setuptables[rulethickness=0.03em]
>
> \starttable[s0|l|l|]
>   \HL[3]
>   \NC Monat     \NC 1965  \NC 1966  \AR
>   \NC \CMID     \NC \CMID \NC \CMID \DR
>   \NC September \NC 2000  \NC 1700 \AR
>   \HL[3]
> \stoptable
>
> \stoptext
>
>
> Aditya
> ___________________________________________________________________________________
> 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  : https://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-09  5:06     ` Hamid Kamrani
@ 2007-08-09  6:43       ` Wolfgang Schuster
  2007-08-09  7:43         ` Aditya Mahajan
  2007-08-09 16:01         ` Hamid Kamrani
  0 siblings, 2 replies; 14+ messages in thread
From: Wolfgang Schuster @ 2007-08-09  6:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2007/8/9, Hamid Kamrani <hamid.kamrani@gmail.com>:
> Aditya,
>
> In the example you give with CMID you have only two column preambles
> whereas the table has 3 columns and if one adds the missing preamble
> then one gets an error. Some how your new code breaks the calculation
> for number of columns.
>
> -Hamid

He forgot only to put a \NC before the \AR.

The correct code should be

\starttable[s0|l|l|l|]
 \HL[3]
 \NC Monat     \NC 1965  \NC 1966  \NC\AR
 \NC \CMID     \NC \CMID \NC \CMID \DR
 \NC September \NC 2000  \NC 1700 \NC\AR
 \HL[3]
\stoptable

Wolfgang

> On 8/8/07, Aditya Mahajan <adityam@umich.edu> wrote:
> > Quoting Johannes Graumann <johannes_graumann@web.de>:
> >
> > > Aditya Mahajan wrote:
> > >
> > >> Hi,
> > >>
> > >> The question of how to get tables equivalent to latex's booktabs
> > >> package has been discussed quite a few times in the past. Booktabs
> > >> package provides (top|mid|bottom)rule commands and a cmidrule command.
> > >> The top and bottom rules are 0.08em thick, the midrule is 0.05em thick,
> > >> and the cmidrules are 0.03em thick. The cmidrules do not extend beyond
> > >> the columns edge. Here is an example of how to do something similar
> > >> using tables in context <http://wiki.contextgarden.net/Table#Booktabs>.
> > >>
> > >> To me this looks exactly similar to the example in the booktabs manual.
> > >> Am I missing something, or is it fair to say that context can generate
> > >> booktabs like tables?
> >
> > > Hello,
> > >
> > > I'm one of the booktab-equivalent requesters and in my case the request is
> > > motivated by the (sadly German-only)
> > > http://www.ctan.org/tex-archive/info/german/tabsatz/tabsatz.pdf
> > > Please compare examples on pages 4 and 5 for the cmidrule functionality I'm
> > > missing in ConTeXt. The clarity you can give classy looking tables with
> > > trimmed cmidrules is even more evident in the example on page 9. There's
> > > lots of more use of this in the document, but it gets too esoteric to be
> > > easily grasped quickly (IMHO).
> >
> > Here is one attempt, which works correctly. Of course the best solution
> > is to forget about the \omit and set the halign preamble correctly. But
> > I have not been able to figure that out yet.
> >
> > \starttext
> >
> > \def\CMID{\normalTABLEshortrule}
> >
> > \unprotect
> > \def\TableNC
> >   {\checkTABLEautorow
> >    \nextTABLEgrayline
> >    \ifnum\currentTABLEcolumn>\maxTABLEcolumn
> >      \setTABLEerror\TABLEmissingrow
> >      \handleTABLEerror
> >    \else
> >      \global\advance\currentTABLEcolumn \plusone
> >      \ifnum\currentTABLEcolumn=1\relax
> >        \normalTABLEquote
> >      \else
> >        \fancyTABLEquote
> >       \fi
> >    \fi}
> >
> > \def\fancyTABLEquote      {\unskip\!ttRightGlue&\omit\hskip2em&} % "
> > \protect
> >
> > \setuptables[rulethickness=0.03em]
> >
> > \starttable[s0|l|l|]
> >   \HL[3]
> >   \NC Monat     \NC 1965  \NC 1966  \AR
> >   \NC \CMID     \NC \CMID \NC \CMID \DR
> >   \NC September \NC 2000  \NC 1700 \AR
> >   \HL[3]
> > \stoptable
> >
> > \stoptext
> >
> >
> > Aditya
> > ___________________________________________________________________________________
> > 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  : https://foundry.supelec.fr/projects/contextrev/
> > 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://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-09  6:43       ` Wolfgang Schuster
@ 2007-08-09  7:43         ` Aditya Mahajan
  2007-08-09  8:56           ` Wolfgang Schuster
  2007-08-11 21:05           ` Patrick Gundlach
  2007-08-09 16:01         ` Hamid Kamrani
  1 sibling, 2 replies; 14+ messages in thread
From: Aditya Mahajan @ 2007-08-09  7:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 834 bytes --]

On Thu, 9 Aug 2007, Wolfgang Schuster wrote:

> 2007/8/9, Hamid Kamrani <hamid.kamrani@gmail.com>:
>> Aditya,
>>
>> In the example you give with CMID you have only two column preambles
>> whereas the table has 3 columns and if one adds the missing preamble
>> then one gets an error. Some how your new code breaks the calculation
>> for number of columns.
>>
>> -Hamid
>
> He forgot only to put a \NC before the \AR.

Sorry about that. I thought I pasted from a correctly running example.

Here is another attempt, which I feel is the cleanest way to go about 
this whole thing. Right now the skip between the columns is not 
configurable, but it should be possible to use the get the value of 
the skip.

The attached code typesets an example that Wolfgang had sent off-list. 
I have only changed two lines of the table.tex.

Aditya

[-- Attachment #2: Type: TEXT/PLAIN, Size: 2908 bytes --]

\TracingFormats=2

\starttext
\unprotect
% SET VRULE: Invoked by the key "|"
\def\!tfSetVrule{%
  \!thToksEdef\!taRuleColumnTemplate={%
    \noexpand\hfil
    \noexpand\vrule
    \noexpand\!thWidth
    \ifnum \!tgCode=1
      \ifx \!tgValue\empty
        \the\LineThicknessFactor      % Default integer
      \else
        \!tgValue                     % User-specified integer
      \fi
      \!taLTU                         % \LineThicknessUnit
    \else
      \!tgValue                       % User-specified dimension
    \fi
    ####%
    \noexpand\hfil
    \the\!taRuleColumnTemplate%      % has \tabskips, when column number=0
    \ifnum\!taColumnNumber=\zerocount\else\tabskip2em\fi}%ADDED (should be configurable)
  \!tfAdjoinPriorColumn}

\def\!tfAdjoinPriorColumn{%
  \ifnum \!taColumnNumber=0
    \!taPreamble=\!taRuleColumnTemplate % New \tabskip may have been added
    \ifnum \TracingFormats>0
      \!tfShowRuleTemplate
    \fi
  \else
    \ifx\!tfRowOfWidths\empty  % no "w" keys specified yet, not even this col
    \else
      \!tfUpdateRowOfWidths
    \fi
    % Adjoin positioning glues to left and right of template
    \!thToksEdef\!taDataColumnTemplate={%
      \the \!taLeftGlue
      \the \!taDataColumnTemplate
      \the \!taRightGlue
      \tabskip\zeropoint}%ADDED
    \ifnum \TracingFormats>0
      \!tfShowTemplates
    \fi
    % Adjoin data- and rule-column templates to preamble
    \!thToksEdef\!taPreamble={%
      \the\!taPreamble
      &
      \the\!taDataColumnTemplate
      &
      \the\!taRuleColumnTemplate}
  \fi
%
% START NEW COLUMN
  \advance \!taColumnNumber 1
  % Initialize data-column template, restoring last "regular" tabskip
  % after a "once only" tabskip
  \if!taOnceOnlyTabskip
    \!thToksEdef\!taDataColumnTemplate={%
       ####\tabskip \the\!taLastRegularTabskip}
  \else
    \!taDataColumnTemplate{##}%
  \fi
  % Remaining initializations
  \!taRuleColumnTemplate{}% # is inserted by \SetVrule, or \SetAlternateVrule
  \!taLeftGlue{\hfil}%         % Default positioning is "center"
  \!taRightGlue{\hfil}%
  \!taMinimumColumnWidth=0pt
  \def\!tfWidthText{}%
  \!taOnceOnlyTabskipfalse    % Set true by key "o"
  \ReadFormatKeys}

\def\CM{\normalTABLEshortrule}

\protect



\starttable[s0|l|l|c|]
  \HL[3]
% \TABLEnoalign{\unprotect\showthe\!taPreamble\protect}
  \NC \Use3[c]{Kase-Ubersicht} \NC \AR
  \HL[2]
  \NC Kase                \NC Herkunftsland \NC Preis (Euro) \NC \AR
  \NC \CM                 \NC \CM           \NC \CM          \NC \DR
  \NC Edamer              \NC Holland       \NC 12.23        \NC \AR
  \NC Gouda               \NC Holland       \NC 9.34         \NC \AR
  \NC Emmentaler          \NC Allgau        \NC 2.34         \NC \AR
  \NC Andechser Bierkase  \NC Bayern        \NC 1.--         \NC \AR
  \HL[3]
\stoptable
\stoptext

[-- Attachment #3: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-09  7:43         ` Aditya Mahajan
@ 2007-08-09  8:56           ` Wolfgang Schuster
  2007-08-09 16:14             ` Aditya Mahajan
  2007-08-11 21:05           ` Patrick Gundlach
  1 sibling, 1 reply; 14+ messages in thread
From: Wolfgang Schuster @ 2007-08-09  8:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2007/8/9, Aditya Mahajan <adityam@umich.edu>:
> On Thu, 9 Aug 2007, Wolfgang Schuster wrote:
>
> > 2007/8/9, Hamid Kamrani <hamid.kamrani@gmail.com>:
> >> Aditya,
> >>
> >> In the example you give with CMID you have only two column preambles
> >> whereas the table has 3 columns and if one adds the missing preamble
> >> then one gets an error. Some how your new code breaks the calculation
> >> for number of columns.
> >>
> >> -Hamid
> >
> > He forgot only to put a \NC before the \AR.
>
> Sorry about that. I thought I pasted from a correctly running example.
>
> Here is another attempt, which I feel is the cleanest way to go about
> this whole thing. Right now the skip between the columns is not
> configurable, but it should be possible to use the get the value of
> the skip.
>
> The attached code typesets an example that Wolfgang had sent off-list.
> I have only changed two lines of the table.tex.
>
> Aditya

Hi Aditya,

what do you think about

\setuptables
  [\c!columndistance=2em]

\def\!tfSetVrule{%
  \!thToksEdef\!taRuleColumnTemplate={%
    \noexpand\hfil
    \noexpand\vrule
    \noexpand\!thWidth
    \ifnum \!tgCode=1
      \ifx \!tgValue\empty
        \the\LineThicknessFactor      % Default integer
      \else
        \!tgValue                     % User-specified integer
      \fi
      \!taLTU                         % \LineThicknessUnit
    \else
      \!tgValue                       % User-specified dimension
    \fi
    ####%
    \noexpand\hfil
    \the\!taRuleColumnTemplate%      % has \tabskips, when column number=0
    \ifnum\!taColumnNumber=\zerocount\else\tabskip\@@ticolumndistance\fi}%ADDED
(should be configurable)
  \!tfAdjoinPriorColumn}

I changed your hard code 2em value for \tabskip to a parameter in \setuptables.

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-09  6:43       ` Wolfgang Schuster
  2007-08-09  7:43         ` Aditya Mahajan
@ 2007-08-09 16:01         ` Hamid Kamrani
  1 sibling, 0 replies; 14+ messages in thread
From: Hamid Kamrani @ 2007-08-09 16:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Wolfgang,

It is not just a matter of forgetting the NC. When you add that NC
then the tabbing and alignment is incorrect for the last column. The
rules should not extend beyond the last column and in this case they
do.

Aditya's formatted correctly but had the wrong syntax. Yours has the
right syntax but formats incorrectly.

-Hamid


On 8/9/07, Wolfgang Schuster <schuster.wolfgang@googlemail.com> wrote:
> 2007/8/9, Hamid Kamrani <hamid.kamrani@gmail.com>:
> > Aditya,
> >
> > In the example you give with CMID you have only two column preambles
> > whereas the table has 3 columns and if one adds the missing preamble
> > then one gets an error. Some how your new code breaks the calculation
> > for number of columns.
> >
> > -Hamid
>
> He forgot only to put a \NC before the \AR.
>
> The correct code should be
>
> \starttable[s0|l|l|l|]
>  \HL[3]
>  \NC Monat     \NC 1965  \NC 1966  \NC\AR
>  \NC \CMID     \NC \CMID \NC \CMID \DR
>  \NC September \NC 2000  \NC 1700 \NC\AR
>  \HL[3]
> \stoptable
>
> Wolfgang
>
> > On 8/8/07, Aditya Mahajan <adityam@umich.edu> wrote:
> > > Quoting Johannes Graumann <johannes_graumann@web.de>:
> > >
> > > > Aditya Mahajan wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> The question of how to get tables equivalent to latex's booktabs
> > > >> package has been discussed quite a few times in the past. Booktabs
> > > >> package provides (top|mid|bottom)rule commands and a cmidrule command.
> > > >> The top and bottom rules are 0.08em thick, the midrule is 0.05em thick,
> > > >> and the cmidrules are 0.03em thick. The cmidrules do not extend beyond
> > > >> the columns edge. Here is an example of how to do something similar
> > > >> using tables in context <http://wiki.contextgarden.net/Table#Booktabs>.
> > > >>
> > > >> To me this looks exactly similar to the example in the booktabs manual.
> > > >> Am I missing something, or is it fair to say that context can generate
> > > >> booktabs like tables?
> > >
> > > > Hello,
> > > >
> > > > I'm one of the booktab-equivalent requesters and in my case the request is
> > > > motivated by the (sadly German-only)
> > > > http://www.ctan.org/tex-archive/info/german/tabsatz/tabsatz.pdf
> > > > Please compare examples on pages 4 and 5 for the cmidrule functionality I'm
> > > > missing in ConTeXt. The clarity you can give classy looking tables with
> > > > trimmed cmidrules is even more evident in the example on page 9. There's
> > > > lots of more use of this in the document, but it gets too esoteric to be
> > > > easily grasped quickly (IMHO).
> > >
> > > Here is one attempt, which works correctly. Of course the best solution
> > > is to forget about the \omit and set the halign preamble correctly. But
> > > I have not been able to figure that out yet.
> > >
> > > \starttext
> > >
> > > \def\CMID{\normalTABLEshortrule}
> > >
> > > \unprotect
> > > \def\TableNC
> > >   {\checkTABLEautorow
> > >    \nextTABLEgrayline
> > >    \ifnum\currentTABLEcolumn>\maxTABLEcolumn
> > >      \setTABLEerror\TABLEmissingrow
> > >      \handleTABLEerror
> > >    \else
> > >      \global\advance\currentTABLEcolumn \plusone
> > >      \ifnum\currentTABLEcolumn=1\relax
> > >        \normalTABLEquote
> > >      \else
> > >        \fancyTABLEquote
> > >       \fi
> > >    \fi}
> > >
> > > \def\fancyTABLEquote      {\unskip\!ttRightGlue&\omit\hskip2em&} % "
> > > \protect
> > >
> > > \setuptables[rulethickness=0.03em]
> > >
> > > \starttable[s0|l|l|]
> > >   \HL[3]
> > >   \NC Monat     \NC 1965  \NC 1966  \AR
> > >   \NC \CMID     \NC \CMID \NC \CMID \DR
> > >   \NC September \NC 2000  \NC 1700 \AR
> > >   \HL[3]
> > > \stoptable
> > >
> > > \stoptext
> > >
> > >
> > > Aditya
> > > ___________________________________________________________________________________
> > > 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  : https://foundry.supelec.fr/projects/contextrev/
> > > 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://tex.aanhet.net
> > archive  : https://foundry.supelec.fr/projects/contextrev/
> > 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://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-09  8:56           ` Wolfgang Schuster
@ 2007-08-09 16:14             ` Aditya Mahajan
  2007-08-10  5:44               ` Wolfgang Schuster
  0 siblings, 1 reply; 14+ messages in thread
From: Aditya Mahajan @ 2007-08-09 16:14 UTC (permalink / raw)
  To: ntg-context

Quoting Wolfgang Schuster <schuster.wolfgang@googlemail.com>:

> 2007/8/9, Aditya Mahajan <adityam@umich.edu>:
>> On Thu, 9 Aug 2007, Wolfgang Schuster wrote:
>>
>> > 2007/8/9, Hamid Kamrani <hamid.kamrani@gmail.com>:
>> >> Aditya,
>> >>
>> >> In the example you give with CMID you have only two column preambles
>> >> whereas the table has 3 columns and if one adds the missing preamble
>> >> then one gets an error. Some how your new code breaks the calculation
>> >> for number of columns.
>> >>
>> >> -Hamid
>> >
>> > He forgot only to put a \NC before the \AR.
>>
>> Sorry about that. I thought I pasted from a correctly running example.
>>
>> Here is another attempt, which I feel is the cleanest way to go about
>> this whole thing. Right now the skip between the columns is not
>> configurable, but it should be possible to use the get the value of
>> the skip.
>>
>> The attached code typesets an example that Wolfgang had sent off-list.
>> I have only changed two lines of the table.tex.
>>
>> Aditya
>
> Hi Aditya,
>
> what do you think about
>
> \setuptables
>  [\c!columndistance=2em]

This goes against the way I understand table macros. With this, you can 
only have equal width columns. In tables, you can specify specific 
widths of specific s and o keys.

AFAIU, the table macros divide that the specified tabskip by 2, and 
place it in the data column. Since the rule column comes next, the rule 
column automatically gets the same tabskip, so in appearance we the 
specified column width.

This is also the reason why cmidrules do not work. If you specify a 
hrule inside a data column, it spans half of the visual space between 
the columns. What needs to be done is that the glue be added inside a 
local group to the rule column, with the global tabskip set to zero.

The previous solution that I posted adds a 2em tabskip glue to the rule 
column, and a 0pt tabskip glue to the data column. After thinking again 
about it, I think that this is not the right way. There is no need to 
add a 0pt glue to the data column. We can add the glue to the rule 
column inside a group.

I will see if I can get this working.

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-09 16:14             ` Aditya Mahajan
@ 2007-08-10  5:44               ` Wolfgang Schuster
  0 siblings, 0 replies; 14+ messages in thread
From: Wolfgang Schuster @ 2007-08-10  5:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2007/8/9, Aditya Mahajan <adityam@umich.edu>:
> Quoting Wolfgang Schuster <schuster.wolfgang@googlemail.com>:
>
> > 2007/8/9, Aditya Mahajan <adityam@umich.edu>:
> >> On Thu, 9 Aug 2007, Wolfgang Schuster wrote:
> >>
> >> > 2007/8/9, Hamid Kamrani <hamid.kamrani@gmail.com>:
> >> >> Aditya,
> >> >>
> >> >> In the example you give with CMID you have only two column preambles
> >> >> whereas the table has 3 columns and if one adds the missing preamble
> >> >> then one gets an error. Some how your new code breaks the calculation
> >> >> for number of columns.
> >> >>
> >> >> -Hamid
> >> >
> >> > He forgot only to put a \NC before the \AR.
> >>
> >> Sorry about that. I thought I pasted from a correctly running example.
> >>
> >> Here is another attempt, which I feel is the cleanest way to go about
> >> this whole thing. Right now the skip between the columns is not
> >> configurable, but it should be possible to use the get the value of
> >> the skip.
> >>
> >> The attached code typesets an example that Wolfgang had sent off-list.
> >> I have only changed two lines of the table.tex.
> >>
> >> Aditya
> >
> > Hi Aditya,
> >
> > what do you think about
> >
> > \setuptables
> >  [\c!columndistance=2em]
>
> This goes against the way I understand table macros. With this, you can
> only have equal width columns. In tables, you can specify specific
> widths of specific s and o keys.

look into the tabsatz and boktabs manual and you see all columns in them
have the same distance, it was only meant as a alternative to your hard coded
columndistance in the examples.

If you can do this with another method like the tabskip there nothing
against them.

Wolfgang

> AFAIU, the table macros divide that the specified tabskip by 2, and
> place it in the data column. Since the rule column comes next, the rule
> column automatically gets the same tabskip, so in appearance we the
> specified column width.
>
> This is also the reason why cmidrules do not work. If you specify a
> hrule inside a data column, it spans half of the visual space between
> the columns. What needs to be done is that the glue be added inside a
> local group to the rule column, with the global tabskip set to zero.
>
> The previous solution that I posted adds a 2em tabskip glue to the rule
> column, and a 0pt tabskip glue to the data column. After thinking again
> about it, I think that this is not the right way. There is no need to
> add a 0pt glue to the data column. We can add the glue to the rule
> column inside a group.
>
> I will see if I can get this working.
>
> Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-06  1:13   ` Aditya Mahajan
@ 2007-08-11 21:05     ` Patrick Gundlach
  0 siblings, 0 replies; 14+ messages in thread
From: Patrick Gundlach @ 2007-08-11 21:05 UTC (permalink / raw)
  To: ntg-context

Hi,

>> Is there something like \arraystretch(?) which is a factor that every
>> vertical whitespace in a table is multiplied with? 

> If you are happy with an integer scaling, [...]

cool, this is very nice!

Thanks,

Patrick
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Booktabs equivalent in Context
  2007-08-09  7:43         ` Aditya Mahajan
  2007-08-09  8:56           ` Wolfgang Schuster
@ 2007-08-11 21:05           ` Patrick Gundlach
  1 sibling, 0 replies; 14+ messages in thread
From: Patrick Gundlach @ 2007-08-11 21:05 UTC (permalink / raw)
  To: ntg-context

Hi,

> Here is another attempt, which I feel is the cleanest way to go about
> this whole thing. Right now the skip between the columns is not
> configurable, but it should be possible to use the get the value of
> the skip.

I'd love to see a cmidrule from column n to column m where n + 1 > m
and then trimmed right.

I know, I know, I am demanding, but since we're at it :-)

Perhaps Hans has a solution in his magic bag.

Patrick
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-08-11 21:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-03 21:10 Booktabs equivalent in Context Aditya Mahajan
2007-08-04  7:28 ` Patrick Gundlach
2007-08-06  1:13   ` Aditya Mahajan
2007-08-11 21:05     ` Patrick Gundlach
2007-08-08 12:03 ` Johannes Graumann
2007-08-08 22:23   ` Aditya Mahajan
2007-08-09  5:06     ` Hamid Kamrani
2007-08-09  6:43       ` Wolfgang Schuster
2007-08-09  7:43         ` Aditya Mahajan
2007-08-09  8:56           ` Wolfgang Schuster
2007-08-09 16:14             ` Aditya Mahajan
2007-08-10  5:44               ` Wolfgang Schuster
2007-08-11 21:05           ` Patrick Gundlach
2007-08-09 16:01         ` Hamid Kamrani

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).