ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* how to get thick and thin borders working in tables (ConTeXt)
@ 2008-12-09 16:48 Lars Huttar
  2008-12-09 17:12 ` Aditya Mahajan
       [not found] ` <87C60F58-5C30-4154-BFC7-FCB1F2375C17@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Lars Huttar @ 2008-12-09 16:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Keami Hung

Hello,

We are using ConTeXt (with XeTeX engine) to typeset some tables that
have borders (rules) between cells.

In the previous edition of the book (which was not done in TeX), some of
the lines between table cells were double, others single. This was done
to show grouping of columns and rows. We have been told that in TeX, or
at least in ConTeXt, you can't do double rules (we'd be happy to be
corrected on that point), so we have been trying to use thick and thin
lines to show grouping.

Thick or thin lines work fine if applied to whole tables or whole cells,
but when there are cells with thick rules on some sides and thin rules
on other sides, it gets confused.

For example, we tried
(a)	\setupTABLE[c][4][leftframe=on,rulethickness=0.5mm]
to set the left border of the fourth column to be thick. This worked.
But then if we use
(b)	\setupTABLE[c][4][rightframe=on,rulethickness=0.25mm]
to set the right border of the same column to be thin, it overrides the
thickness of both left and right borders, so setting (a) is lost.

In other words, we can't seem to get a given cell to have a thick border
on one side and a thin border on the other side. (Well, we could fake it
in some cases by setting rulethickness for an adjacent cell, but that
adjacent cell would then have to have thick borders on all sides.)

Does anybody know if it's possible to do this in ConTeXt? or in TeX?

Thanks for any ideas,
Lars

P.S.
Incidentally, if you set the bottom border of row 1 and the top border
of row 2 each to be thick, the result is additive: you get a
doubly-thick border.


___________________________________________________________________________________
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] 6+ messages in thread

* Re: how to get thick and thin borders working in tables (ConTeXt)
  2008-12-09 16:48 how to get thick and thin borders working in tables (ConTeXt) Lars Huttar
@ 2008-12-09 17:12 ` Aditya Mahajan
       [not found] ` <87C60F58-5C30-4154-BFC7-FCB1F2375C17@gmail.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Aditya Mahajan @ 2008-12-09 17:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Keami Hung

On Tue, 9 Dec 2008, Lars Huttar wrote:

> Hello,
>
> We are using ConTeXt (with XeTeX engine) to typeset some tables that
> have borders (rules) between cells.
>
> In the previous edition of the book (which was not done in TeX), some of
> the lines between table cells were double, others single. This was done
> to show grouping of columns and rows. We have been told that in TeX, or
> at least in ConTeXt, you can't do double rules (we'd be happy to be
> corrected on that point),

Have you tried using metapost backgrounds? See 
http://www.pragma-ade.com/general/manuals/enattab.pdf

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] 6+ messages in thread

