Feature Request: xtables extensions
Dear devs, Natural Tables are quite handy but their syntax is a little verbose. \bTABLE \bTR \bTD ... \eTD \eTR \eTABLE There exist nice extensions which make the format less verbose by mapping \startTABLE \NC ... \NR\NR \stopTABLE back to the original macros. The new method for tables, called xtables, is faster and seems to have less problems than Natural Tables. However, the syntax is even more verbose \startxtable \startxrow \startxcell ... \stopxcell \stopxrow \stopxtable Can we have similar abbreviations as for Natural Tables? I am thinking of something like \startXTABLE \NC ... \NR\NR \stopXTABLE I tried myself rewriting tabl-nte.mkiv for xtables but it is not straightforward. What do you think of this proposal? Kind regards, Henri
I quickly came up with something myself. Unfortunately, it involves overloading of the original xtables. Perhaps there is a better way but it works. I am happy to hear your opinions! \unprotect % Overload tabl_x_start_table \unexpanded\def\tabl_x_start_table[#settings]% maybe two arguments: [tag][settings] | [tag] | [settings] {\bgroup \let\NC\tabl_xte_start_nc \let\NR\tabl_xte_start_nr \tabl_x_prepare{#settings}% \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process\zerocount} % xtable extensions \newconditional\c_tabl_xte_in_nc \unexpanded\def\tabl_xte_start_nr {\stopxrow \setfalse\c_tabl_xte_in_nc} \unexpanded\def\tabl_xte_start_nc {\futurelet\next\tabl_xte_start_nc_indeed} \def\tabl_xte_start_nc_indeed {\ifx\next\tabl_xte_start_nr \else \expandafter\tabl_xte_start_nc_finish \fi} \def\tabl_xte_start_nc_finish#1\NC {\ifconditional\c_tabl_xte_in_nc \else \settrue\c_tabl_xte_in_nc \startxrow[]% \fi \startxcell#1\stopxcell\NC} \protect \starttext \startxtable[align={lohi,middle}] \NC OSI-Schicht \NC[nx=6] Umsetzung \NC\NR \NC Anwendungsschicht \NC[nx=2,ny=3] SOME/I \NC[nx=2,ny=3] AVB/TSN \NC[nx=2,ny=3] DoIP \NC\NR \NC Darstellungsschicht \NC\NR \NC Sitzungsschicht \NC\NR \NC Transportschicht \NC[nx=3] TCP \NC[nx=3] UDP \NC\NR \NC Vermittlungsschicht \NC[nx=3] IPv4 \NC[nx=3] IPv6 \NC\NR \NC Sicherungsschicht \NC[nx=6] Ethernet \NC\NR \NC Bitübertragungsschicht \NC[nx=2] 100BASE-TX \NC[nx=2] 100BASE-T \NC[nx=2] 1000BASE-T \NC\NR \stopxtable \stoptext On 03/08/2017 04:29 PM, Henri Menke wrote:
Dear devs,
Natural Tables are quite handy but their syntax is a little verbose.
\bTABLE \bTR \bTD ... \eTD \eTR \eTABLE
There exist nice extensions which make the format less verbose by mapping
\startTABLE \NC ... \NR\NR \stopTABLE
back to the original macros.
The new method for tables, called xtables, is faster and seems to have less problems than Natural Tables. However, the syntax is even more verbose
\startxtable \startxrow \startxcell ... \stopxcell \stopxrow \stopxtable
Can we have similar abbreviations as for Natural Tables? I am thinking of something like
\startXTABLE \NC ... \NR\NR \stopXTABLE
I tried myself rewriting tabl-nte.mkiv for xtables but it is not straightforward.
What do you think of this proposal?
Kind regards, Henri
Alternatively to my first proposal but still overloading the original xtables I came up with another solution which does not have the \NC\NR but only \NR and does not read the cell content as an argument. \unprotect % Overload tabl_x_start_table \unexpanded\def\tabl_x_start_table[#settings]% maybe two arguments: [tag][settings] | [tag] | [settings] {\bgroup \let\NC\tabl_xte_start_nc \let\NR\tabl_xte_start_nr \settrue\c_tabl_xte_first_nc \tabl_x_prepare{#settings}% \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process\zerocount} % xtable extensions \newconditional\c_tabl_xte_first_nc \unexpanded\def\tabl_xte_start_nr {\stopxcell\stopxrow \settrue\c_tabl_xte_first_nc} \unexpanded\def\tabl_xte_start_nc {\ifconditional\c_tabl_xte_first_nc \setfalse\c_tabl_xte_first_nc \expandafter\startxrow\expandafter\startxcell \else \expandafter\stopxcell\expandafter\startxcell \fi} \protect \starttext \startxtable[align={lohi,middle}] \NC OSI-Schicht \NC[nx=6] Umsetzung \NR \NC Anwendungsschicht \NC[nx=2,ny=3] SOME/I \NC[nx=2,ny=3] AVB/TSN \NC[nx=2,ny=3] DoIP \NR \NC Darstellungsschicht \NR \NC Sitzungsschicht \NR \NC Transportschicht \NC[nx=3] TCP \NC[nx=3] UDP \NR \NC Vermittlungsschicht \NC[nx=3] IPv4 \NC[nx=3] IPv6 \NR \NC Sicherungsschicht \NC[nx=6] Ethernet \NR \NC Bitübertragungsschicht \NC[nx=2] 100BASE-TX \NC[nx=2] 100BASE-T \NC[nx=2] 1000BASE-T \NR \stopxtable \stoptext On 03/08/2017 04:39 PM, Henri Menke wrote:
I quickly came up with something myself. Unfortunately, it involves overloading of the original xtables. Perhaps there is a better way but it works. I am happy to hear your opinions!
\unprotect
% Overload tabl_x_start_table \unexpanded\def\tabl_x_start_table[#settings]% maybe two arguments: [tag][settings] | [tag] | [settings] {\bgroup \let\NC\tabl_xte_start_nc \let\NR\tabl_xte_start_nr \tabl_x_prepare{#settings}% \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process\zerocount}
% xtable extensions \newconditional\c_tabl_xte_in_nc
\unexpanded\def\tabl_xte_start_nr {\stopxrow \setfalse\c_tabl_xte_in_nc}
\unexpanded\def\tabl_xte_start_nc {\futurelet\next\tabl_xte_start_nc_indeed}
\def\tabl_xte_start_nc_indeed {\ifx\next\tabl_xte_start_nr \else \expandafter\tabl_xte_start_nc_finish \fi}
\def\tabl_xte_start_nc_finish#1\NC {\ifconditional\c_tabl_xte_in_nc \else \settrue\c_tabl_xte_in_nc \startxrow[]% \fi \startxcell#1\stopxcell\NC}
\protect
\starttext
\startxtable[align={lohi,middle}] \NC OSI-Schicht \NC[nx=6] Umsetzung \NC\NR \NC Anwendungsschicht \NC[nx=2,ny=3] SOME/I \NC[nx=2,ny=3] AVB/TSN \NC[nx=2,ny=3] DoIP \NC\NR \NC Darstellungsschicht \NC\NR \NC Sitzungsschicht \NC\NR \NC Transportschicht \NC[nx=3] TCP \NC[nx=3] UDP \NC\NR \NC Vermittlungsschicht \NC[nx=3] IPv4 \NC[nx=3] IPv6 \NC\NR \NC Sicherungsschicht \NC[nx=6] Ethernet \NC\NR \NC Bitübertragungsschicht \NC[nx=2] 100BASE-TX \NC[nx=2] 100BASE-T \NC[nx=2] 1000BASE-T \NC\NR \stopxtable
\stoptext
On 03/08/2017 04:29 PM, Henri Menke wrote:
Dear devs,
Natural Tables are quite handy but their syntax is a little verbose.
\bTABLE \bTR \bTD ... \eTD \eTR \eTABLE
There exist nice extensions which make the format less verbose by mapping
\startTABLE \NC ... \NR\NR \stopTABLE
back to the original macros.
The new method for tables, called xtables, is faster and seems to have less problems than Natural Tables. However, the syntax is even more verbose
\startxtable \startxrow \startxcell ... \stopxcell \stopxrow \stopxtable
Can we have similar abbreviations as for Natural Tables? I am thinking of something like
\startXTABLE \NC ... \NR\NR \stopXTABLE
I tried myself rewriting tabl-nte.mkiv for xtables but it is not straightforward.
What do you think of this proposal?
Kind regards, Henri
I refined the proposal a little further to not having to overload xtables but only use one remaining internal macro of xtables. I also sent this version to Hans to be considered going to the ConTeXt core. \unprotect %D xtable extensions \definextable[XTABLE] \unexpanded\def\startXTABLE {\bgroup \let\NC\tabl_xte_start_nc \let\NR\tabl_xte_start_nr \settrue\c_tabl_xte_first_nc \tabl_x_start_named{XTABLE}} \newconditional\c_tabl_xte_first_nc \unexpanded\def\tabl_xte_start_nr {\stopxcell\stopxrow \settrue\c_tabl_xte_first_nc} \unexpanded\def\tabl_xte_start_nc {\ifconditional\c_tabl_xte_first_nc \setfalse\c_tabl_xte_first_nc \expandafter\startxrow\expandafter\startxcell \else \expandafter\stopxcell\expandafter\startxcell \fi} %D The related structure commands are also available: \let\startXTABLEhead\startxtablehead \let\startXTABLEfoot\startxtablefoot \let\startXTABLEnext\startxtablenext \let\startXTABLEbody\startxtablebody \let\stopXTABLEhead\stopxtablehead \let\stopXTABLEfoot\stopxtablefoot \let\stopXTABLEnext\stopxtablenext \let\stopXTABLEbody\stopxtablebody \protect \starttext \startXTABLE[align={lohi,middle}] \startXTABLEhead \NC OSI-Schicht \NC[nx=6] Umsetzung \NR \stopXTABLEhead \startXTABLEbody \NC Anwendungsschicht \NC[nx=2,ny=3] SOME/I \NC[nx=2,ny=3] AVB/TSN \NC[nx=2,ny=3] DoIP \NR \NC Darstellungsschicht \NR \NC Sitzungsschicht \NR \NC Transportschicht \NC[nx=3] TCP \NC[nx=3] UDP \NR \NC Vermittlungsschicht \NC[nx=3] IPv4 \NC[nx=3] IPv6 \NR \NC Sicherungsschicht \NC[nx=6] Ethernet \NR \stopXTABLEbody \startXTABLEfoot \NC Bitübertragungsschicht \NC[nx=2] 100BASE-TX \NC[nx=2] 100BASE-T \NC[nx=2] 1000BASE-T \NR \stopXTABLEfoot \stopXTABLE \stoptext On 03/08/2017 04:49 PM, Henri Menke wrote:
Alternatively to my first proposal but still overloading the original xtables I came up with another solution which does not have the \NC\NR but only \NR and does not read the cell content as an argument.
\unprotect
% Overload tabl_x_start_table \unexpanded\def\tabl_x_start_table[#settings]% maybe two arguments: [tag][settings] | [tag] | [settings] {\bgroup \let\NC\tabl_xte_start_nc \let\NR\tabl_xte_start_nr \settrue\c_tabl_xte_first_nc \tabl_x_prepare{#settings}% \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process\zerocount}
% xtable extensions \newconditional\c_tabl_xte_first_nc
\unexpanded\def\tabl_xte_start_nr {\stopxcell\stopxrow \settrue\c_tabl_xte_first_nc}
\unexpanded\def\tabl_xte_start_nc {\ifconditional\c_tabl_xte_first_nc \setfalse\c_tabl_xte_first_nc \expandafter\startxrow\expandafter\startxcell \else \expandafter\stopxcell\expandafter\startxcell \fi}
\protect
\starttext
\startxtable[align={lohi,middle}] \NC OSI-Schicht \NC[nx=6] Umsetzung \NR \NC Anwendungsschicht \NC[nx=2,ny=3] SOME/I \NC[nx=2,ny=3] AVB/TSN \NC[nx=2,ny=3] DoIP \NR \NC Darstellungsschicht \NR \NC Sitzungsschicht \NR \NC Transportschicht \NC[nx=3] TCP \NC[nx=3] UDP \NR \NC Vermittlungsschicht \NC[nx=3] IPv4 \NC[nx=3] IPv6 \NR \NC Sicherungsschicht \NC[nx=6] Ethernet \NR \NC Bitübertragungsschicht \NC[nx=2] 100BASE-TX \NC[nx=2] 100BASE-T \NC[nx=2] 1000BASE-T \NR \stopxtable
\stoptext
On 03/08/2017 04:39 PM, Henri Menke wrote:
I quickly came up with something myself. Unfortunately, it involves overloading of the original xtables. Perhaps there is a better way but it works. I am happy to hear your opinions!
\unprotect
% Overload tabl_x_start_table \unexpanded\def\tabl_x_start_table[#settings]% maybe two arguments: [tag][settings] | [tag] | [settings] {\bgroup \let\NC\tabl_xte_start_nc \let\NR\tabl_xte_start_nr \tabl_x_prepare{#settings}% \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process\zerocount}
% xtable extensions \newconditional\c_tabl_xte_in_nc
\unexpanded\def\tabl_xte_start_nr {\stopxrow \setfalse\c_tabl_xte_in_nc}
\unexpanded\def\tabl_xte_start_nc {\futurelet\next\tabl_xte_start_nc_indeed}
\def\tabl_xte_start_nc_indeed {\ifx\next\tabl_xte_start_nr \else \expandafter\tabl_xte_start_nc_finish \fi}
\def\tabl_xte_start_nc_finish#1\NC {\ifconditional\c_tabl_xte_in_nc \else \settrue\c_tabl_xte_in_nc \startxrow[]% \fi \startxcell#1\stopxcell\NC}
\protect
\starttext
\startxtable[align={lohi,middle}] \NC OSI-Schicht \NC[nx=6] Umsetzung \NC\NR \NC Anwendungsschicht \NC[nx=2,ny=3] SOME/I \NC[nx=2,ny=3] AVB/TSN \NC[nx=2,ny=3] DoIP \NC\NR \NC Darstellungsschicht \NC\NR \NC Sitzungsschicht \NC\NR \NC Transportschicht \NC[nx=3] TCP \NC[nx=3] UDP \NC\NR \NC Vermittlungsschicht \NC[nx=3] IPv4 \NC[nx=3] IPv6 \NC\NR \NC Sicherungsschicht \NC[nx=6] Ethernet \NC\NR \NC Bitübertragungsschicht \NC[nx=2] 100BASE-TX \NC[nx=2] 100BASE-T \NC[nx=2] 1000BASE-T \NC\NR \stopxtable
\stoptext
On 03/08/2017 04:29 PM, Henri Menke wrote:
Dear devs,
Natural Tables are quite handy but their syntax is a little verbose.
\bTABLE \bTR \bTD ... \eTD \eTR \eTABLE
There exist nice extensions which make the format less verbose by mapping
\startTABLE \NC ... \NR\NR \stopTABLE
back to the original macros.
The new method for tables, called xtables, is faster and seems to have less problems than Natural Tables. However, the syntax is even more verbose
\startxtable \startxrow \startxcell ... \stopxcell \stopxrow \stopxtable
Can we have similar abbreviations as for Natural Tables? I am thinking of something like
\startXTABLE \NC ... \NR\NR \stopXTABLE
I tried myself rewriting tabl-nte.mkiv for xtables but it is not straightforward.
What do you think of this proposal?
Kind regards, Henri
On Wed, 8 Mar 2017 16:29:52 +0100
Henri Menke
Natural Tables are quite handy but their syntax is a little verbose.
\bTABLE \bTR \bTD ... \eTD \eTR \eTABLE
There exist nice extensions which make the format less verbose by mapping
\startTABLE \NC ... \NR\NR \stopTABLE
back to the original macros.
The new method for tables, called xtables, is faster and seems to have less problems than Natural Tables. However, the syntax is even more verbose
\startxtable \startxrow \startxcell ... \stopxcell \stopxrow \stopxtable
Can we have similar abbreviations as for Natural Tables?
Beauty is in the eyes of the beholder, but I have always found the syntax of the older table macros to be quite unreadable, somewhat a left-over from laTeX-like syntax. The xtables syntax is verbose, indeed, but much more readable and much better in line with other ConTeXt syntax. (Hans, my only complaint about xtables is that they apparently cannot be used nested in a title={} of \startplacefigure.) Alan
On Wed, 8 Mar 2017, Alan Braslau wrote:
On Wed, 8 Mar 2017 16:29:52 +0100 Henri Menke
wrote: Natural Tables are quite handy but their syntax is a little verbose.
\bTABLE \bTR \bTD ... \eTD \eTR \eTABLE
There exist nice extensions which make the format less verbose by mapping
\startTABLE \NC ... \NR\NR \stopTABLE
back to the original macros.
The new method for tables, called xtables, is faster and seems to have less problems than Natural Tables. However, the syntax is even more verbose
\startxtable \startxrow \startxcell ... \stopxcell \stopxrow \stopxtable
Can we have similar abbreviations as for Natural Tables?
Beauty is in the eyes of the beholder, but I have always found the syntax of the older table macros to be quite unreadable, somewhat a left-over from laTeX-like syntax.
The xtables syntax is verbose, indeed, but much more readable and much better in line with other ConTeXt syntax.
It depends. For numerical tables, the old syntax is easier to read. \startTABLE \NC Parameter \NC value 1 \NC value 2 \NC value 3 \NC \NR \NC 1.0 \NC 3.4 \NC 3.6 \NC 4.2 \NC \NR \NC 1.0 \NC 3.4 \NC 3.6 \NC 4.2 \NC \NR \NC 1.0 \NC 3.4 \NC 3.6 \NC 4.2 \NC \NR \stopTABLE For textual tables, or for generating tables programmatically using CLD, the start-stop syntax is more convenient. Aditya
participants (3)
-
Aditya Mahajan
-
Alan Braslau
-
Henri Menke