Sent with Proton Mail secure email.

On Sunday, December 28th, 2025 at 8:00 PM, Wolfgang Schuster 
<[email protected]> wrote:

> 
> 
> Am 28.12.2025 um 17:58 schrieb Aryeh Zapinsky:
> > Problem:
> > When using r2l alignment, layout of paragraphs appears to be flipped
> > (from r2l to l2r) after correctly placing the first paragraph inside of
> > a frame.
> > 
> > Questions:
> > 1. What is going on? (I'm not sure how to describe what's happening.) Is
> > the paragraph not being formatted correctly or the frame?
> > 2. What document can I look at to understand what's happening to format
> > the text? typo-duc.lmt seems to be referencing some other work that has
> > sections and tagged rules. What document is that?
> > 3. What are typo-dir, typo-dha, and typo-duc each doing? I'm curious to
> > know so I can better navigate the codebase going forward.
> 
> 
> I can reproduce the problem with the following minimal example
> 
> \defineparagraphs [Columns] [n=2,rule=on]
> 
> \starttext
> 
> \startframed[width=max,align=r2l]
> \startColumns 1 \nextColumns 2 \stopColumns
> \startColumns 1 \nextColumns 2 \stopColumns
> \stopframed
> 
> \stoptext
> 
> 
> The reason why the first environment is r2l is because it start in
> horizontal mode while the second start in vertical mode, when you add
> \dontleavehmode before the second one it will also switch to r2l.
> 
> 
> One way to fix this problem is to add a direction key with will by
> default place the column "left to right" with the option to reverse it
> to "right to left".
> 

It looks like \startparagraphs is internally using
\hpack without considering the layout directions, 
maybe something like the following solve it?

\defineparagraphs [Columns] [n=2,rule=on]
\unprotect
\overloadmode=0
\overloaded\protected\def\startparagraphs[#1]% quite slow
  {\bgroup % (1)
   \cdef\currentparagraphs{#1}%
   \edef\p_width{\paragraphsparameter\c!width}%
   \ifempty\p_width
     \d_typo_paragraphs_width\availablehsize
   \else
     \d_typo_paragraphs_width\p_width\relax
   \fi
   
\d_typo_paragraphs_width{\d_typo_paragraphs_width-(\paragraphsparameter\c!offset)*2}%
   \c_typo_paragraphs_max{\paragraphsparameter\c!n}%
   \d_typo_paragraphs_auto\d_typo_paragraphs_width\relax
   \scratchcounter\zerocount
   \localcontrolledrepeat \c_typo_paragraphs_max
     
{\edef\p_width{\namedparagraphsparameter{\currentparagraphs:\the\currentloopiterator}\c!width}%
      \ifempty\p_width
        \advanceby\scratchcounter\plusone
      \else
        \advanceby\d_typo_paragraphs_auto-\p_width\relax
      \fi
      \ifnum\currentloopiterator>\plusone
        
\advanceby\d_typo_paragraphs_auto{-(\namedparagraphsparameter{\currentparagraphs:\number\currentloopiterator}\c!distance)}%
      \fi}%
   \ifnum\scratchcounter>\zerocount
     \divideby\d_typo_paragraphs_auto\scratchcounter
   \else
     \d_typo_paragraphs_auto\zeropoint
   \fi
   \parindent\zeropoint
   \c_typo_paragraphs_n\zerocount
   \enforced\let\\\nextparagraphs % downward compatible
   \setbox\scratchbox\hpack\c!direction\displaylefttoright % <---------- was 
\setbox\scratchbox\hpack
   \bgroup % (2)
   \forgetall
   
\ifchkdimension\paragraphsparameter\c!offset\or\advanceby\hsize-2\lastchkdimension\fi
   \let\typo_paragraphs_start_cell\typo_paragraphs_start_cell_indeed
   \let\typo_paragraphs_stop_cell \typo_paragraphs_stop_cell_indeed
   \typo_paragraphs_start_cell_indeed}
\protect

\starttext
\startframed[width=max,align=r2l]

\startColumns 
Column one text here
\Columns 
Column two text here
\stopColumns

\stopframed
\stoptext

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

maillist : [email protected] / 
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
___________________________________________________________________________________

Reply via email to