* Re: how to get thick and thin borders working in tables (ConTeXt)
       [not found] ` <87C60F58-5C30-4154-BFC7-FCB1F2375C17@gmail.com>
@ 2008-12-09 20:01   ` Lars Huttar
  2008-12-10  6:07     ` Lars Huttar
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Huttar @ 2008-12-09 20:01 UTC (permalink / raw)
  To: ntg-context; +Cc: Keami Hung

On 12/9/2008 12:04 PM, Wolfgang Schuster wrote:
>
> Am 09.12.2008 um 17:48 schrieb Lars Huttar:
>
>> Hello,
>>
>> We are using ConTeXt (with XeTeX engine) to typeset some tables that
>> have borders (rules) between cells.
>>
>> In the previous edition of the book (which was not done in TeX), some of
>> the lines between table cells were double, others single. This was done
>> to show grouping of columns and rows. We have been told that in TeX, or
>> at least in ConTeXt, you can't do double rules (we'd be happy to be
>> corrected on that point), so we have been trying to use thick and thin
>> lines to show grouping.
>>
>> Thick or thin lines work fine if applied to whole tables or whole cells,
>> but when there are cells with thick rules on some sides and thin rules
>> on other sides, it gets confused.
>>
>> For example, we tried
>> (a)    \setupTABLE[c][4][leftframe=on,rulethickness=0.5mm]
>> to set the left border of the fourth column to be thick. This worked.
>> But then if we use
>> (b)    \setupTABLE[c][4][rightframe=on,rulethickness=0.25mm]
>> to set the right border of the same column to be thin, it overrides the
>> thickness of both left and right borders, so setting (a) is lost.
>>
>> In other words, we can't seem to get a given cell to have a thick border
>> on one side and a thin border on the other side. (Well, we could fake it
>> in some cases by setting rulethickness for an adjacent cell, but that
>> adjacent cell would then have to have thick borders on all sides.)
>>
>> Does anybody know if it's possible to do this in ConTeXt? or in TeX?
>>
>> Thanks for any ideas,
>> Lars
>>
>> P.S.
>> Incidentally, if you set the bottom border of row 1 and the top border
>> of row 2 each to be thick, the result is additive: you get a
>> doubly-thick border.
>
> I can provide a patch for ConTeXt to draw rules with different
> thickness on each side but I can't assure it will work in the future.
>
> With metapost you can nearly all types of borders you want.
>
> \startuseMPgraphic{table:frame:double}
> draw OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ; % outer frame
> draw OverlayBox enlarged -2pt ;                            % inner frame
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
>
> \startuseMPgraphic{table:frame:all}
> draw OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
>
> \startuseMPgraphic{table:frame:left}
> linecap := squared ;
> draw leftboundary OverlayBox withpen pencircle scaled 2 ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
>
> \startuseMPgraphic{table:frame:right}
> linecap := squared ;
> draw rightboundary OverlayBox withpen pencircle scaled 2 ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
>
> \startuseMPgraphic{table:frame:top}
> linecap := squared ;
> draw topboundary OverlayBox withpen pencircle scaled 2 ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
>
> \startuseMPgraphic{table:frame:bottom}
> linecap := squared ;
> draw bottomboundary OverlayBox withpen pencircle scaled 2 ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
>
> \defineoverlay[table:frame:double][\useMPgraphic{table:frame:double}]
>
> \defineoverlay[table:frame:all]   [\useMPgraphic{table:frame:all}]
> \defineoverlay[table:frame:left]  [\useMPgraphic{table:frame:left}]
> \defineoverlay[table:frame:right] [\useMPgraphic{table:frame:right}]
> \defineoverlay[table:frame:top]   [\useMPgraphic{table:frame:top}]
> \defineoverlay[table:frame:bottom][\useMPgraphic{table:frame:bottom}]
>
> \starttext
>
> \startbuffer
> \bTABLE[frame=off,offset=2ex]
>     \bTR
>         \bTD One   \eTD
>         \bTD Two   \eTD
>         \bTD Three \eTD
>     \eTR
>     \bTR
>         \bTD Four  \eTD
>         \bTD Five  \eTD
>         \bTD Six   \eTD
>     \eTR
>     \bTR
>         \bTD Seven \eTD
>         \bTD Eight \eTD
>         \bTD Nine  \eTD
>     \eTR
> \eTABLE
> \stopbuffer
>
> \start
> \setupTABLE[background={table:frame:double}]
> \getbuffer
> \stop
> \blank
>
> \start
> \setupTABLE[background={table:frame:all}]
> \setupTABLE[c][first][background={table:frame:all,table:frame:left}]
> \setupTABLE[c][last][background={table:frame:all,table:frame:right}]
> \setupTABLE[r][first][background={table:frame:all,table:frame:top}]
> \setupTABLE[r][last][background={table:frame:all,table:frame:bottom}]
> \setupTABLE[first][first][background={table:frame:all,table:frame:left,table:frame:top}] 
>
> \setupTABLE[last][first][background={table:frame:all,table:frame:right,table:frame:top}] 
>
> \setupTABLE[first][last][background={table:frame:all,table:frame:left,table:frame:bottom}] 
>
> \setupTABLE[last][last][background={table:frame:all,table:frame:right,table:frame:bottom}] 
>
> \getbuffer
> \stop
>
> \stoptext
>
> Wolfgang
>
>
>


Thanks for the very detailed example!
We should be able to apply this to our document.

I'm copying it to the list because I think it would be valuable for 
posterity.

Thanks to Aditya too for the reply.

Regards,
Lars


-- 

Lars Huttar

___________________________________________________________________________________
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] 6+ messages in thread

* Re: how to get thick and thin borders working in tables (ConTeXt)
  2008-12-09 20:01   ` Lars Huttar
