5

I am struggling with my table formatting a bit and hope there is someone around here that can give me some help.

This is the table I have at the moment.

\bTABLE
    \startTABLEhead
        \bTR \bTD No. \eTD \bTD[nc=2] Length              \eTD \eTR
        \bTR \bTD               \bTD [m] \eTD \bTD [inch] \eTD \eTR
    \stopTABLEhead
    \startTABLEbody
        \bTR \bTD 1.  \eTD \bTD 1        \eTD \bTD 25.4   \eTD \eTR
    \stopTABLEbody
\eTABLE

now I want a rule on top of the first row and on the bottom of the second row. That's simple enough only I would like to do this by using something like this

\setupTABLE[frame=off]
\setupTABLE[header][first][topframe=on]
\setupTABLE[header][last][bottomframe=on]

This way I can use this setup on all the tables in my document.

Can this be done?

user14644
  • 139

1 Answers1

4

\setupTABLE{header] does not accept first or last keys. You can only use \setupTABLE[header][1] etc, but that sets the style for the 1st column of the header. Currently, there is no way to set the style of the rows of the table header.

However, it is easy to define your own Metapost background that adds topframe and bottomframe to the table header and works with multipage tables.

\setupTABLE[frame=off]
\setupTABLE[header][each][background=tableheader, framecolor=darkblue, rulethickness=2bp]

\defineoverlay[tableheader][\useMPgraphic{tableheader}]

\startuseMPgraphic{tableheader}
    if \positiverow = 1 : % first row
        draw topboundary OverlayBox 
    elseif \positiverow = \noftblheadlines : % last row
        draw bottomboundary OverlayBox
    fi 
        withcolor OverlayLineColor
        withpen pensquare scaled OverlayLineWidth;

    setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\starttext
\bTABLE[split=repeat]
    \startTABLEhead
        \bTR \bTD No. \eTD \bTD[nc=2] Length         \eTD \eTR
        \bTR \bTD     \eTD \bTD{} [m] \eTD \bTD{} [inch] \eTD \eTR
    \stopTABLEhead
    \startTABLEbody
        \dorecurse{100}
        {\bTR \bTD 1.  \eTD \bTD 1        \eTD \bTD 25.4   \eTD \eTR}
    \stopTABLEbody
\eTABLE
\stoptext

enter image description here

Aditya
  • 62,301