ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] How to specify a default formatting for TABLE
@ 2024-07-01 21:56 Gerion Entrup
  2024-07-01 22:17 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Gerion Entrup @ 2024-07-01 21:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1719 bytes --]

Hi,

I want to format a bunch a tables with the same formatting.
It seems that specifying the \setupTABLE commands as part of the preamble works.

However, I need some tables that are formatted in another way.
Is there a generic way to specify this?

Here is a MWE:
```
\setupTABLE[frame=off, offset=2pt]
\setupTABLE[row][first][topframe=on, bottomframe=on, style=bf]
\setupTABLE[row][last][bottomframe=on]
\setupTABLE[row][even][background=color,backgroundcolor=red]

\setupcolors[state=start]

\starttext

A table:\\
\bTABLE
	\bTR \bTD head1 \eTD \bTD head2 \eTD \eTR
	\bTR \bTD data1 \eTD \bTD data2 \eTD \eTR
	\bTR \bTD data3 \eTD \bTD data4 \eTD \eTR
\eTABLE
\blank[line]

Another table with the same format:\\
\bTABLE
	\bTR \bTD head1 \eTD \bTD head2 \eTD \eTR
	\bTR \bTD data1 \eTD \bTD data2 \eTD \eTR
	\bTR \bTD data3 \eTD \bTD data4 \eTD \eTR
\eTABLE
\blank[line]

This table should be formatted in another way (actually not formatted):\\
\bTABLE
	\setupTABLE[row][each][topframe=off, bottomframe=off, style=, background=]
	\bTR \bTD head1 \eTD \bTD head2 \eTD \eTR
	\bTR \bTD data1 \eTD \bTD data2 \eTD \eTR
	\bTR \bTD data3 \eTD \bTD data4 \eTD \eTR
\eTABLE
\blank[line]

This does not work either:\\
{
\setupTABLE[row][each][topframe=off, bottomframe=off, style=, background=]
% \setupTABLE[row][1,2,3][topframe=off, bottomframe=off, style=, background=] % this deactivates the color at least
\bTABLE
	\bTR \bTD head1 \eTD \bTD head2 \eTD \eTR
	\bTR \bTD data1 \eTD \bTD data2 \eTD \eTR
	\bTR \bTD data3 \eTD \bTD data4 \eTD \eTR
\eTABLE
}

\stoptext
```

The last two tables should be formatted as if the four setupTABLE commands in the header are not existent.
My solution does not work, however.

Gerion

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: How to specify a default formatting for TABLE
  2024-07-01 21:56 [NTG-context] How to specify a default formatting for TABLE Gerion Entrup
@ 2024-07-01 22:17 ` Wolfgang Schuster
  2024-07-01 22:23   ` Gerion Entrup
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2024-07-01 22:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Gerion Entrup

Gerion Entrup schrieb am 01.07.2024 um 23:56:
> Hi,
> 
> I want to format a bunch a tables with the same formatting.
> It seems that specifying the \setupTABLE commands as part of the preamble works.
> 
> However, I need some tables that are formatted in another way.
> Is there a generic way to specify this?
> 
> Here is a MWE:
> [...]
> 
> The last two tables should be formatted as if the four setupTABLE commands in the header are not existent.
> My solution does not work, however.

1. Put your table settings in a setups-block and load the one you want 
at the start of your table.

2. You don't need \setupcolors[state=start] because colors are enabled 
by default (since a veee...eeery long time).

3. You can replace \bTD ... \eTD with \bTH ... \eTH for table headers to 
get bold text.

%%%% begin example
\startsetups[table:a]
   \setupTABLE [each] [frame=off,width=1cm,height=1cm,align={middle,lohi}]
   \setupTABLE [each] [background=color,backgroundcolor=lightgray]
\stopsetups

\startsetups[table:b]
   \setupTABLE [each] 
[frame=off,width=2cm,height=1.2\lineheight,align=middle]
   \setupTABLE [each] [topframe=on,bottomframe=on]