@ 2008-12-10  6:07     ` Lars Huttar
       [not found]       ` <115224fb0812100205lbff5fd8hba319b31e143ef70@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Huttar @ 2008-12-10  6:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Keami Hung

On 12/9/2008 2:01 PM, Lars Huttar wrote:
> On 12/9/2008 12:04 PM, Wolfgang Schuster wrote:

We applied your example to our document, and were able to get it working
with thick and thin lines. Thanks very much!

Now since you included double lines in your example, I've been aspiring
to use that instead of just thick lines...

>>
>> \startuseMPgraphic{table:frame:double}
>> draw OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ; % outer frame
>> draw OverlayBox enlarged -2pt ;                            % inner frame
>> setbounds currentpicture to OverlayBox ;
>> \stopuseMPgraphic

OK... the above results in triple lines between cells, so I modified the
draw OverlayBox lines as follows:

draw OverlayBox enlarged \the\dimexpr\linewidth*1\relax ; % outer frame
draw OverlayBox enlarged -\the\dimexpr\linewidth*2\relax ; % inner frame

This was mainly experimental, as I don't fully understand the model.
(I looked up some Metapost references but couldn't find a definition of
"enlarged".) But it seems to work: the double lines between two cells
overlap exactly, so you get a consistent look.

However, when I try to mix double frames with single frames, I'm having
trouble. Here is what I tried, in order to get a cell with double frame
on the left, and single frame everywhere else:

\startuseMPgraphic{table:frame:Lrtb} % left border is double
draw leftboundary OverlayBox enlarged \the\dimexpr\linewidth*1\relax ; %
outer frame
draw leftboundary OverlayBox enlarged -\the\dimexpr\linewidth*2\relax ;
% inner frame
draw rightboundary OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ;
draw topboundary OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ;
draw bottomboundary OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

Now the graphic has double line on the left and a single line elsewhere.
However, the lines are thicker than in the previous one... about twice
as thick, too heavy for our requirements. And I can't tell why. This is
true on all four sides.
See http://www.huttar.net/lars-kathy/tmp/test-mp-tableframe.pdf, second
table.

Also, on the side that has double lines, the double lines don't go all
the way to the top and bottom (see same pdf, second table), so that the
double line is not continuous across multiple rows.

Any suggestions?

The above graphic is used as follows...
\start
\setupTABLE[c][first][background={table:frame:Lrtb}]
\getbuffer
\stop


Thanks,
Lars


___________________________________________________________________________________
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] 6+ messages in thread

