ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] simplify side by side Poems
@ 2024-05-23 12:13 seyal.zavira
  2024-05-23 12:32 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: seyal.zavira @ 2024-05-23 12:13 UTC (permalink / raw)
  To: ntg-context

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?
___________________________________________________________________________________
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] 5+ messages in thread

* [NTG-context] Re: simplify side by side Poems
  2024-05-23 12:13 [NTG-context] simplify side by side Poems seyal.zavira
@ 2024-05-23 12:32 ` Wolfgang Schuster
  2024-05-23 16:59   ` seyal.zavira
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2024-05-23 12:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users, seyal.zavira

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
___________________________________________________________________________________
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] 5+ messages in thread

* [NTG-context] Re: simplify side by side Poems
  2024-05-23 12:32 ` [NTG-context] " Wolfgang Schuster
@ 2024-05-23 16:59   ` seyal.zavira
  2024-05-23 20:44     ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: seyal.zavira @ 2024-05-23 16:59 UTC (permalink / raw)
  To: ntg-context

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.
___________________________________________________________________________________
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] 5+ messages in thread

* [NTG-context] Re: simplify side by side Poems
  2024-05-23 16:59   ` seyal.zavira
@ 2024-05-23 20:44     ` Wolfgang Schuster
  2024-05-25  6:40       ` seyal.zavira
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2024-05-23 20:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users, seyal.zavira

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
___________________________________________________________________________________
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] 5+ messages in thread

* [NTG-context] Re: simplify side by side Poems
  2024-05-23 20:44     ` Wolfgang Schuster
@ 2024-05-25  6:40       ` seyal.zavira
  0 siblings, 0 replies; 5+ messages in thread
From: seyal.zavira @ 2024-05-25  6:40 UTC (permalink / raw)
  To: ntg-context

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).
___________________________________________________________________________________
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] 5+ messages in thread

end of thread, other threads:[~2024-05-25  6:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-23 12:13 [NTG-context] simplify side by side Poems seyal.zavira
2024-05-23 12:32 ` [NTG-context] " Wolfgang Schuster
2024-05-23 16:59   ` seyal.zavira
2024-05-23 20:44     ` Wolfgang Schuster
2024-05-25  6:40       ` seyal.zavira

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