ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Lars Huttar <lars_huttar@sil.org>
To: ntg-context@ntg.nl
Cc: Keami Hung <keami_hung@sil.org>
Subject: Re: how to get thick and thin borders working in tables (ConTeXt)
Date: Tue, 09 Dec 2008 14:01:56 -0600	[thread overview]
Message-ID: <493ECEB4.7030305@sil.org> (raw)
In-Reply-To: <87C60F58-5C30-4154-BFC7-FCB1F2375C17@gmail.com>

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
___________________________________________________________________________________


  parent reply	other threads:[~2008-12-09 20:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-09 16:48 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=493ECEB4.7030305@sil.org \
    --to=lars_huttar@sil.org \
    --cc=keami_hung@sil.org \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).