* Re: how to get thick and thin borders working in tables (ConTeXt)
       [not found]       ` <115224fb0812100205lbff5fd8hba319b31e143ef70@mail.gmail.com>
@ 2008-12-11 17:05         ` Lars Huttar
       [not found]           ` <B39B1A46-0F5B-40A6-AA56-FD7D72709566@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Huttar @ 2008-12-11 17:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/10/2008 4:05 AM, Wolfgang Schuster wrote:
> On Wed, Dec 10, 2008 at 7:07 AM, Lars Huttar <lars_huttar@sil.org> wrote:
...
>> However, when I try to mix double frames with single frames, I'm having
>> trouble. Here is what I tried, in order to get a cell with double frame
>> on the left, and single frame everywhere else:
>>
>> \startuseMPgraphic{table:frame:Lrtb} % left border is double
>> draw leftboundary OverlayBox enlarged \the\dimexpr\linewidth*1\relax ; %
>> outer frame
>> draw leftboundary OverlayBox enlarged -\the\dimexpr\linewidth*2\relax ;
>> % inner frame
>> draw rightboundary OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ;
>> draw topboundary OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ;
>> draw bottomboundary OverlayBox enlarged -\the\dimexpr\linewidth/2\relax ;
>> setbounds currentpicture to OverlayBox ;
>> \stopuseMPgraphic
>>
>> Now the graphic has double line on the left and a single line elsewhere.
>> However, the lines are thicker than in the previous one... about twice
>> as thick, too heavy for our requirements. And I can't tell why. This is
>> true on all four sides.
>> See http://www.huttar.net/lars-kathy/tmp/test-mp-tableframe.pdf, second
>> table.
>>
>> Also, on the side that has double lines, the double lines don't go all
>> the way to the top and bottom (see same pdf, second table), so that the
>> double line is not continuous across multiple rows.
>>
>> Any suggestions?
>>
>> The above graphic is used as follows...
>> \start
>> \setupTABLE[c][first][background={table:frame:Lrtb}]
>> \getbuffer
>> \stop
> 
> \startuseMPgraphic{table:frame:all}
> draw OverlayBox enlarged -0.2 ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
> 
> \startuseMPgraphic{table:frame:leftdouble}
> draw OverlayBox leftenlarged 2 topenlarged -0.2 bottomenlarged -0.2
> rightenlarged -0.2 ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
> 
> \defineoverlay[table:frame:all][\useMPgraphic{table:frame:all}]
> \defineoverlay[table:frame:leftdouble][\useMPgraphic{table:frame:leftdouble}]
> 
> \starttext
> 
> \startbuffer
> \bTABLE[frame=off,offset=2ex]
>    \bTR
>        \bTD One   \eTD
>        \bTD Two   \eTD
>        \bTD Three \eTD
>    \eTR
>    \bTR
>        \bTD Four  \eTD
>        \bTD Five  \eTD
>        \bTD Six   \eTD
>    \eTR
>    \bTR
>        \bTD Seven \eTD
>        \bTD Eight \eTD
>        \bTD Nine  \eTD
>    \eTR
> \eTABLE
> \stopbuffer
> 
> \start
> \setupTABLE[background={table:frame:all}]
> \setupTABLE[c][first][background={table:frame:all,table:frame:leftdouble}]
> \getbuffer
> \stop
> 
> \stoptext
> 
> Wolfgang
> 

This fixes the problems I mentioned in my previous email. Thanks again
for that!

Unfortunately, when I generalize it, it takes us back to producing
triple borders between adjacent cells. I think this is inevitable when
overlaying a double frame (for certain sides) on top of a single frame
for all sides, because a double side overlaid on a single side cannot be
centered (or else the single line shows through separately from the
double line).

So my fix... which I'm posting here in hopes that someone may refine it,
and for the benefit of others who may attempt similar things... is to
center the double frames between the cells and avoid overlaying a double
frame side over a single frame side.

We center borders between the cells by using "enlarged" values -0.2 +/-
k, i.e. center around -0.2. I'm not sure why -0.2 works better than
zero, but it does... Doing this makes coincident border lines from
adjacent cells look like ordinary single lines instead of  being extra
thick. We settled on k = 0.6 to get the desired distance between our
double lines. Incidentally, I wish I knew how to put -0.2, 0.2-k, and
-0.2+k into variables or something so that they could all be changed in
one place, instead of hard-coded in many places. Maybe somebody can help
me there.

A cost of this single-overlay-per-cell approach is that we have to
specify individually the 16 possible overlays (combinations of single
and double edges) for any possible cell. But that's not too bad, as we
only have to define them once. (In practice, we also had to define a
couple of special cases where we needed some cells with open edges for a
"faked rowspan". We haven't completely got those working yet.)

An unexpected and potentially large benefit of this approach is that for
each cell, we only generate one MPgraphic (apparently because we only
use one overlay per cell), which should make the TeX run much faster,
and avoid running over the maxnumMPgraphics limit. With the
multiple-overlay-per-cell approach, we ended up using about 13,000
MPgraphics for our document, far beyond the default limit of 4000, and
taking 15 minutes to run compared to 37 seconds for a similar document
without the tables.

Here is our working system... hope it's helpful to somebody:

%%%% define MPgraphics for double-ruled tables
% Lars Huttar, 2008-12-09
% Thanks to Wolfgang Schuster on NTG-list

% Each MPgraph (and overlay) is named lrtb, with capitalized letters
indicating which sides are double-ruled.
% Adjacent cells must not define their common side differently, e.g. one
cell define it single and one side
% define it double; if that happens, it will appear triple (or a
triple-thick line).

% 0 double sides
\startuseMPgraphic{table:frame:lrtb} % all single
draw OverlayBox enlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

% 1 double side
\startuseMPgraphic{table:frame:Lrtb} % left double
draw OverlayBox leftenlarged  0.4 topenlarged -0.2 bottomenlarged -0.2
rightenlarged -0.2 ;
draw OverlayBox leftenlarged -0.8 topenlarged -0.2 bottomenlarged -0.2
rightenlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:lRtb} % right double
draw OverlayBox leftenlarged -0.2 topenlarged -0.2 bottomenlarged -0.2
rightenlarged -0.8 ;
draw OverlayBox leftenlarged -0.2 topenlarged -0.2 bottomenlarged -0.2
rightenlarged  0.4 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:lrTb} % top double
draw OverlayBox leftenlarged -0.2 topenlarged  0.4 bottomenlarged -0.2
rightenlarged -0.2 ;
draw OverlayBox leftenlarged -0.2 topenlarged -0.8 bottomenlarged -0.2
rightenlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:lrtB} % bottom double
draw OverlayBox leftenlarged -0.2 topenlarged -0.2 bottomenlarged  0.4
rightenlarged -0.2 ;
draw OverlayBox leftenlarged -0.2 topenlarged -0.2 bottomenlarged -0.8
rightenlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

% 2 double sides: adjacent
\startuseMPgraphic{table:frame:LrTb} % left, top double
draw OverlayBox leftenlarged -0.8 topenlarged -0.8 bottomenlarged -0.2
rightenlarged -0.2 ;
draw OverlayBox leftenlarged  0.4 topenlarged  0.4 bottomenlarged -0.2
rightenlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:lRTb} % right, top double
draw OverlayBox leftenlarged -0.2 topenlarged -0.8 bottomenlarged -0.2
rightenlarged -0.8 ;
draw OverlayBox leftenlarged -0.2 topenlarged  0.4 bottomenlarged -0.2
rightenlarged  0.4 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:LrtB} % left, bottom double
draw OverlayBox leftenlarged -0.8 topenlarged -0.2 bottomenlarged -0.8
rightenlarged -0.2 ;
draw OverlayBox leftenlarged  0.4 topenlarged -0.2 bottomenlarged  0.4
rightenlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:lRtB} % right, bottom double
draw OverlayBox leftenlarged -0.2 topenlarged -0.2 bottomenlarged -0.8
rightenlarged -0.8 ;
draw OverlayBox leftenlarged -0.2 topenlarged -0.2 bottomenlarged  0.4
rightenlarged  0.4 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

% 2 double sides: opposite
\startuseMPgraphic{table:frame:LRtb} % left, right double
draw OverlayBox leftenlarged -0.8 topenlarged -0.2 bottomenlarged -0.2
rightenlarged -0.8 ;
draw OverlayBox leftenlarged  0.4 topenlarged -0.2 bottomenlarged -0.2
rightenlarged  0.4 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:lrTB} % top, bottom double
draw OverlayBox leftenlarged -0.2 topenlarged -0.8 bottomenlarged -0.8
rightenlarged -0.2 ;
draw OverlayBox leftenlarged -0.2 topenlarged  0.4 bottomenlarged  0.4
rightenlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

% 3 double sides
\startuseMPgraphic{table:frame:LRTb} % left, top, right double
draw OverlayBox leftenlarged -0.8 topenlarged -0.8 bottomenlarged -0.2
rightenlarged -0.8 ;
draw OverlayBox leftenlarged  0.4 topenlarged  0.4 bottomenlarged -0.2
rightenlarged  0.4 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:LRtB} % left, bottom, right double
draw OverlayBox leftenlarged -0.8 topenlarged -0.2 bottomenlarged -0.8
rightenlarged -0.8 ;
draw OverlayBox leftenlarged  0.4 topenlarged -0.2 bottomenlarged  0.4
rightenlarged  0.4 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:LrTB} % left, top, bottom double
draw OverlayBox leftenlarged -0.8 topenlarged -0.8 bottomenlarged -0.8
rightenlarged -0.2 ;
draw OverlayBox leftenlarged  0.4 topenlarged  0.4 bottomenlarged  0.4
rightenlarged -0.2 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:lRTB} % right, top, bottom double
draw OverlayBox leftenlarged -0.2 topenlarged -0.8 bottomenlarged -0.8
rightenlarged -0.8 ;
draw OverlayBox leftenlarged -0.2 topenlarged  0.4 bottomenlarged  0.4
rightenlarged  0.4 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

% 4 double sides
\startuseMPgraphic{table:frame:LRTB} % all double
draw OverlayBox enlarged 0.4 ;
draw OverlayBox enlarged -0.8 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

% Special cases for 'fake' rowspans: three double sides and one open side
% Note that these do not look quite right: the borders are too thick
\startuseMPgraphic{table:frame:LRTO} % left, right, top double; bottom open
% draw OverlayBox leftenlarged -0.8 topenlarged -0.8 bottomenlarged 0.0
rightenlarged -0.8 ;
% draw OverlayBox leftenlarged  0.4 topenlarged  0.4 bottomenlarged 0.0
rightenlarged  0.4 ;
draw leftboundary OverlayBox enlarged 0.4;
draw rightboundary OverlayBox  enlarged 0.4 ;
draw topboundary OverlayBox  enlarged 0.4;
draw leftboundary OverlayBox enlarged -0.8;
draw rightboundary OverlayBox  enlarged -0.8 ;
draw topboundary OverlayBox  enlarged -0.8;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{table:frame:LROB} % left, right, bottom double; top open
% draw OverlayBox leftenlarged -0.8 topenlarged 0.0 bottomenlarged -0.8
rightenlarged -0.8 ;
% draw OverlayBox leftenlarged  0.4 topenlarged 0.0 bottomenlarged  0.4
rightenlarged  0.4 ;
draw leftboundary OverlayBox enlarged 0.4;
draw rightboundary OverlayBox  enlarged 0.4 ;
draw bottomboundary OverlayBox  enlarged 0.4;
draw leftboundary OverlayBox enlarged -0.8;
draw rightboundary OverlayBox  enlarged -0.8 ;
draw bottomboundary OverlayBox  enlarged -0.8;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic


%%%%% define overlays %%%%%
% 0 double sides
\defineoverlay[lrtb][\useMPgraphic{table:frame:lrtb}]
% 1 double side
\defineoverlay[Lrtb][\useMPgraphic{table:frame:Lrtb}]
\defineoverlay[lRtb][\useMPgraphic{table:frame:lRtb}]
\defineoverlay[lrTb][\useMPgraphic{table:frame:lrTb}]
\defineoverlay[lrtB][\useMPgraphic{table:frame:lrtB}]
% 2 double sides: adjacent
\defineoverlay[LrTb][\useMPgraphic{table:frame:LrTb}]
\defineoverlay[lRTb][\useMPgraphic{table:frame:lRTb}]
\defineoverlay[LrtB][\useMPgraphic{table:frame:LrtB}]
\defineoverlay[lRtB][\useMPgraphic{table:frame:lRtB}]
% 2 double sides: opposite
\defineoverlay[LRtb][\useMPgraphic{table:frame:LRtb}]
\defineoverlay[lrTB][\useMPgraphic{table:frame:lrTB}]
% 3 double sides
\defineoverlay[LRTb][\useMPgraphic{table:frame:LRTb}]
\defineoverlay[LRtB][\useMPgraphic{table:frame:LRtB}]
\defineoverlay[lRTB][\useMPgraphic{table:frame:lRTB}]
\defineoverlay[LrTB][\useMPgraphic{table:frame:LrTB}]
% 4 double sides
\defineoverlay[LRTB][\useMPgraphic{table:frame:LRTB}]
% Special cases for 'fake' rowspans
\defineoverlay[LRTO][\useMPgraphic{table:frame:LRTO}]
\defineoverlay[LROB][\useMPgraphic{table:frame:LROB}]


___________________________________________________________________________________
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] 6+ messages in thread

* Re: how to get thick and thin borders working in tables (ConTeXt)
       [not found]           ` <B39B1A46-0F5B-40A6-AA56-FD7D72709566@gmail.com>
