Auto width and height on table cells
Hello, I want some tables to occupy 100% of \textwidth and \textheight and for all columns to be the same width except one or two that I want to specify and for all rows to be the same height except for one or two, that I want to specify as well.. For the moment, I'm doing it "manually", calculating column width as (\textwidth - width of fixed columns) / # rest of columns and row height as (\textheight - height of fixed rows) / # rest of rows I'm getting the result that I want, but it's a bit tedious. Is it possible to have ConTeXt do all those calculations for me? I haven't been able to figure it out from the manuals and the wiki. Thank you in advance. Regards, Ángel
On 6/30/2022 7:43 AM, Angel M Alganza via ntg-context wrote:
Hello,
I want some tables to occupy 100% of \textwidth and \textheight and for all columns to be the same width except one or two that I want to specify and for all rows to be the same height except for one or two, that I want to specify as well.. For the moment, I'm doing it "manually", calculating column width as
(\textwidth - width of fixed columns) / # rest of columns
and row height as
(\textheight - height of fixed rows) / # rest of rows
I'm getting the result that I want, but it's a bit tedious.
Is it possible to have ConTeXt do all those calculations for me? I haven't been able to figure it out from the manuals and the wiki. \starttext
\startxtable[option=stretch] \startxrow \startxcell[width=3cm,option=fixed] one \stopxcell \startxcell two \stopxcell \startxcell three \stopxcell \stopxrow \startxrow \startxcell a \stopxcell \startxcell b \stopxcell \startxcell c \stopxcell \stopxrow \stopxtable \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hello, Hans, On Thu, Jun 30, 2022 at 08:16:53AM +0200, Hans Hagen via ntg-context wrote:
\startxtable[option=stretch] \startxrow \startxcell[width=3cm,option=fixed] one \stopxcell
Thank you very much, that does part of the trick (the column width). Is there a way to do the same for the row height, please? I never looked at xtables, since the wiki says they're used for tables that need to span several pages, which I don't need. Cheers, Ángel
Am 30.06.22 um 08:40 schrieb Angel M Alganza via ntg-context:
Hello, Hans,
On Thu, Jun 30, 2022 at 08:16:53AM +0200, Hans Hagen via ntg-context wrote:
\startxtable[option=stretch] \startxrow \startxcell[width=3cm,option=fixed] one \stopxcell
Thank you very much, that does part of the trick (the column width). Is there a way to do the same for the row height, please?
I never looked at xtables, since the wiki says they're used for tables that need to span several pages, which I don't need.
They’re also tedious, because you can’t setup rows/columns in advance (like \setupTABLE) – or did that change? Hraban
On 6/30/2022 9:22 AM, Angel M Alganza via ntg-context wrote:
Hi Henning,
On Thu, Jun 30, 2022 at 09:02:28AM +0200, Henning Hraban Ramm via ntg-context wrote:
They’re also tedious, because you can’t setup rows/columns in advance (like \setupTABLE) – or did that change?
I'm afraid you're right. You're joking right? SInce when can one not set up something in some context subsystem? Why would I make a table mechanism with no presets?
\starttext \setupxtable[suffix][align=middle,foregroundcolor=red] \setupxtable[blabla][foregroundstyle=slanted] \setupxtable[crap] [foregroundcolor=blue] \setupxtable[bold] [crap][foregroundstyle=bold] \startxtable[frame=off] \startxtablehead \startxrow[bold] \startxcell[suffix] a 0 \stopxcell \startxcell[blabla] a 1 \stopxcell \startxcell a 2 \stopxcell \stopxrow \stopxtablehead \startxtablebody \startxrow \startxcell[suffix][ny=2] a 1 \stopxcell \startxcell b 1 \stopxcell \startxcell c 1 \stopxcell \stopxrow \startxrow \startxcell b 2 \stopxcell \startxcell c 2 \stopxcell \stopxrow \startxrow \startxcell[suffix] a 3 \stopxcell \startxcell b 3 \stopxcell \startxcell c 3 \stopxcell \stopxrow \startxrow \startxcell[suffix] a 4 \stopxcell \startxcell b 4 \stopxcell \startxcell c 4 \stopxcell \stopxrow \startxrow \startxcell[suffix] a 5 \stopxcell \startxcell b 5 \stopxcell \startxcell c 5 \stopxcell \stopxrow \stopxtablebody \stopxtable \stoptext It's just more symbolic than in natural tables (which is better performance wise). I'm pretty sure it's mentioned in some manual. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Thu, Jun 30, 2022 at 09:36:07AM +0200, Hans Hagen via ntg-context wrote:
You're joking right? SInce when can one not set up something in some context subsystem? Why would I make a table mechanism with no presets?
I see! :-)
It's just more symbolic than in natural tables (which is better performance wise). I'm pretty sure it's mentioned in some manual.
I didn't see it in the wiki and I thought it didn't exist. How about the auto row height? That'd be the only thing I'm missing. Thanks so much. Ángel
On Thu, Jun 30, 2022 at 09:36:07AM +0200, Hans Hagen via ntg-context wrote:
You're joking right? SInce when can one not set up something in some context subsystem? Why would I make a table mechanism with no presets?
I see! :-)
It's just more symbolic than in natural tables (which is better performance wise). I'm pretty sure it's mentioned in some manual.
I didn't see it in the wiki and I thought it didn't exist.
How about the auto row height? That'd be the only thing I'm missing. we don't have it for the vertical direction ... you can remind me later
On 6/30/2022 9:46 AM, Angel M Alganza via ntg-context wrote: this year (to see if it is doable) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hi again, Hans, On Thu, Jun 30, 2022 at 10:26:58AM +0200, Hans Hagen via ntg-context wrote:
How about the auto row height? That'd be the only thing I'm missing. we don't have it for the vertical direction ... you can remind me later this year (to see if it is doable)
Ah, OK. Thank you! :-) Cheers, Ángel
On 6/30/22 09:46, Angel M Alganza via ntg-context wrote:
[...] How about the auto row height? That'd be the only thing I'm missing.
Hi Ángel, I’m not sure whether I’m totally missing your point, but I think this is a way that might achieve what you want: \starttext \showframe \startbuffer row\currentxtablerow--col\currentxtablecolumn \stopbuffer \startbuffer[table] \startxtable[option={stretch, height}, align={lohi, middle}] \startxrow \startxcell[width=3cm, option=fixed]\inlinebuffer\stopxcell \dorecurse{5} {\startxcell\inlinebuffer\stopxcell} \stopxrow \startxrow \startxcell[height=3cm, option=fixed]\inlinebuffer\stopxcell \dorecurse{5} {\startxcell\inlinebuffer\stopxcell} \stopxrow \dorecurse{5} {\startxrow \dorecurse{6} {\startxcell\inlinebuffer\stopxcell} \stopxrow} \stopxtable \stopbuffer \getbuffer[table] \page \setuppapersize[A3, landscape] \getbuffer[table] \stoptext Just in case it helps, Pablo
Hi Pablo, On Thu, Jun 30, 2022 at 04:15:10PM +0200, Pablo Rodriguez via ntg-context wrote:
I’m not sure whether I’m totally missing your point, but I think this is a way that might achieve what you want:
No, you aren't, and it almost does it, except when the fixed width column is other than the first one, I'm afraid. ¡Muchas gracias! Ángel
On 6/30/22 18:10, Angel M Alganza via ntg-context wrote:
[...] No, you aren't, and it almost does it, except when the fixed width column is other than the first one, I'm afraid.
Hi Ángel, there might be a way to get it, as long as you don’t define height directly, such as in: \starttext \showframe \startbuffer row\currentxtablerow--col\currentxtablecolumn \stopbuffer \startbuffer[table] \startxtable[option={stretch, height}, align={lohi, middle}] \startxrow \dorecurse{5} {\startxcell[width=.115\textwidth]\inlinebuffer\stopxcell} \startxcell\inlinebuffer\stopxcell \stopxrow \startxrow \dorecurse{5} {\startxcell\inlinebuffer\stopxcell} \startxcell[offset=1em]\input zapf\stopxcell \stopxrow \dorecurse{5} {\startxrow \dorecurse{6} {\startxcell\inlinebuffer\stopxcell} \stopxrow} \stopxtable \stopbuffer \getbuffer[table] \page \setuppapersize[A3, landscape] \getbuffer[table] \stoptext Again, just in case it helps, Pablo
Am 30.06.22 um 09:36 schrieb Hans Hagen via ntg-context:
On 6/30/2022 9:22 AM, Angel M Alganza via ntg-context wrote:
They’re also tedious, because you can’t setup rows/columns in advance (like \setupTABLE) – or did that change?
I'm afraid you're right. You're joking right? SInce when can one not set up something in some context subsystem? Why would I make a table mechanism with no presets?
Yes, presets are nice, and I appreciate the better performance, but if I can setup stuff like striped tables or some other “advanced” formatting without explicite settings within the table, I prefer that. I can stay with “natural tables” (and “tabulate” for easy cases), but the auto-stretching of rows or whole tables _is_ missing. Unfortunately, this is a situation like in LaTeX: We have a choice of table “packages”, but none of them covers my most common use cases. Hraban
Hi again, On Thu, Jun 30, 2022 at 12:12:07PM +0200, Henning Hraban Ramm via ntg-context wrote:
I can stay with “natural tables” (and “tabulate” for easy cases), but the auto-stretching of rows or whole tables _is_ missing.
I'm going back, too, I think.
Unfortunately, this is a situation like in LaTeX: We have a choice of table “packages”, but none of them covers my most common use cases.
Same here.
participants (4)
-
Angel M Alganza
-
Hans Hagen
-
Henning Hraban Ramm
-
Pablo Rodriguez