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
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
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
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
___________________________________________________________________________________
Quoting Johannes Graumann
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
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
Quoting Johannes Graumann
: 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 ___________________________________________________________________________________
2007/8/9, Hamid Kamrani
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
wrote: Quoting Johannes Graumann
: 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 ___________________________________________________________________________________
On Thu, 9 Aug 2007, Wolfgang Schuster wrote:
2007/8/9, Hamid Kamrani
: 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
2007/8/9, Aditya Mahajan
On Thu, 9 Aug 2007, Wolfgang Schuster wrote:
2007/8/9, Hamid Kamrani
: 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
Quoting Wolfgang Schuster
2007/8/9, Aditya Mahajan
: On Thu, 9 Aug 2007, Wolfgang Schuster wrote:
2007/8/9, Hamid Kamrani
: 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
2007/8/9, Aditya Mahajan
Quoting Wolfgang Schuster
: 2007/8/9, Aditya Mahajan
: On Thu, 9 Aug 2007, Wolfgang Schuster wrote:
2007/8/9, Hamid Kamrani
: 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
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
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
2007/8/9, Hamid Kamrani
: 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
wrote: Quoting Johannes Graumann
: 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 ___________________________________________________________________________________
participants (5)
-
Aditya Mahajan
-
Hamid Kamrani
-
Johannes Graumann
-
Patrick Gundlach
-
Wolfgang Schuster