@ 2008-12-11 22:39             ` Lars Huttar
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Huttar @ 2008-12-11 22:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/11/2008 3:24 PM, Wolfgang Schuster wrote:
> 
> Am 11.12.2008 um 18:05 schrieb Lars Huttar:
> 
>> We center borders between the cells by using "enlarged" values -0.2 +/-
>> k, i.e. center around -0.2. I'm not sure why -0.2 works better than
>> zero, but it does... Doing this makes coincident border lines from
>> adjacent cells look like ordinary single lines instead of  being extra
>> thick. We settled on k = 0.6 to get the desired distance between our
>> double lines. Incidentally, I wish I knew how to put -0.2, 0.2-k, and
>> -0.2+k into variables or something so that they could all be changed in
>> one place, instead of hard-coded in many places. Maybe somebody can help
>> me there.
> 
> \startMPinitializations
> numeric InnerFrame, MiddleFrame, OuterFrame ;
> InnerFrame  := 0.2 ;
> MiddleFrame := 0.4 ;
> OuterFrame  := 0.8 ;
> \stopMPinitializations

Makes sense.
Thanks... this will make the code clearer and more maintainable.


> % 1 double side
> \startuseMPgraphic{table:frame:Lrtb} % left double
> draw OverlayBox leftenlarged  MiddleFrame topenlarged -InnerFrame
>     bottomenlarged -InnerFrame rightenlarged -InnerFrame ;
> draw OverlayBox leftenlarged -OuterFrame topenlarged -InnerFrame
>     bottomenlarged -InnerFrame rightenlarged -InnerFrame ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
> 
>> An unexpected and potentially large benefit of this approach is that for
>> each cell, we only generate one MPgraphic (apparently because we only
>> use one overlay per cell), which should make the TeX run much faster,
>> and avoid running over the maxnumMPgraphics limit. With the
>> multiple-overlay-per-cell approach, we ended up using about 13,000
>> MPgraphics for our document, far beyond the default limit of 4000, and
>> taking 15 minutes to run compared to 37 seconds for a similar document
>> without the tables.
> 
> Use the 'nomprun' switch for texexec
> 
> texexec --nomprun --xtx file
> 
> ConTeXt collects now all graphics and process them after the TeX run.

Hmm... we tried this, but it doesn't seem to make any obvious difference.
Is this supposed to give a speed improvement? or get around the
maxnumMPgraphics limit?

Thanks again for your help.

Lars

___________________________________________________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2008-12-11 22:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-09 16:48 how to get thick and thin borders working in tables (ConTeXt) Lars Huttar
2008-12-09 17:12 ` Aditya Mahajan
     [not found] ` <87C60F58-5C30-4154-BFC7-FCB1F2375C17@gmail.com>
2008-12-09 20:01   ` Lars Huttar
2008-12-10  6:07     ` Lars Huttar
     [not found]       ` <115224fb0812100205lbff5fd8hba319b31e143ef70@mail.gmail.com>
2008-12-11 17:05         ` Lars Huttar
     [not found]           ` <B39B1A46-0F5B-40A6-AA56-FD7D72709566@gmail.com>
2008-12-11 22:39             ` Lars Huttar

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