Hi all, i want to use tables for constructing poems structure this snippet of code works well: \startsetups tablepoem \setupTABLE[column][each][width=5cm] \stopsetups \starttext \bTABLE[setups=tablepoem] \bTR \bTD One one ons ksl \eTD \bTD two gfjgfd oski kwo \eTD \eTR \bTR \bTD One wer s dft tgf \eTD \bTD two gfkdsjg dfs we \eTD \eTR \eTABLE \stoptext but when i use this code for simplifying of changing cells I get an error: \startsetups tablepoem \setupTABLE[column][each][width=5cm] \stopsetups \def\Poemstart{\bTABLE[setups=tablepoem] \bTR \bTD} \def\Mesra{\eTD \bTD} \def\nextBeyt{\eTD\eTR\bTR\bTD} \def\Poemstop{\eTD\eTR\eTABLE} \starttext \Poemstart One one ons ksl \Mesra two gfjgfd oski kwo \nextBeyt One wer s dft tgf \Mesra two gfkdsjg dfs we \Poemstop \stoptext what is the problem?
seyal.zavira@gmail.com schrieb am 23.05.2024 um 14:13:
Hi all,
i want to use tables for constructing poems structure this snippet of code works well:
\startsetups tablepoem \setupTABLE[column][each][width=5cm] \stopsetups \starttext \bTABLE[setups=tablepoem] \bTR \bTD One one ons ksl \eTD \bTD two gfjgfd oski kwo \eTD \eTR \bTR \bTD One wer s dft tgf \eTD \bTD two gfkdsjg dfs we \eTD \eTR \eTABLE \stoptext
but when i use this code for simplifying of changing cells I get an error:
\startsetups tablepoem \setupTABLE[column][each][width=5cm] \stopsetups
\def\Poemstart{\bTABLE[setups=tablepoem] \bTR \bTD} \def\Mesra{\eTD \bTD} \def\nextBeyt{\eTD\eTR\bTR\bTD} \def\Poemstop{\eTD\eTR\eTABLE}
\starttext \Poemstart One one ons ksl \Mesra two gfjgfd oski kwo \nextBeyt One wer s dft tgf \Mesra two gfkdsjg dfs we \Poemstop \stoptext
what is the problem?
The table environment collects the content of the table cell-wise which means when TeX sees a \bTD in the input it reads the following text until it finds the corresponding \eTD. When you put the \eTD in the definition of another command the scanner will never find the end of a cell and you either run out of memory or reach the end of the file etc. Below are a few alternative solutions to simplify the input, one of them is an alternative version of input (\startTABLE) for natural tables which uses the same commands to separate columns as tabulate does. %%%% begin example \starttext \startTABLE[width=5cm] \NC One one ons ksl \NC two gfjgfd oski kwo \NC\NR \NC One wer s dft tgf \NC two gfkdsjg dfs we \NC\NR \stopTABLE \starttabulate[|*{2}{k{0}lw(5cm)|}] \NC One one ons ksl \NC two gfjgfd oski kwo \NC\NR \NC One wer s dft tgf \NC two gfkdsjg dfs we \NC\NR \stoptabulate \defineparagraphs[poem][n=2,width=5cm] \setupparagraphs[poem][each][width=5cm,distance=0pt] \startpoem \startlines One one ons ksl One wer s dft tgf \stoplines \nextpoem \startlines two gfjgfd oski kwo two gfkdsjg dfs we \stoplines \stoppoem \stoptext %%%% end example Wolfgang
Thanks so much but what should a person do if he wants to define an equivalent of \eTD? for example it can be useful for RTL language such as: \def\پسل{\eTD} and as you said this code will not work.
seyal.zavira@gmail.com schrieb am 23.05.2024 um 18:59:
Thanks so much
but what should a person do if he wants to define an equivalent of \eTD? for example it can be useful for RTL language such as: \def\پسل{\eTD} and as you said this code will not work.
You can create your own replacement for the \bTD ... \eTD pair define a command which is delimited by another command. To do this you have to first create a new command like always as \def\... which takes a single argument and at the end after the argument you another command is used as delimiter for the argument. The argument of your new delimited command is then passed to the normal commands for the table cell. %%%% begin example \starttext \protected\def\StartTableCell#1\StopTableCell {\bTD#1\eTD} % New method to create delimited arguments with #L and #R in Luametatex % % \protected\def\StartTableCell#L\StartTableCell#R\StopTableCell#1% % {\bTD#1\eTD} \bTABLE \bTR \StartTableCell row 1 column 1 \StopTableCell \StartTableCell row 1 column 2 \StopTableCell \eTR \bTR \StartTableCell row 2 column 1 \StopTableCell \StartTableCell row 2 column 2 \StopTableCell \eTR \eTABLE \stoptext %%% end example Wolfgang
Thanks so much i also could define poem structure like this: Using table method: \protected\def\PoemStart#1\PoemStop {\bTABLE[setups=tablepoem]#1\eTABLE} \protected\def\Beyt#1 {\bTR #1 \eTR} \protected\def\Misra#1 {\bTD #1 \eTD} \starttext \PoemStart \Beyt{\Misra{the first sentence} \Misra{the second sentence}} \Beyt{\Misra{the third sentence} \Misra{the fourth sentence}} \PoemStop \stoptext also it can be done with itemize(easier but less flexible): \defineitemgroup[Mypoem] \setupitemgroup[Mypoem][horizontal,two] \protected\def\PoemStart#1\PoemStop {\startitemgroup[Mypoem]#1\stopitemgroup} \protected\def\Misra#1 {\startitem#1\stopitem} \starttext \PoemStart \Misra{the first sentence} \Misra{the second sentence} \Misra{the third sentence} \Misra{the fourth sentence} \PoemStop \stoptext there is also another method by using buffers and lua code (part of the answer to my question on the stack site).
participants (2)
-
seyal.zavira@gmail.com
-
Wolfgang Schuster