\stopsetups

\starttext

\bTABLE
   \bTR
     \bTD A \eTD
     \bTD B \eTD
   \eTR
   \bTR
     \bTD C \eTD
     \bTD D \eTD
   \eTR
\eTABLE

\blank

\bTABLE[setups=table:a]
   \bTR
     \bTD A \eTD
     \bTD B \eTD
   \eTR
   \bTR
     \bTD C \eTD
     \bTD D \eTD
   \eTR
\eTABLE

\blank

\bTABLE[setups=table:b]
   \bTR
     \bTD A \eTD
     \bTD B \eTD
   \eTR
   \bTR
     \bTD C \eTD
     \bTD D \eTD
   \eTR
\eTABLE

\stoptext
%%%% end example

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: How to specify a default formatting for TABLE
  2024-07-01 22:17 ` [NTG-context] " Wolfgang Schuster
@ 2024-07-01 22:23   ` Gerion Entrup
  0 siblings, 0 replies; 3+ messages in thread
From: Gerion Entrup @ 2024-07-01 22:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Wolfgang Schuster


[-- Attachment #1.1: Type: text/plain, Size: 2015 bytes --]

Am Dienstag, 2. Juli 2024, 00:17:36 MESZ schrieb Wolfgang Schuster:
> Gerion Entrup schrieb am 01.07.2024 um 23:56:
> > Hi,
> > 
> > I want to format a bunch a tables with the same formatting.
> > It seems that specifying the \setupTABLE commands as part of the preamble works.
> > 
> > However, I need some tables that are formatted in another way.
> > Is there a generic way to specify this?
> > 
> > Here is a MWE:
> > [...]
> > 
> > The last two tables should be formatted as if the four setupTABLE commands in the header are not existent.
> > My solution does not work, however.
> 
> 1. Put your table settings in a setups-block and load the one you want 
> at the start of your table.
> 
> 2. You don't need \setupcolors[state=start] because colors are enabled 
> by default (since a veee...eeery long time).
> 
> 3. You can replace \bTD ... \eTD with \bTH ... \eTH for table headers to 
> get bold text.
> 
> %%%% begin example
> \startsetups[table:a]
>    \setupTABLE [each] [frame=off,width=1cm,height=1cm,align={middle,lohi}]
>    \setupTABLE [each] [background=color,backgroundcolor=lightgray]
> \stopsetups
> 
> \startsetups[table:b]
>    \setupTABLE [each] 
> [frame=off,width=2cm,height=1.2\lineheight,align=middle]
>    \setupTABLE [each] [topframe=on,bottomframe=on]
> \stopsetups
> 
> \starttext
> 
> \bTABLE
>    \bTR
>      \bTD A \eTD
>      \bTD B \eTD
>    \eTR
>    \bTR
>      \bTD C \eTD
>      \bTD D \eTD
>    \eTR
> \eTABLE
> 
> \blank
> 
> \bTABLE[setups=table:a]
>    \bTR
>      \bTD A \eTD
>      \bTD B \eTD
>    \eTR
>    \bTR
>      \bTD C \eTD
>      \bTD D \eTD
>    \eTR
> \eTABLE
> 
> \blank
> 
> \bTABLE[setups=table:b]
>    \bTR
>      \bTD A \eTD
>      \bTD B \eTD
>    \eTR
>    \bTR
>      \bTD C \eTD
>      \bTD D \eTD
>    \eTR
> \eTABLE
> 
> \stoptext
> %%%% end example
> 
> Wolfgang

Thank you very much! That are a bunch of nice tricks. The setups environment is really powerful.
I will actively search for this keyword in the documentation next time.

Gerion




[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2024-07-01 22:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-01 21:56 [NTG-context] How to specify a default formatting for TABLE Gerion Entrup
2024-07-01 22:17 ` [NTG-context] " Wolfgang Schuster
2024-07-01 22:23   ` Gerion Entrup

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