texlive[76086] Master/texmf-dist: leporello (18aug25)

commits+karl at tug.org commits+karl at tug.org
Mon Aug 18 21:02:15 CEST 2025


Revision: 76086
          https://tug.org/svn/texlive?view=revision&revision=76086
Author:   karl
Date:     2025-08-18 21:02:15 +0200 (Mon, 18 Aug 2025)
Log Message:
-----------
leporello (18aug25)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/leporello/README.md
    trunk/Master/texmf-dist/doc/latex/leporello/doc/layout.tex
    trunk/Master/texmf-dist/doc/latex/leporello/leporello-doc.pdf
    trunk/Master/texmf-dist/doc/latex/leporello/leporello-doc.tex
    trunk/Master/texmf-dist/tex/latex/leporello/leporello.cls

Modified: trunk/Master/texmf-dist/doc/latex/leporello/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/leporello/README.md	2025-08-18 19:02:04 UTC (rev 76085)
+++ trunk/Master/texmf-dist/doc/latex/leporello/README.md	2025-08-18 19:02:15 UTC (rev 76086)
@@ -1,4 +1,4 @@
-![Version 0.8.0](https://img.shields.io/badge/version-0.8.0-blue)
+![Version 0.9.0](https://img.shields.io/badge/version-0.9.0-blue)
 
 # The `leporello` class
 

Modified: trunk/Master/texmf-dist/doc/latex/leporello/doc/layout.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/leporello/doc/layout.tex	2025-08-18 19:02:04 UTC (rev 76085)
+++ trunk/Master/texmf-dist/doc/latex/leporello/doc/layout.tex	2025-08-18 19:02:15 UTC (rev 76086)
@@ -16,8 +16,6 @@
   show ids
 ]{leporello}
 
-\errorcontextlines100
-
 \leporellosetstyle{align bottom}{
   align parent={l,b},
   align self={l,b}

Modified: trunk/Master/texmf-dist/doc/latex/leporello/leporello-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/leporello/leporello-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/leporello/leporello-doc.tex	2025-08-18 19:02:04 UTC (rev 76085)
+++ trunk/Master/texmf-dist/doc/latex/leporello/leporello-doc.tex	2025-08-18 19:02:15 UTC (rev 76086)
@@ -11,8 +11,8 @@
 % This work has the LPPL maintenance status `maintained'.
 %
 \documentclass[a4paper]{article}
-\def\leporellofileversion{0.8.0}
-\def\leporellofiledate{12 August 2025}
+\def\leporellofileversion{0.9.0}
+\def\leporellofiledate{15 August 2025}
 
 \usepackage[T1]{fontenc}
 \usepackage{Alegreya}
@@ -264,6 +264,7 @@
 
 \changes{v0.7.0}{2025/08/08}{First public beta release.}
 \changes{v0.8.0}{2025/08/12}{Added box attachment mechanism and option to place arbitrary code to box background.}
+\changes{v0.9.0}{2025/08/15}{Box attachment mechanism and flow mechanism use box name instead of ID. Enhanced pagination settings. Support for RTL and vertical typesetting.}
 
 \begin{document}
 \printdoctitle
@@ -282,6 +283,8 @@
 
 A folded leaflet is sometimes called leporello in reference to the servant of Don Giovanni (known from the opera by Mozart) who, at one point, unfolds a lengthy zig-zag folded list of his master's love affairs.
 
+There are some requirements for the creation of print data for high-quality folded leaflets: Especially if the leaflet is folded inward, the inner pages should be a bit less wide, so in general the pages of a leaflet are not of the exact same width (although the widths only differ slightly). Also, borderless printing requires that the print data adds a so-called bleed area added to the layout if the final document into which the typeset material extends. This area is trimmed off eventually to avoid unprinted edges due to natural movement of the paper during guillotining. Crop marks need to be added to the print data showing the layout of the final document. This packages takes into account all these requirements while providing a lot of customization.
+
 \section{Loading the document class}
 
 Use \macro{\documentclass{leporello}} to load the document class. The document class loads the \macro{geometry}, the \macro{graphicx} and the \macro{l3draw} package.
@@ -305,10 +308,10 @@
 A few column layouts are predefined. These do not expect a value. The layouts will set the following list of dimensions:
 
 \begin{longtable}{
-  @{} 
-  p{\dimexpr0.35\linewidth-\tabcolsep} 
-  p{\dimexpr0.65\linewidth-\tabcolsep} 
   @{}
+  p{\dimexpr0.35\linewidth-\tabcolsep}
+  p{\dimexpr0.65\linewidth-\tabcolsep}
+  @{}
 }
   \toprule
   \textbf{Key}              & \textbf{List of dimensions}                                 \\
@@ -328,14 +331,24 @@
 Expects a dimension that sets the height of the final layout. If \macro{layout height} is not specified, the class assumes the default value of \macro{210mm} (the height of A4 landscape).
 
 \begin{macrodef}
+|auto typeset|
+\end{macrodef}
+If set, the columns are automatically typeset according to the order of the definition.
+
+\begin{macrodef}
+|continuous pagination|
+\end{macrodef}
+If set, columns are numbered continuously from left to right. Otherwise, the pagination starts on the last column of every odd shipout page, continues from left to right over the columns on the following shipout page and eventually from left ro right over the remaining columns on the first page. For example, in a document with three columns per shipout page the pagination would be 5, 6, 1 and 2, 3, 4 and then on the next two shipout pages 11, 12, 7 and 8, 9, 10.
+
+\begin{macrodef}
 |show frames|
 \end{macrodef}
-If set, frames around the single pages (columns) are shown. Does not expect a value. 
+If set, frames around the single pages (columns) are shown. Does not expect a value.
 
 \begin{macrodef}
 |show ids|
 \end{macrodef}
-If set, the IDs of the boxes are shown. Does not expect a value. 
+If set, the IDs of the boxes are shown. Does not expect a value. The IDs of the boxes are integers starting from 1 and increasing in the order of typesetting of the boxes.
 
 \begin{macrodef}
 |prepress|
@@ -371,7 +384,7 @@
   <body>
 \end{|leporellocolumn|}
 \end{macrodef}
-A column is defined by the \macro{leporellocolumn} environment which takes one mandatory argument taking the name (ID) of the column.
+A column is defined by the \macro{leporellocolumn} environment which takes one mandatory argument taking the name (ID) of the column. A single dot (\macro{.}) is reserved as name for an empty column.
 
 \section{Positioning boxes}
 
@@ -383,11 +396,16 @@
 Boxes can be positioned inside of columns. They can contain anything that can be placed in a TeX box in general. A box is defined by the \macro{leporellobox} environment which takes one optional argument to set box-specific options. These are the following:
 
 \begin{macrodef}
-|parent|={<integer>}
+|name|={<string>}
 \end{macrodef}
-Expects the ID of the box to which the current box is aligned. If not specified, the default value \macro{0} is assumed, denoting the current column box.
+Expects a (unique) string denoting the name of the box which can be used for attaching boxes to each other or assigning boxes for the flow mechanism.
 
 \begin{macrodef}
+|parent|={<string>}
+\end{macrodef}
+Expects a string denoting the name of the box to which the current box is aligned. If not specified, the current column box is assumed as parent box. The parent box needs to be in the same column as the box that should be aligned to it.
+
+\begin{macrodef}
 |align parent|={<tuple of poles>}
 \end{macrodef}
 Expects a comma-separated list of two items (a tuple) which denotes the horizontal and vertical pole of which the intersection defines the coordinate of the parent box (per default this is the current column box) that serves as anchor to align the current box. If not specified, the default value \macro{l, t} is assumed, denoting the top left corner. Available poles are:
@@ -399,7 +417,7 @@
   @{}
 }
   \toprule
-  \textbf{Key} & \textbf{Meaning}             \\
+  \textbf{Key} & \textbf{Meaning}             \\*
   \midrule
   \macro{l}    & left edge of the box         \\
   \macro{hc}   & horizontal center of the box \\
@@ -482,9 +500,9 @@
 Expects a single control sequence (macro) to store the height of the current box.
 
 \begin{macrodef}
-|flow into|={<integer>}
+|flow into|={<string>}
 \end{macrodef}
-Expects the ID of the box into which typeset material will flow into if it does not fit into the current box. See section \ref{sec:flow} below.
+Expects a string denoting the name of the box into which typeset material will flow into if it does not fit into the current box. The box to flow into can be in a following column or on a following page. See section \ref{sec:flow} below.
 
 \section{Typesetting boxes into columns}
 
@@ -491,18 +509,23 @@
 \begin{macrodef}
 |\leporellotypesetcolumns|[<options>]{<list of strings>}
 \end{macrodef}
-Using the command \macro{\leporellotypesetcolumns} which takes one mandatory argument, previously defined columns can be placed onto a page of the document. The command expects as argument a comma-separated list of names of previously defined columns. These are then placed onto a document page from left to right while the width is taken from the setting via the \macro{columns} key and the height is taken from the setting via the \macro{layout height} key.
+Using the command \macro{\leporellotypesetcolumns} which takes one mandatory argument, previously defined columns can be placed onto a page of the document. The command expects as argument a comma-separated list of names of previously defined columns. These are then placed onto a document page from left to right while the width is taken from the setting via the \macro{columns} key and the height is taken from the setting via the \macro{layout height} key. With a \macro{.}, an empty column can be added to the list.
 
+The command takes one optional argument that accepts one of the following keys:
+
 \begin{macrodef}
 |reverse layout|
 \end{macrodef}
-The command takes one optional argument that can take the option \macro{reverse layout}. If set, the widths of the columns are reversed, but the placement of the columns is still from left to right. This option does not take a value. The option should be used to typeset the verso of a folded leaflet that naturally has the widths of the columns reversed.
+If set, the widths of the columns are reversed, but the placement of the columns is still from left to right. This option does not take a value. The option should be used to typeset the verso of a folded leaflet that naturally has the widths of the columns reversed.
 
-Currently, boxes can only be attached to columns. A future version of the document class may allow the attachment of boxes to each other. If a box should be positioned below another box with natural height defined by its contents, the \macro{store height} key can be used to store the height of the upper box into a custom macro which can then be used to calculate the offset from the top.
+\begin{macrodef}
+|reverse order|
+\end{macrodef}
+If set, the order of the columns is reversed, which means that the columns are typeset from right to left. Pagination is not affected.
 
 \section{Flow mechanism}\label{sec:flow}
 
-Typeset material can flow from one box to another box. To this end, the key \macro{flow into} can be set to the relevant box and assigned the ID of the box to flow into as value. The IDs of the boxes are integers starting from 1 and increasing in the order of the definition of the boxes. By setting the key \macro{show ids} to the document options, the IDs of all boxes are shown.
+Typeset material can flow from one box to another box. To this end, the key \macro{flow into} can be set to the relevant box and assigned the name of the box to flow into as value. The name of the relevant box can be set via the \macro{name} key.
 
 \begin{macrodef}
 |\leporelloboxbreak|
@@ -509,52 +532,25 @@
 \end{macrodef}
 The flow mechanism works across multiple boxes. But due to the way the typesetting mechanism of TeX works, it needs some manual adjustment if the typeset material flows across boxes of different width. In this case, the command \macro{\leporelloboxbreak} should be inserted at the point where the break should take place.
 
-\subsection{Hooks}
+Typeset material can only flow into boxes in the following column or page. If typeset material should flow backwards on the same page, this can be achieved using the key \macro{reverse order} on the relevant page.
 
-The package offers two pairs of hooks that are positioned at the start and end of columns and boxes allowing for inserting code. The package uses the hook \macro{leporello/box/before} to insert code for the flow mechanism. 
+\subsection{Right-to-left and vertical typesetting}
 
-Apart from that, the package uses the hook \macro{begindocument/before} to insert layout-related settings among other things via the \macro{geometry} package as well as the hook \macro{shipout/foreground} to insert code to draw cropmarks.
+The document class natively supports right-to-left and vertical typesetting using the mechanisms provided by LuaLaTeX. The \macro{babel} package also makes use of the mechanisms for bidirectional typesetting provided by LuaLaTeX, which means that this package will work best with a combination of LuaLaTeX and \macro{babel}for right-to-left or vertical typesetting.
 
-\begin{longtable}{
-  @{}
-  p{13em}
-  p{\dimexpr\linewidth-2\tabcolsep-13em}
-  @{}
-}
-  \toprule
-  \textbf{Hook}                   & \textbf{Position} \\
-  \midrule
-  \macro{leporello/column/before} & before the code block stored via the \macro{leporellocolumn} environment is typeset to the column box, preceded by a line of code that sets \macro{\l_leporello_current_column_str} to the name of the current column \\
-  \macro{leporello/column/after}  & after the code block stored via the \macro{leporellocolumn} environment is typeset to the column box \\
-  \macro{leporello/box/before}    & before the code block stored via the \macro{leporellobox} environment is typeset to the relevant box which is preceded by a line of code that sets \macro{\l_leporello_current_box_int} to the ID of the current column and inserts the code defined via the \macro{pre} key \\
-  \macro{leporello/box/after}     & after the code block stored via the \macro{leporellobox} environment is typeset to the relevant box \\
-  \bottomrule
-\end{longtable}
+If the \macro{bidi} package is used (which is used by the \macro{polyglossia} package), the following addition to the preamble is needed to enable right-to-left typesetting:
 
-\section{Other settings}
+\begin{codeexample}
+\AddToHook{leporello/typeset/before}{\setLTR}
+\AddToHook{leporello/box/begin}{\setRTL}
+\end{codeexample}
 
-\subsection{Hooks}
+In general, it has to be made sure that only the inner boxes are affected by the right-to-left or vertical typesetting mechanism and not the overall layout.
 
-The package offers two pairs of hooks that are positioned at the start and end of columns and boxes allowing for inserting code. The package uses the hook \macro{leporello/box/before} to insert code for the flow mechanism. 
+Vertical typesetting will typically affect the measurements of the boxes. The package sets to true the boolean \macro{\l_leporello_layout_vertical_ltr_bool} for vertical typesetting from left to right (for example used to write traditional Mongolian). The package sets to true the boolean \macro{\l_leporello_layout_vertical_rtl_bool} for vertical typesetting from right to left (for example used to write Chinese, Japanese or Korean).
 
-Apart from that, the package uses the hook \macro{begindocument/before} to insert layout-related settings among other things via the \macro{geometry} package as well as the hook \macro{shipout/foreground} to insert code to draw cropmarks.
+\section{Other settings}
 
-\begin{longtable}{
-  @{}
-  p{13em}
-  p{\dimexpr\linewidth-2\tabcolsep-13em}
-  @{}
-}
-  \toprule
-  \textbf{Hook}                   & \textbf{Position} \\
-  \midrule
-  \macro{leporello/column/before} & before the code block stored via the \macro{leporellocolumn} environment is typeset to the column box, preceded by a line of code that sets \macro{\l_leporello_current_column_str} to the name of the current column \\
-  \macro{leporello/column/after}  & after the code block stored via the \macro{leporellocolumn} environment is typeset to the column box \\
-  \macro{leporello/box/before}    & before the code block stored via the \macro{leporellobox} environment is typeset to the relevant box which is preceded by a line of code that sets \macro{\l_leporello_current_box_int} to the ID of the current column and inserts the code defined via the \macro{pre} key \\
-  \macro{leporello/box/after}     & after the code block stored via the \macro{leporellobox} environment is typeset to the relevant box \\
-  \bottomrule
-\end{longtable}
-
 \subsection{Inserting images}
 
 One way to insert images is via the \macro{\includegraphics} command provided by the \macro{graphicx} package. Using the \macro{background code} key, images can be added to the background of a box.
@@ -598,7 +594,7 @@
 
 \subsection{Defining colors}
 
-The package uses the color model of the \macro{l3color} module. The \macro{xcolor} package is not supported. To provide a user interface to define and select colors, the commands \macro{\leporellocolordefine} and \macro{\leporellocolorselect} are defined. 
+The package uses the color model of the \macro{l3color} module. The \macro{xcolor} package is not supported. To provide a user interface to define and select colors, the commands \macro{\leporellocolordefine} and \macro{\leporellocolorselect} are defined.
 
 \begin{macrodef}
 |\leporellocolordefine|{<string>}{<color model>}{<list of values>}
@@ -624,6 +620,32 @@
 \end{macrodef}
 In order to restore the default justified typesetting style of TeX after having set \macro{\raggedright}, \macro{\raggedleft} or \macro{\centering}, the packages defines the command \macro{\leporellojustified}.
 
+\subsection{Hooks}
+
+The package offers two pairs of hooks that are positioned at the start and end of columns and boxes allowing for inserting code.
+
+The package uses the hook \macro{begindocument/before} to insert layout-related settings among other things via the \macro{geometry} package as well as the hook \macro{shipout/foreground} to insert code to draw cropmarks.
+
+In the context of RTL typesetting, the package uses the hooks \macro{leporello/typeset/before} and \macro{leporello/box/begin} to unset and reset RTL mode.
+
+\begin{longtable}{
+  @{}
+  p{13.5em}
+  p{\dimexpr\linewidth-2\tabcolsep-13.5em}
+  @{}
+}
+  \toprule
+  \textbf{Hook}                    & \textbf{Position} \\*
+  \midrule
+  \macro{leporello/column/begin}   & before the code block stored via the \macro{leporellocolumn} environment is typeset to the column box, preceded by a line of code that sets \macro{\l_leporello_current_column_str} to the name of the current column \\
+  \macro{leporello/column/end}     & after the code block stored via the \macro{leporellocolumn} environment is typeset to the column box \\
+  \macro{leporello/box/begin}      & before the code block stored via the \macro{leporellobox} environment is typeset to the relevant box which is preceded by a line of code that sets \macro{\l_leporello_current_box_int} to the ID of the current column and immediately followed by the code defined via the \macro{pre} key \\
+  \macro{leporello/box/end}        & after the code block stored via the \macro{leporellobox} environment is typeset to the relevant box \\
+  \macro{leporello/typeset/before} & immediately after the start of the group that contains the typeset column \\
+  \macro{leporello/typeset/after}  & immediately before the end of the group that contains the typeset column \\
+  \bottomrule
+\end{longtable}
+
 \section{Example}
 
 The following example shows some of the basic ideas of the package by providing a code example and showing its output.

Modified: trunk/Master/texmf-dist/tex/latex/leporello/leporello.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/leporello/leporello.cls	2025-08-18 19:02:04 UTC (rev 76085)
+++ trunk/Master/texmf-dist/tex/latex/leporello/leporello.cls	2025-08-18 19:02:15 UTC (rev 76086)
@@ -11,11 +11,11 @@
 % This work has the LPPL maintenance status `maintained'.
 %
 \ProvidesExplClass{leporello}
-  {2025/08/12} {0.8.0} {Document class for typesetting folded leaflets}
+  {2025/08/15} {0.9.0} {Document class for typesetting folded leaflets}
 
 \cs_generate_variant:Nn \clist_item:Nn { NV }
+\cs_generate_variant:Nn \coffin_attach:NnnNnnnn { cencennn , ceeceeee }
 \cs_generate_variant:Nn \color_select:n { e }
-\cs_generate_variant:Nn \coffin_attach:NnnNnnnn { ceeceeee }
 \cs_generate_variant:Nn \msg_error:nnnn { nneV }
 \cs_generate_variant:Nn \prop_gput:Nnn { cnV , cne }
 \cs_generate_variant:Nn \tl_const:Nn { co }
@@ -22,7 +22,7 @@
 \cs_generate_variant:Nn \vbox_set_top:Nn { Ne }
 
 \prg_generate_conditional_variant:Nnn \clist_if_in:nn { en } { T , F , TF }
-\prg_generate_conditional_variant:Nnn \str_if_eq:nn { en } { F }
+\prg_generate_conditional_variant:Nnn \str_if_eq:nn { en } { T , F }
 
 \bool_new:N \l_leporello_show_frames_bool
 \bool_new:N \l_leporello_show_id_bool
@@ -33,10 +33,15 @@
 \clist_new:N \l_leporello_columns_clist
 \int_new:N \l_leporello_column_count_int
 
-\dim_new:N \l__leporello_layout_width_dim
-\dim_new:N \l__leporello_paper_width_dim
-\dim_new:N \l__leporello_paper_height_dim
+\dim_new:N \l_leporello_layout_width_dim
+\dim_new:N \l_leporello_paper_width_dim
+\dim_new:N \l_leporello_paper_height_dim
 
+\bool_new:N \l_leporello_continuous_pagination_bool
+\bool_new:N \l_leporello_auto_typeset_bool
+\clist_new:N \g_leporello_auto_typeset_clist
+\int_new:N \l_leporello_auto_typeset_int
+
 \keys_define:nn { leporello / global } {
   columns           .code:n     = {
     \clist_set:Nn \l_leporello_columns_clist {#1}
@@ -43,14 +48,23 @@
     \int_set:Nn \l_leporello_column_count_int {
       \clist_count:N \l_leporello_columns_clist
     }
-    \dim_zero:N \l__leporello_layout_width_dim
+    \dim_zero:N \l_leporello_layout_width_dim
     \clist_map_inline:Nn \l_leporello_columns_clist {
-      \dim_add:Nn \l__leporello_layout_width_dim {##1}
+      \dim_add:Nn \l_leporello_layout_width_dim {##1}
     }
   } ,
   columns           .initial:n  = { 97mm , 100mm , 100mm } ,
   layout ~ height   .dim_set:N  = \l_leporello_layout_height_dim ,
   layout ~ height   .initial:n  = { 210mm } ,
+  continuous ~ pagination
+                    .bool_set:N = \l_leporello_continuous_pagination_bool ,
+  continuous ~ pagination
+                    .default:n  = { true } ,
+  continuous ~ pagination
+                    .initial:n  = { false } ,
+  auto ~ typeset    .bool_set:N = \l_leporello_auto_typeset_bool ,
+  auto ~ typeset    .default:n  = { true } ,
+  auto ~ typeset    .initial:n  = { false } ,
   show ~ frames     .bool_set:N = \l_leporello_show_frames_bool ,
   show ~ frames     .default:n  = { true } ,
   show ~ frames     .initial:n  = { false } ,
@@ -106,6 +120,11 @@
   Column ~ #1 ~ undefined.
 }
 
+\msg_new:nnn { leporello } { parent-box-undefined } {
+  \msg_error_text:n { leporello } \iow_newline:
+  Parent ~ box ~ #1 ~ undefined.
+}
+
 \int_new:N \l_leporello_current_page_int
 \int_new:N \l_leporello_current_column_int
 \str_new:N \l_leporello_current_column_str
@@ -115,14 +134,11 @@
 \int_new:N \g_leporello_box_int
 \int_new:N \l_leporello_current_box_int
 \clist_new:N \g_leporello_parent_boxes_clist
+\prop_new:N \g_leporello_box_names_prop
 
 \tl_new:N \l__leporello_box_align_parent_clist
 \tl_new:N \l__leporello_box_align_self_clist
 \tl_new:N \l__leporello_box_offset_clist
-\bool_new:N \l__leporello_box_width_bool
-\bool_new:N \l__leporello_box_height_bool
-\dim_new:N \l__leporello_box_width_dim
-\dim_new:N \l__leporello_box_height_dim
 \tl_new:N \l__leporello_box_store_width_tl
 \tl_new:N \l__leporello_box_store_height_tl
 \dim_new:N \l__leporello_box_padding_left_dim
@@ -135,24 +151,48 @@
 \box_new:N \l__leporello_box_background_box
 \clist_new:N \l__leporello_box_bleed_clist
 
-\dim_new:N \l__leporello_typeset_box_width_dim
-\dim_new:N \l__leporello_typeset_box_height_dim
+\str_new:N \l_leporello_box_flow_into_str
+\box_new:N \g_leporello_box_flow_temp_box
+\seq_new:N \g_leporello_box_flow_temp_seq
+
+\dim_new:N \l_leporello_typeset_box_width_inner_dim
+\dim_new:N \l_leporello_typeset_box_width_dim
+\dim_new:N \l_leporello_typeset_box_height_dim
 \dim_new:N \l__leporello_typeset_box_bleed_left_dim
 \dim_new:N \l__leporello_typeset_box_bleed_top_dim
 \dim_new:N \l__leporello_typeset_box_bleed_x_dim
 \dim_new:N \l__leporello_typeset_box_bleed_y_dim
 \int_new:N \l__leporello_typeset_coffin_attach_align_int
-\box_new:N \l__leporello_typeset_column_box
-\coffin_new:N \l__leporello_typeset_mark_coffin
+\box_new:N \l_leporello_typeset_column_box
+\coffin_new:N \l_leporello_typeset_mark_coffin
 \coffin_new:N \l__leporello_typeset_mark_temp_coffin
 
 \keys_define:nn { leporello / box } {
-  parent             .code:n = {
-    \clist_if_exist:cF { g_leporello_box_ #1 _children_clist } {
-      \clist_new:c { g_leporello_box_ #1 _children_clist }
+  name               .code:n      = {
+    \prop_gput:NnV \g_leporello_box_names_prop {#1} \g_leporello_box_int
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { name } {#1}
+  } ,
+  flow ~ into        .code:n      = {
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { flow ~ into } {#1}
+  } ,
+  parent             .code:n      = {
+    \prop_if_in:NnTF \g_leporello_box_names_prop {#1} {
+      \clist_if_exist:cF {
+        g_leporello_box_ \prop_item:Nn \g_leporello_box_names_prop {#1} _children_clist
+      } {
+        \clist_new:c {
+          g_leporello_box_ \prop_item:Nn \g_leporello_box_names_prop {#1} _children_clist
+        }
+      }
+      \clist_gput_right:cV {
+        g_leporello_box_ \prop_item:Nn \g_leporello_box_names_prop {#1} _children_clist
+      } \g_leporello_box_int
+      \clist_gput_right:NV \g_leporello_parent_boxes_clist \g_leporello_box_int
+    } {
+      \msg_error:nnn { leporello } { parent-box-undefined } {#1}
     }
-    \clist_gput_right:cV { g_leporello_box_ #1 _children_clist } \g_leporello_box_int
-    \clist_gput_right:NV \g_leporello_parent_boxes_clist \g_leporello_box_int
   } ,
   align ~ parent     .clist_set:N = \l__leporello_box_align_parent_clist ,
   align ~ parent     .initial:n   = { l , t } ,
@@ -161,12 +201,12 @@
   offset             .clist_set:N = \l__leporello_box_offset_clist ,
   offset             .initial:n   = { 0mm , 0mm } ,
   width              .code:n      = {
-    \bool_set_true:N \l__leporello_box_width_bool
-    \dim_set:Nn \l__leporello_box_width_dim {#1}
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { width } {#1}
   } ,
   height             .code:n      = {
-    \bool_set_true:N \l__leporello_box_height_bool
-    \dim_set:Nn \l__leporello_box_height_dim {#1}
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { height } {#1}
   } ,
   stretch ~ height   .bool_set:N  = \l__leporello_box_stretch_height_bool ,
   stretch ~ height   .default:n   = { true } ,
@@ -200,11 +240,15 @@
 }
 
 \bool_new:N \l_leporello_reverse_layout_bool
+\bool_new:N \l_leporello_reverse_order_bool
 
 \keys_define:nn { leporello / print } {
-  reverse ~ layout .bool_set:N = \l_leporello_reverse_layout_bool ,
-  reverse ~ layout .default:n  = { true } ,
-  reverse ~ layout .initial:n  = { false }
+  reverse ~ layout   .bool_set:N  = \l_leporello_reverse_layout_bool ,
+  reverse ~ layout   .default:n   = { true } ,
+  reverse ~ layout   .initial:n   = { false } ,
+  reverse ~ order    .bool_set:N  = \l_leporello_reverse_order_bool ,
+  reverse ~ order    .default:n   = { true } ,
+  reverse ~ order    .initial:n   = { false }
 }
 
 \bool_new:N \l_leporello_image_fill_bleed_bool
@@ -229,19 +273,19 @@
 \keys_define:nn { leporello / image } {
   width              .code:n      = {
     \bool_set_true:N \l_leporello_image_width_bool
-    \dim_set:Nn \l_leporello_image_width_dim {#1} 
+    \dim_set:Nn \l_leporello_image_width_dim {#1}
   } ,
   height             .code:n      = {
     \bool_set_true:N \l_leporello_image_height_bool
-    \dim_set:Nn \l_leporello_image_height_dim {#1} 
+    \dim_set:Nn \l_leporello_image_height_dim {#1}
   } ,
   clip ~ width       .code:n      = {
     \bool_set_true:N \l_leporello_image_clip_width_bool
-    \dim_set:Nn \l_leporello_image_clip_width_dim {#1} 
+    \dim_set:Nn \l_leporello_image_clip_width_dim {#1}
   } ,
   clip ~ height      .code:n      = {
     \bool_set_true:N \l_leporello_image_clip_height_bool
-    \dim_set:Nn \l_leporello_image_clip_height_dim {#1} 
+    \dim_set:Nn \l_leporello_image_clip_height_dim {#1}
   } ,
   offset             .code:n      = {
     \dim_set:Nn \l_leporello_image_offset_x_dim { \clist_item:nn {#1} { 1 } }
@@ -258,11 +302,76 @@
 
 % ===
 
-\hook_new_pair:nn { leporello / column / before } { leporello / column / after }
-\hook_new_pair:nn { leporello / box / before } { leporello / box / after }
+\hook_new_pair:nn { leporello / typeset / before } { leporello / typeset / after }
+\hook_new_pair:nn { leporello / column / begin } { leporello / column / end }
+\hook_new_pair:nn { leporello / box / begin } { leporello / box / end }
 
 % ===
 
+\bool_new:N \l_leporello_layout_vertical_ltr_bool
+\bool_new:N \l_leporello_layout_vertical_rtl_bool
+
+\sys_if_engine_luatex:T {
+  \hook_gput_code:nnn { leporello / typeset / before } { . } {
+    \int_case:nnF { \int_use:N \tex_bodydirection:D } {
+      { 1 } {
+        \bool_set_false:N \l_leporello_layout_vertical_ltr_bool
+        \bool_set_false:N \l_leporello_layout_vertical_rtl_bool
+        \tex_bodydir:D TLT
+        \tex_pardir:D TLT
+        \tex_textdir:D TLT
+        \tex_relax:D
+        \hook_gput_code:nnn { leporello / box / begin } {
+          . / layout
+        } {
+          \tex_bodydir:D TRT
+          \tex_pardir:D TRT
+          \tex_textdir:D TRT
+          \tex_relax:D
+        }
+      }
+      { 2 } {
+        \bool_set_true:N \l_leporello_layout_vertical_ltr_bool
+        \bool_set_false:N \l_leporello_layout_vertical_rtl_bool
+        \tex_bodydir:D TLT
+        \tex_pardir:D TLT
+        \tex_textdir:D TLT
+        \tex_relax:D
+        \hook_gput_code:nnn { leporello / box / begin } {
+          . / layout
+        } {
+          \tex_bodydir:D LTL
+          \tex_pardir:D LTL
+          \tex_textdir:D LTL
+          \tex_relax:D
+        }
+      }
+      { 3 } {
+        \bool_set_false:N \l_leporello_layout_vertical_ltr_bool
+        \bool_set_true:N \l_leporello_layout_vertical_rtl_bool
+        \tex_bodydir:D TLT
+        \tex_pardir:D TLT
+        \tex_textdir:D TLT
+        \tex_relax:D
+        \hook_gput_code:nnn { leporello / box / begin } {
+          . / layout
+        } {
+          \tex_bodydir:D RTT
+          \tex_pardir:D RTT
+          \tex_textdir:D RTT
+          \tex_relax:D
+        }
+      }
+    } {
+      \bool_set_false:N \l_leporello_layout_vertical_ltr_bool
+      \bool_set_false:N \l_leporello_layout_vertical_rtl_bool
+      \hook_gremove_code:nn { leporello / box / begin } { . / layout }
+    }
+  }
+}
+
+% ===
+
 \ProcessKeyOptions [ leporello / global ]
 \LoadClass { article }
 \RequirePackage { geometry }
@@ -271,6 +380,9 @@
 
 \cs_set_eq:NN \leporello_pagestyle_set:n \pagestyle
 \cs_set_eq:NN \leporello_geometry_set:n \geometry
+\cs_new_protected:Npn \leporello_page_gset:n #1 {
+  \setcounter { page } {#1}
+}
 \cs_new_protected:Npn \leoprello_graphics_use:nn #1#2 {
   \includegraphics [ #1 ] {#2}
 }
@@ -294,24 +406,25 @@
   \draw_begin:
     \bool_set_false:N \l_draw_bb_update_bool
     \draw_set_linewidth:n { .25pt }
-    \clist_map_inline:nn { 10mm , \paperwidth - 10mm } {
-      \clist_map_inline:nn { -10mm , 10mm - \paperheight } {
+    \clist_map_inline:nn { 10mm , \l_leporello_paper_width_dim - 10mm } {
+      \clist_map_inline:nn { -10mm , 10mm - \l_leporello_paper_height_dim } {
         \draw_scope_begin:
           \draw_transform_shift:n {
             ##1 , ####1
           }
           \draw_path_moveto:n {
-            \dim_sign:n { ##1 - \paperwidth / 2 } * 5pt , 0pt
+            \dim_sign:n { ##1 - \l_leporello_paper_width_dim / 2 } * 5pt , 0pt
           }
           \draw_path_lineto:n {
-            \dim_sign:n { ##1 - \paperwidth / 2 } * 20pt , 0pt
+            \dim_sign:n { ##1 - \l_leporello_paper_width_dim / 2 } * 20pt , 0pt
           }
           \draw_path_use:n { stroke }
-        \draw_scope_end:      
+        \draw_scope_end:
       }
     }
   \draw_end:
 }
+
 \cs_new_protected:Npn \__leporello_cropmarks:n #1 {
   \draw_begin:
     \bool_set_false:N \l_draw_bb_update_bool
@@ -326,7 +439,7 @@
     \draw_scope_end:
     \draw_scope_begin:
       \draw_transform_shift:n {
-        #1 , 10mm - \paperheight
+        #1 , 10mm - \l_leporello_paper_height_dim
       }
       \draw_path_moveto:n { 0pt , -5pt }
       \draw_path_lineto:n { 0pt , -20pt }
@@ -334,6 +447,7 @@
     \draw_scope_end:
   \draw_end:
 }
+
 \cs_new_protected:Npn \__leporello_id_mark:n #1 {
   \draw_begin:
     \bool_set_false:N \l_draw_bb_update_bool
@@ -344,78 +458,10 @@
     }
     \draw_coffin_use:Nnn \l__leporello_typeset_mark_temp_coffin
       { hc } { vc }
-  \draw_end:  
+  \draw_end:
 }
 
-\hook_gput_code:nnn { begindocument / before } { . } {
-  \leporello_pagestyle_set:n { empty }
-  \dim_set:Nn \l__leporello_paper_height_dim {
-    \l_leporello_layout_height_dim + 2 \l_leporello_info_area_dim
-  }
-  \dim_set:Nn \l__leporello_paper_width_dim {
-    \l__leporello_layout_width_dim + 2 \l_leporello_info_area_dim
-  }
-  \bool_if:NTF \l_leporello_prepress_bool {
-    \leporello_geometry_set:n {
-      layoutwidth = \l__leporello_layout_width_dim ,
-      layoutheight = \l_leporello_layout_height_dim ,
-      layouthoffset = \l_leporello_info_area_dim ,
-      layoutvoffset = \l_leporello_info_area_dim ,
-      paperwidth = \l__leporello_paper_width_dim ,
-      paperheight = \l__leporello_paper_height_dim ,
-      margin = 0pt
-    }
-    \hook_gput_code:nnn { shipout / foreground } { . } {
-      \__leporello_cropmarks:
-      \dim_set:Nn \l_leporello_current_column_offset_dim {
-        \l_leporello_info_area_dim
-      }
-      \__leporello_cropmarks:n { \l_leporello_current_column_offset_dim }
-      \clist_map_inline:Nn \l_leporello_columns_clist {
-        \dim_add:Nn \l_leporello_current_column_offset_dim {
-          #1
-        }
-        \__leporello_cropmarks:n { \l_leporello_current_column_offset_dim }
-      }
-    }
-  } {
-    \leporello_geometry_set:n {
-      paperwidth = \l__leporello_layout_width_dim ,
-      paperheight = \l_leporello_layout_height_dim ,
-      margin = 0pt
-    }
-  }
-  \dim_set:Nn \tex_topskip:D { 0pt }
-  \dim_set:Nn \tex_parindent:D { 0pt }
-}
-
-\NewDocumentCommand { \leporelloset } { m } {
-  \keys_set:nn { leporello / global } {#1}
-}
-
-\NewDocumentCommand { \leporellosetstyle } { m m } {
-  \keys_define:nn { leporello / box } {
-    #1  .meta:n = {#2}
-  }
-}
-
-\NewDocumentCommand { \leporelloboxwidth } { } {
-  \dim_use:N \l__leporello_typeset_box_width_dim
-}
-
-\NewDocumentCommand { \leporellobleed } { } {
-  \dim_use:N \l_leporello_bleed_dim
-}
-
-\NewDocumentCommand { \leporellocolordefine } { m m m } {
-  \color_set:nnn {#1} {#2} {#3}
-}
-
-\NewDocumentCommand { \leporellocolorselect } { m } {
-  \color_select:n {#1}
-}
-
-\NewDocumentCommand { \leporelloimage } { O{} m } {
+\cs_new:Npn \leporello_typeset_image:nn #1#2 {
   \group_begin:
     \keys_set:nn { leporello / image } {#1}
 
@@ -422,7 +468,7 @@
     \int_compare:nNnT { \l_leporello_current_box_int } = { 0 } {
       \msg_error:nn { leporello } { image-outside-box }
     }
-  
+
     \hbox_set:Nn \l__leporello_image_original_box {
       \leoprello_graphics_use:nn { } {#2}
     }
@@ -522,12 +568,12 @@
           }
         }
       }
-      \int_compare:nNnT { 
+      \int_compare:nNnT {
         \l_leporello_current_column_int
       } = { \l_leporello_column_count_int } {
         \clist_if_in:enT {
           \prop_item:cn {
-            g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop 
+            g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop
           } { bleed }
         } { r } {
           \dim_add:Nn \l_leporello_image_outer_offset_right_dim {
@@ -592,7 +638,7 @@
         } ~
         \dim_to_decimal_in_bp:n {
           \fp_to_dim:n {
-            ( 
+            (
               \l_leporello_image_clip_width_dim +
               \l_leporello_image_offset_x_dim
             ) / \l_leporello_image_scale_fp
@@ -612,122 +658,126 @@
   \group_end:
 }
 
-\NewDocumentEnvironment { leporellocolumn } { m +b } {
-  \clist_new:c { g_leporello_column_ #1 _boxes_clist }
-  \tl_if_exist:cF { g_leporello_column_ #1 _tl } {
-    \tl_new:c { g_leporello_column_ #1 _tl }
+\cs_new_protected:Npn \__leporello_box_break_flow:n #1 {
+  \prop_if_in:cnT { g_leporello_box_ #1 _prop } { name } {
+    \tl_if_exist:cT {
+      g_leporello_box_ \prop_item:cn { g_leporello_box_ #1 _prop } { name } _tl
+    } {
+      \tl_gput_left:cn { g_leporello_box_ #1 _tl } {
+        \tl_use:c {
+          g_leporello_box_ \prop_item:cn { g_leporello_box_ #1 _prop } { name } _tl
+        }
+      }
+    }
   }
-  \tl_gset:cn { g_leporello_column_ #1 _tl } {
-    \clist_gclear:c { g_leporello_column_ #1 _boxes_clist }
-    #2
-  }
-} { }
-
-\cs_new_protected:Npn \__leporello_box_store:nn #1#2 {
-  \tl_if_exist:cF { g_leporello_box_ #1 _tl } {
-    \tl_new:c { g_leporello_box_ #1 _tl }
-  }
-  \tl_gput_right:cn { g_leporello_box_ #1 _tl } {
-    \int_set:Nn \l_leporello_current_box_int {#1}
-    \prop_item:cn { g_leporello_box_ #1 _prop } { pre }
-    #2
-  }
-}
-\cs_generate_variant:Nn \__leporello_box_store:nn { Vn }
-
-\NewDocumentEnvironment { leporellobox } { O{} +b } {
-  \group_begin:
-    \int_gincr:N \g_leporello_box_int
-    
-    \str_if_empty:NT \l_leporello_current_column_str {
-      \msg_error:nnV { leporello } { box-outside-column }
-        \g_leporello_box_int
+  \prop_if_in:cnT { g_leporello_box_ #1 _prop } { flow ~ into } {
+    \str_set:Ne \l_leporello_box_flow_into_str {
+      \prop_item:cn { g_leporello_box_ #1 _prop } { flow ~ into }
     }
 
-    \clist_gput_right:cV {
-      g_leporello_column_ \str_use:N \l_leporello_current_column_str _boxes_clist
-    } \g_leporello_box_int
-
-    \prop_new:c { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-    \keys_set:nn { leporello / box } {#1}
-    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { align ~ parent }
-      { \clist_use:Nn \l__leporello_box_align_parent_clist { , } }
-    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { align ~ self }
-      { \clist_use:Nn \l__leporello_box_align_self_clist { , } }
-    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { offset }
-      { \clist_use:Nn \l__leporello_box_offset_clist { , } }
-    \bool_if:NT \l__leporello_box_width_bool {
-      \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-        { width }
-        \l__leporello_box_width_dim
+    \box_new:c {
+      g_leporello_box_flow_ \str_use:N \l_leporello_box_flow_into_str _box
     }
-    \bool_if:NT \l__leporello_box_height_bool {
-      \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-        { height }
-        \l__leporello_box_height_dim
+    \tl_if_exist:cF { g_leporello_box_ \str_use:N \l_leporello_box_flow_into_str _tl } {
+      \tl_new:c { g_leporello_box_ \str_use:N \l_leporello_box_flow_into_str _tl }
     }
-    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { stretch ~ height }
-      { \bool_if_p:N \l__leporello_box_stretch_height_bool }
-    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { padding ~ left }
-      \l__leporello_box_padding_left_dim
-    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { padding ~ right }
-      \l__leporello_box_padding_right_dim
-    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { padding ~ top }
-      \l__leporello_box_padding_top_dim
-    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { padding ~ bottom }
-      \l__leporello_box_padding_bottom_dim
-    \prop_gput:cno { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { pre }
-      { \l__leporello_box_pre_tl }
-    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { background ~ color }
-      \l__leporello_box_background_color_tl
-    \prop_gput:cno { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { background ~ code }
-      { \l__leporello_box_background_code_tl }
-    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
-      { bleed }
-      { \clist_use:Nn \l__leporello_box_bleed_clist { , } }
 
-    \tl_if_empty:NF \l__leporello_box_store_width_tl {
-      \tl_const:co { c_leporello_box_ \int_use:N \g_leporello_box_int _store_width_tl } {
-        \l__leporello_box_store_width_tl
+    \tl_if_in:cnTF { g_leporello_box_ #1 _tl } {
+      \leporelloboxbreak
+    } {
+      \seq_gset_split:Nne \g_leporello_box_flow_temp_seq {
+        \leporelloboxbreak
+      } {
+        \tl_use:c { g_leporello_box_ #1 _tl }
       }
-      \exp_args:No \tl_if_empty:NF { \l__leporello_box_store_width_tl } {
-        \exp_args:No \dim_new:N { \l__leporello_box_store_width_tl }
+      \tl_clear:c { g_leporello_box_ #1 _tl }
+      \vbox_gset_top:Nn \g_leporello_box_flow_temp_box {
+        \prop_item:cn { g_leporello_box_ #1 _prop } { pre }
+        \seq_item:Nn \g_leporello_box_flow_temp_seq { 1 }
+        \group_begin:
+          \skip_zero:N \tex_parfillskip:D
+          \tex_par:D
+        \group_end:
       }
-    }
-    \tl_if_empty:NF \l__leporello_box_store_height_tl {
-      \tl_const:co { c_leporello_box_ \int_use:N \g_leporello_box_int _store_height_tl } {
-        \l__leporello_box_store_height_tl
+      \tl_gput_left:ce { g_leporello_box_ \str_use:N \l_leporello_box_flow_into_str _tl } {
+        \prop_item:cn { g_leporello_box_ #1 _prop } { pre }
+        \tex_noindent:D
+        \seq_item:Nn \g_leporello_box_flow_temp_seq { 2 }
+        \tex_par:D
       }
-      \exp_args:No \tl_if_empty:NF { \l__leporello_box_store_height_tl } {
-        \exp_args:No \dim_new:N { \l__leporello_box_store_height_tl }
+    } {
+      \vbox_gset_top:cn {
+        g_leporello_box_flow_ \str_use:N \l_leporello_box_flow_into_str _box
+      } {
+        \tl_use:c { g_leporello_box_ #1 _tl }
       }
+      \tl_clear:c { g_leporello_box_ #1 _tl }
+      \group_begin:
+        \skip_zero:N \tex_splittopskip:D
+        \vbox_gset_split_to_ht:Ncn \g_leporello_box_flow_temp_box {
+          g_leporello_box_flow_ \str_use:N \l_leporello_box_flow_into_str _box
+        } {
+          \bool_lazy_or:nnTF {
+            \l_leporello_layout_vertical_ltr_bool
+          } {
+            \l_leporello_layout_vertical_rtl_bool
+          } {
+            \prop_if_in:cnTF { g_leporello_box_ #1 _prop } { width } {
+              \prop_item:cn { g_leporello_box_ #1 _prop } { width }
+            } {
+              \clist_item:Nn \l_leporello_columns_clist {
+                \int_use:N \l_leporello_current_column_int
+              }
+            } -
+            \prop_item:cn { g_leporello_box_ #1 _prop } { padding ~ left } -
+            \prop_item:cn { g_leporello_box_ #1 _prop } { padding ~ right }
+          } {
+            \prop_if_in:cnTF { g_leporello_box_ #1 _prop } { height } {
+              \prop_item:cn { g_leporello_box_ #1 _prop } { height }
+            } {
+              \l_leporello_layout_height_dim
+            } -
+            \prop_item:cn { g_leporello_box_ #1 _prop } { padding ~ top } -
+            \prop_item:cn { g_leporello_box_ #1 _prop } { padding ~ bottom }
+          }
+        }
+      \group_end:
+      \tl_gput_left:ce { g_leporello_box_ \str_use:N \l_leporello_box_flow_into_str _tl } {
+        \exp_not:N \box_use_drop:c {
+          g_leporello_box_flow_ \str_use:N \l_leporello_box_flow_into_str _box
+        }
+      }
     }
+    \vbox_top:n {
+      \vbox_unpack_drop:N \g_leporello_box_flow_temp_box
+    }
+  }
+}
 
-    \__leporello_box_store:Vn \g_leporello_box_int {#2}
-  \group_end:
-} { }
-
 \cs_new_protected:Npn \__leporello_box_construct:nnn #1#2#3 {
   \coffin_if_exist:cF { g_leporello_box_ #1 _ #2 _ #3 _outer_coffin } {
-    \prop_if_in:cnTF { g_leporello_box_ #3 _prop } { width } {
-      \dim_set:Nn \l__leporello_typeset_box_width_dim {
-        \prop_item:cn { g_leporello_box_ #3 _prop } { width }
+    \dim_set:Nn \l_leporello_typeset_box_width_inner_dim {
+      \bool_lazy_or:nnTF {
+        \l_leporello_layout_vertical_ltr_bool
+      } {
+        \l_leporello_layout_vertical_rtl_bool
+      } {
+        \prop_if_in:cnTF { g_leporello_box_ #1 _prop } {height } {
+          \prop_item:cn { g_leporello_box_ #3 _prop } { height }
+        } {
+          \l_leporello_layout_height_dim
+        } -
+        \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ top } -
+        \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ bottom }
+      } {
+        \prop_if_in:cnTF { g_leporello_box_ #3 _prop } { width } {
+          \prop_item:cn { g_leporello_box_ #3 _prop } { width }
+        } {
+          \clist_item:Nn \l_leporello_columns_clist {#2}
+        } -
+        \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ left } -
+        \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ right }
       }
-    } {
-      \dim_set:Nn \l__leporello_typeset_box_width_dim {
-        \clist_item:Nn \l_leporello_columns_clist {#2}
-      }
     }
 
     \coffin_new:c {
@@ -736,24 +786,29 @@
     \vcoffin_gset:cnn {
       g_leporello_box_ #1 _ #2 _ #3 _inner_coffin
     } {
-      \l__leporello_typeset_box_width_dim -
-        \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ left } -
-        \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ right }
+      \l_leporello_typeset_box_width_inner_dim
     } {
       \draw_suspend_begin:
         \int_set:Nn \l_leporello_current_box_int {#3}
-        \hook_use:n { leporello / box / before }
+        \hook_use:n { leporello / box / begin }
+          \__leporello_box_break_flow:n {#3}
           \tl_use:c { g_leporello_box_ #3 _tl }
-        \hook_use:n { leporello / box / after }
+        \hook_use:n { leporello / box / end }
       \draw_suspend_end:
     }
 
-    \prop_if_in:cnTF { g_leporello_box_ #3 _prop } { height }  {
-      \dim_set:Nn \l__leporello_typeset_box_height_dim {
+    \dim_set:Nn \l_leporello_typeset_box_width_dim {
+      \prop_if_in:cnTF { g_leporello_box_ #3 _prop } { width } {
+        \prop_item:cn { g_leporello_box_ #3 _prop } { width }
+      } {
+        \clist_item:Nn \l_leporello_columns_clist {#2}
+      }
+    }
+
+    \dim_set:Nn \l_leporello_typeset_box_height_dim {
+      \prop_if_in:cnTF { g_leporello_box_ #3 _prop } { height } {
         \prop_item:cn { g_leporello_box_ #3 _prop } { height }
-      }
-    } {
-      \dim_set:Nn \l__leporello_typeset_box_height_dim {
+      } {
         \coffin_ht:c {
           g_leporello_box_ #1 _ #2 _ #3 _inner_coffin
         } +
@@ -766,7 +821,7 @@
     }
 
     \bool_if:nT { \prop_item:cn { g_leporello_box_ #3 _prop } { stretch ~ height } } {
-      \dim_set:Nn \l__leporello_typeset_box_height_dim {
+      \dim_set:Nn \l_leporello_typeset_box_height_dim {
         \fp_to_dim:n {
           \l_leporello_layout_height_dim -
           (
@@ -795,7 +850,7 @@
         \dim_add:Nn \l__leporello_typeset_box_bleed_x_dim { \l_leporello_bleed_dim }
       }
     }
-    \skip_set:Nn \tex_hfuzz:D { \l__leporello_typeset_box_bleed_x_dim } 
+    \skip_set:Nn \tex_hfuzz:D { \l__leporello_typeset_box_bleed_x_dim }
 
     \clist_if_in:enT {
       \prop_item:cn { g_leporello_box_ #3 _prop } { bleed }
@@ -807,7 +862,7 @@
     } { b } {
       \dim_add:Nn \l__leporello_typeset_box_bleed_y_dim { \l_leporello_bleed_dim }
     }
-    \skip_set:Nn \tex_vfuzz:D { \l__leporello_typeset_box_bleed_y_dim } 
+    \skip_set:Nn \tex_vfuzz:D { \l__leporello_typeset_box_bleed_y_dim }
 
     \coffin_new:c {
       g_leporello_box_ #1 _ #2 _ #3 _outer_coffin
@@ -814,13 +869,13 @@
     }
     \vcoffin_gset:cnn {
       g_leporello_box_ #1 _ #2 _ #3 _outer_coffin
-    } { \l__leporello_typeset_box_width_dim } {
+    } { \l_leporello_typeset_box_width_dim } {
       \draw_suspend_begin:
         \draw_begin:
           \draw_path_rectangle:nn { 0mm , 0mm } {
-            \l__leporello_typeset_box_width_dim +
+            \l_leporello_typeset_box_width_dim +
             \l__leporello_typeset_box_bleed_x_dim ,
-            \l__leporello_typeset_box_height_dim +
+            \l_leporello_typeset_box_height_dim +
             \l__leporello_typeset_box_bleed_y_dim
           }
           \str_if_eq:enF {
@@ -840,7 +895,7 @@
             }
             \draw_box_use:Nn \l__leporello_box_background_box {
               0mm ,
-              \l__leporello_typeset_box_height_dim +
+              \l_leporello_typeset_box_height_dim +
               \l__leporello_typeset_box_bleed_y_dim -
               \box_ht:N \l__leporello_box_background_box
             }
@@ -852,44 +907,57 @@
     \tl_if_exist:cT { c_leporello_box_ #3 _store_width_tl } {
       \exp_args:NNo \exp_args:No
         \dim_set_eq:NN { \use:c { c_leporello_box_ #3 _store_width_tl } }
-          \l__leporello_typeset_box_width_dim
+          \l_leporello_typeset_box_width_dim
     }
     \tl_if_exist:cT { c_leporello_box_ #3 _store_height_tl } {
       \exp_args:NNo \exp_args:No
         \dim_set_eq:NN { \use:c { c_leporello_box_ #3 _store_height_tl } }
-          \l__leporello_typeset_box_height_dim
+          \l_leporello_typeset_box_height_dim
     }
-  
+
     \bool_if:NT \l_leporello_show_id_bool {
-      \hcoffin_set:Nn \l__leporello_typeset_mark_coffin {
+      \hcoffin_set:Nn \l_leporello_typeset_mark_coffin {
         \__leporello_id_mark:n { #3 }
       }
       \coffin_attach:cnnNnnnn {
-        g_leporello_box_ 
+        g_leporello_box_
           \int_use:N \l_leporello_current_page_int _
           \int_use:N \l_leporello_current_column_int _
           #3 _inner_coffin
-        } { hc } { vc } 
-        \l__leporello_typeset_mark_coffin
+        } { hc } { vc }
+        \l_leporello_typeset_mark_coffin
         { hc } { vc } { 0pt } { 0pt }
     }
 
     \__leporello_box_set_bleed:n {#3}
 
-    \coffin_attach:cnncnnnn {
-      g_leporello_box_ 
+    \coffin_attach:cencennn {
+      g_leporello_box_
         \int_use:N \l_leporello_current_page_int _
         \int_use:N \l_leporello_current_column_int _
         #3 _outer_coffin
-    } { l } { t } {
-      g_leporello_box_ 
+    } {
+      \bool_if:NTF \l_leporello_layout_vertical_rtl_bool { r } { l }
+    } { t } {
+      g_leporello_box_
         \int_use:N \l_leporello_current_page_int _
         \int_use:N \l_leporello_current_column_int _
         #3 _inner_coffin
-    } { l } { t } {
-      \fp_to_dim:n {
-        \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ left } +
-        \l__leporello_typeset_box_bleed_left_dim
+    } {
+      \bool_if:NTF \l_leporello_layout_vertical_rtl_bool { r } { l }
+    } { t } {
+      \bool_if:NTF \l_leporello_layout_vertical_rtl_bool {
+        \fp_to_dim:n {
+          (
+            \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ right } +
+            \l__leporello_typeset_box_bleed_left_dim
+          ) * -1
+        }
+      } {
+        \fp_to_dim:n {
+          \prop_item:cn { g_leporello_box_ #3 _prop } { padding ~ left } +
+          \l__leporello_typeset_box_bleed_left_dim
+        }
       }
     } {
       \fp_to_dim:n {
@@ -941,15 +1009,15 @@
       \dim_sub:Nn \l__leporello_typeset_box_bleed_top_dim {
         \l_leporello_bleed_dim
       }
-    } 
+    }
   } {
     \int_set:Nn \l__leporello_typeset_coffin_attach_align_int { -1 }
   }
 
   \prop_if_exist:cT { g_leporello_box_ #1 _prop } {
-    \clist_if_in:enT {
-      \prop_item:cn { g_leporello_box_ #2 _prop } { align ~ parent }
-    } { l } {
+    \int_compare:nNnT {
+      \l_leporello_current_column_int
+    } = { 1 } {
       \clist_if_in:enT {
         \prop_item:cn { g_leporello_box_ #1 _prop } { bleed }
       } { l } {
@@ -960,17 +1028,6 @@
     }
     \clist_if_in:enT {
       \prop_item:cn { g_leporello_box_ #2 _prop } { align ~ parent }
-    } { r } {
-      \clist_if_in:enT {
-        \prop_item:cn { g_leporello_box_ #1 _prop } { bleed }
-      } { r } {
-        \dim_sub:Nn \l__leporello_typeset_box_bleed_left_dim {
-          \l_leporello_bleed_dim
-        }
-      }
-    }
-    \clist_if_in:enT {
-      \prop_item:cn { g_leporello_box_ #2 _prop } { align ~ parent }
     } { t } {
       \clist_if_in:enT {
         \prop_item:cn { g_leporello_box_ #1 _prop } { bleed }
@@ -997,7 +1054,7 @@
     \int_compare:nNnTF {#1} = { 0 } {
       l_leporello_current_column_coffin
     } {
-      g_leporello_box_ 
+      g_leporello_box_
         \int_use:N \l_leporello_current_page_int _
         \int_use:N \l_leporello_current_column_int _
         #1 _outer_coffin
@@ -1011,7 +1068,7 @@
       \prop_item:cn { g_leporello_box_ #2 _prop } { align ~ parent }
     } { 2 }
   } {
-    g_leporello_box_ 
+    g_leporello_box_
       \int_use:N \l_leporello_current_page_int _
       \int_use:N \l_leporello_current_column_int _
       #2 _outer_coffin
@@ -1058,7 +1115,19 @@
   }
 }
 
-\NewDocumentCommand { \leporellotypesetcolumns } { O{} m } {
+\cs_new_protected:Npn \__leporello_box_store:nn #1#2 {
+  \tl_if_exist:cF { g_leporello_box_ #1 _tl } {
+    \tl_new:c { g_leporello_box_ #1 _tl }
+  }
+  \tl_gput_right:cn { g_leporello_box_ #1 _tl } {
+    \int_set:Nn \l_leporello_current_box_int {#1}
+    \prop_item:cn { g_leporello_box_ #1 _prop } { pre }
+    #2
+  }
+}
+\cs_generate_variant:Nn \__leporello_box_store:nn { Vn }
+
+\cs_new_protected:Npn \leporello_typeset_columns:nn #1#2 {
   \int_incr:N \l_leporello_current_page_int
 
   \int_compare:nNnT { \clist_count:n {#2} } > {
@@ -1069,19 +1138,65 @@
   }
 
   \group_begin:
+    \hook_use:n { leporello / typeset / before }
     \keys_set:nn { leporello / print } {#1}
     \bool_if:NT \l_leporello_reverse_layout_bool {
       \clist_reverse:N \l_leporello_columns_clist
     }
 
-    \int_zero:N \l_leporello_current_column_int
-    \dim_zero:N \l_leporello_current_column_offset_dim
+    \bool_if:NTF \l_leporello_reverse_order_bool {
+      \int_set:Nn \l_leporello_current_column_int {
+        \l_leporello_column_count_int
+      }
+      \dim_zero:N \l_leporello_current_column_offset_dim
+      \clist_map_inline:Nn \l_leporello_columns_clist {
+        \dim_add:Nn \l_leporello_current_column_offset_dim {##1}
+      }
+    } {
+      \int_zero:N \l_leporello_current_column_int
+      \dim_zero:N \l_leporello_current_column_offset_dim
+    }
+
     \leporello_draw_absolute:nn { 0mm , 0mm } {
       \clist_map_inline:nn {#2} {
-        \int_incr:N \l_leporello_current_column_int
+        \bool_if:NTF \l_leporello_reverse_order_bool {
+          \dim_sub:Nn \l_leporello_current_column_offset_dim {
+            \clist_item:NV \l_leporello_columns_clist
+              \l_leporello_current_column_int
+          }
+        } {
+          \int_incr:N \l_leporello_current_column_int
+        }
+        \leporello_page_gset:n {
+          \bool_if:NTF \l_leporello_continuous_pagination_bool {
+            \int_eval:n {
+              ( \l_leporello_current_page_int - 1 ) *
+              \l_leporello_column_count_int +
+              \l_leporello_current_column_int
+            }
+          } {
+            \int_eval:n {
+              \int_div_truncate:nn {
+                \l_leporello_current_page_int - 1
+              } { 2 } *
+              \l_leporello_column_count_int * 2 +
+              \int_mod:nn {
+                \int_mod:nn {
+                  \l_leporello_current_page_int
+                } { 2 } *
+                \l_leporello_column_count_int +
+                \l_leporello_current_column_int
+              } {
+                \l_leporello_column_count_int * 2
+              } + 1
+            }
+          }
+        }
 
-        \tl_if_exist:cF { g_leporello_column_ ##1 _tl } {
-          \msg_error:nnn { leporello } { column-undefined } {##1}
+        \str_if_eq:nnF {##1} { . } {
+          \tl_if_exist:cF { g_leporello_column_ ##1 _tl } {
+            \msg_error:nnn { leporello } { column-undefined } {##1}
+          }
         }
 
         \vcoffin_set:Nnn \l_leporello_current_column_coffin {
@@ -1096,40 +1211,47 @@
                 \l_leporello_layout_height_dim
               }
               \draw_path_use_clear:n { clip }
-              \vbox_set_top:Nn \l__leporello_typeset_column_box {
-                \draw_suspend_begin:
-                  \str_set:Nn \l_leporello_current_column_str {##1}
-                  \hook_use:n { leporello / column / before }
-                    \tl_use:c { g_leporello_column_ ##1 _tl }
-                  \hook_use:n { leporello / column / after }
-                \draw_suspend_end:
+              \str_if_eq:nnF {##1} { . } {
+                \vbox_set_top:Nn \l_leporello_typeset_column_box {
+                  \draw_suspend_begin:
+                    \str_set:Nn \l_leporello_current_column_str {##1}
+                    \hook_use:n { leporello / column / begin }
+                      \tl_use:c { g_leporello_column_ ##1 _tl }
+                    \hook_use:n { leporello / column / end }
+                  \draw_suspend_end:
+                }
+                \draw_box_use:N \l_leporello_typeset_column_box
               }
-              \draw_box_use:N \l__leporello_typeset_column_box
             \draw_end:
           \draw_suspend_end:
         }
 
-        \clist_map_inline:cn { g_leporello_column_ ##1 _boxes_clist } {
-          \__leporello_box_construct:VVn
-            \l_leporello_current_page_int
-            \l_leporello_current_column_int
-            {####1}
-          \iow_log:n {####1}
-          \__leporello_box_attach_children:n {####1}
-        }
-        \clist_map_inline:cn { g_leporello_column_ ##1 _boxes_clist } {
-          \clist_if_in:NnF \g_leporello_parent_boxes_clist {####1} {
-            \__leporello_box_set_bleed:n {####1}
-            \__leporello_boxes_attach:nn { 0 } {####1}
+        \str_if_eq:nnF {##1} { . } {
+          \clist_map_inline:cn { g_leporello_column_ ##1 _boxes_clist } {
+            \__leporello_box_construct:VVn
+              \l_leporello_current_page_int
+              \l_leporello_current_column_int
+              {####1}
+            \__leporello_box_attach_children:n {####1}
           }
+          \clist_map_inline:cn { g_leporello_column_ ##1 _boxes_clist } {
+            \clist_if_in:NnF \g_leporello_parent_boxes_clist {####1} {
+              \__leporello_box_set_bleed:n {####1}
+              \__leporello_boxes_attach:nn { 0 } {####1}
+            }
+          }
         }
 
         \draw_coffin_use:Nnnn \l_leporello_current_column_coffin
           { l } { t } { \l_leporello_current_column_offset_dim , 0mm }
 
-        \dim_add:Nn \l_leporello_current_column_offset_dim {
-          \clist_item:NV \l_leporello_columns_clist
-            \l_leporello_current_column_int
+        \bool_if:NTF \l_leporello_reverse_order_bool {
+          \int_decr:N \l_leporello_current_column_int
+        } {
+          \dim_add:Nn \l_leporello_current_column_offset_dim {
+            \clist_item:NV \l_leporello_columns_clist
+              \l_leporello_current_column_int
+          }
         }
       }
 
@@ -1151,105 +1273,185 @@
         }
       }
     }
+    \hook_use:n { leporello / typeset / after }
   \group_end:
 }
+\cs_generate_variant:Nn \leporello_typeset_columns:nn { nV }
 
-% === Flow mechanism
+\hook_gput_code:nnn { begindocument / before } { . } {
+  \leporello_pagestyle_set:n { empty }
+  \dim_set:Nn \l_leporello_paper_height_dim {
+    \l_leporello_layout_height_dim + 2 \l_leporello_info_area_dim
+  }
+  \dim_set:Nn \l_leporello_paper_width_dim {
+    \l_leporello_layout_width_dim + 2 \l_leporello_info_area_dim
+  }
+  \bool_if:NTF \l_leporello_prepress_bool {
+    \leporello_geometry_set:n {
+      layoutwidth = \l_leporello_layout_width_dim ,
+      layoutheight = \l_leporello_layout_height_dim ,
+      layouthoffset = \l_leporello_info_area_dim ,
+      layoutvoffset = \l_leporello_info_area_dim ,
+      paperwidth = \l_leporello_paper_width_dim ,
+      paperheight = \l_leporello_paper_height_dim ,
+      margin = 0pt
+    }
+    \hook_gput_code:nnn { shipout / foreground } { . } {
+      \__leporello_cropmarks:
+      \dim_set:Nn \l_leporello_current_column_offset_dim {
+        \l_leporello_info_area_dim
+      }
+      \__leporello_cropmarks:n { \l_leporello_current_column_offset_dim }
+      \clist_map_inline:Nn \l_leporello_columns_clist {
+        \dim_add:Nn \l_leporello_current_column_offset_dim {
+          #1
+        }
+        \__leporello_cropmarks:n { \l_leporello_current_column_offset_dim }
+      }
+    }
+  } {
+    \leporello_geometry_set:n {
+      paperwidth = \_leporello_layout_width_dim ,
+      paperheight = \l_leporello_layout_height_dim ,
+      margin = 0pt
+    }
+  }
+  \dim_set:Nn \tex_topskip:D { 0pt }
+  \dim_set:Nn \tex_parindent:D { 0pt }
+}
 
-\int_new:N \l_leporello_box_flow_into_int
-\box_new:N \g_leporello_box_flow_temp_box
-\seq_new:N \g_leporello_box_flow_temp_seq
-\dim_new:N \l_leporello_box_flow_width_first_dim
-\dim_new:N \l_leporello_box_flow_width_second_dim
+\clist_new:N \l_leporello_auto_typeset_temp_clist
 
-\keys_define:nn { leporello / box } {
-  flow ~ into        .code:n = {
-    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop } 
-      { flow ~ into } {#1}
+\hook_gput_code:nnn { enddocument } { . } {
+  \bool_if:NT \l_leporello_auto_typeset_bool {
+    \int_zero:N \l_leporello_auto_typeset_int
+    \clist_clear:N \l_leporello_auto_typeset_temp_clist
+    \clist_map_inline:Nn \g_leporello_auto_typeset_clist {
+      \int_compare:nNnTF {
+        \l_leporello_auto_typeset_int
+      } < {
+        \l_leporello_column_count_int
+      } {
+        \clist_put_right:Nn \l_leporello_auto_typeset_temp_clist {#1}
+      } {
+        \leporello_typeset_columns:nV { } \l_leporello_auto_typeset_temp_clist
+        \clist_clear:N \l_leporello_auto_typeset_temp_clist
+        \int_zero:N \l_leporello_auto_typeset_int
+        \clist_put_right:Nn \l_leporello_auto_typeset_temp_clist {#1}
+      }
+      \int_incr:N \l_leporello_auto_typeset_int
+    }
+    \clist_if_empty:NF \l_leporello_auto_typeset_temp_clist {
+      \leporello_typeset_columns:nV { } \l_leporello_auto_typeset_temp_clist
+    }
   }
 }
 
-\hook_gput_code:nnn { leporello / box / before } { . } {
-  \prop_if_in:cnT { g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop } 
-    { flow ~ into } {
-    \int_set:Nn \l_leporello_box_flow_into_int {
-      \prop_item:cn { g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop } 
-        { flow ~ into }
+\NewDocumentEnvironment { leporellocolumn } { m +b } {
+  \clist_new:c { g_leporello_column_ #1 _boxes_clist }
+  \tl_if_exist:cF { g_leporello_column_ #1 _tl } {
+    \tl_new:c { g_leporello_column_ #1 _tl }
+  }
+  \tl_gset:cn { g_leporello_column_ #1 _tl } {
+    \clist_gclear:c { g_leporello_column_ #1 _boxes_clist }
+    #2
+  }
+  \bool_if:NT \l_leporello_auto_typeset_bool {
+    \clist_gput_right:Nn \g_leporello_auto_typeset_clist {#1}
+  }
+} { }
+
+\NewDocumentEnvironment { leporellobox } { O{} +b } {
+  \group_begin:
+    \int_gincr:N \g_leporello_box_int
+
+    \str_if_empty:NT \l_leporello_current_column_str {
+      \msg_error:nnV { leporello } { box-outside-column }
+        \g_leporello_box_int
     }
 
-    \box_new:c {
-      g_leporello_box_flow_ \int_use:N \l_leporello_box_flow_into_int _box
-    }
-    \tl_if_exist:cF { g_leporello_box_ \int_use:N \l_leporello_box_flow_into_int _tl } {
-      \tl_new:c { g_leporello_box_ \int_use:N \l_leporello_box_flow_into_int _tl }
-    }
-        
-    \tl_if_in:cnTF { g_leporello_box_ \int_use:N \l_leporello_current_box_int _tl } {
-      \leporelloboxbreak
-    } {
-      \seq_gset_split:Nne \g_leporello_box_flow_temp_seq {
-        \leporelloboxbreak                
-      } {
-        \tl_use:c { g_leporello_box_ \int_use:N \l_leporello_current_box_int _tl }
+    \clist_gput_right:cV {
+      g_leporello_column_ \str_use:N \l_leporello_current_column_str _boxes_clist
+    } \g_leporello_box_int
+
+    \prop_new:c { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+    \keys_set:nn { leporello / box } {#1}
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { align ~ parent }
+      { \clist_use:Nn \l__leporello_box_align_parent_clist { , } }
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { align ~ self }
+      { \clist_use:Nn \l__leporello_box_align_self_clist { , } }
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { offset }
+      { \clist_use:Nn \l__leporello_box_offset_clist { , } }
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { stretch ~ height }
+      { \bool_if_p:N \l__leporello_box_stretch_height_bool }
+    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { padding ~ left }
+      \l__leporello_box_padding_left_dim
+    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { padding ~ right }
+      \l__leporello_box_padding_right_dim
+    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { padding ~ top }
+      \l__leporello_box_padding_top_dim
+    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { padding ~ bottom }
+      \l__leporello_box_padding_bottom_dim
+    \prop_gput:cno { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { pre }
+      { \l__leporello_box_pre_tl }
+    \prop_gput:cnV { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { background ~ color }
+      \l__leporello_box_background_color_tl
+    \prop_gput:cno { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { background ~ code }
+      { \l__leporello_box_background_code_tl }
+    \prop_gput:cne { g_leporello_box_ \int_use:N \g_leporello_box_int _prop }
+      { bleed }
+      { \clist_use:Nn \l__leporello_box_bleed_clist { , } }
+
+    \tl_if_empty:NF \l__leporello_box_store_width_tl {
+      \tl_const:co { c_leporello_box_ \int_use:N \g_leporello_box_int _store_width_tl } {
+        \l__leporello_box_store_width_tl
       }
-      \tl_clear:c { g_leporello_box_ \int_use:N \l_leporello_current_box_int _tl }
-      \vbox_gset_top:Nn \g_leporello_box_flow_temp_box {
-        \prop_item:cn { g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop } 
-          { pre }
-        \seq_item:Nn \g_leporello_box_flow_temp_seq { 1 }
-        \group_begin:
-          \skip_zero:N \tex_parfillskip:D
-          \tex_par:D
-        \group_end:
+      \exp_args:No \tl_if_empty:NF { \l__leporello_box_store_width_tl } {
+        \exp_args:No \dim_new:N { \l__leporello_box_store_width_tl }
       }
-      \tl_gput_left:ce { g_leporello_box_ \int_use:N \l_leporello_box_flow_into_int _tl } {
-        \prop_item:cn { g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop } 
-          { pre }
-        \tex_noindent:D
-        \seq_item:Nn \g_leporello_box_flow_temp_seq { 2 }
-        \tex_par:D
+    }
+    \tl_if_empty:NF \l__leporello_box_store_height_tl {
+      \tl_const:co { c_leporello_box_ \int_use:N \g_leporello_box_int _store_height_tl } {
+        \l__leporello_box_store_height_tl
       }
-    } {
-      \vbox_gset_top:cn {
-        g_leporello_box_flow_ \int_use:N \l_leporello_box_flow_into_int _box
-      } {
-        \tl_use:c { g_leporello_box_ \int_use:N \l_leporello_current_box_int _tl }
+      \exp_args:No \tl_if_empty:NF { \l__leporello_box_store_height_tl } {
+        \exp_args:No \dim_new:N { \l__leporello_box_store_height_tl }
       }
-      \tl_clear:c { g_leporello_box_ \int_use:N \l_leporello_current_box_int _tl }
-      \group_begin:
-        \skip_zero:N \tex_splittopskip:D
-        \vbox_gset_split_to_ht:Ncn \g_leporello_box_flow_temp_box {
-          g_leporello_box_flow_ \int_use:N \l_leporello_box_flow_into_int _box
-        } { 
-          \prop_if_in:cnTF { 
-            g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop
-          } { height } {
-            \prop_item:cn {
-              g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop
-            } { height }
-          } {
-            \l_leporello_layout_height_dim
-          } -
-          \prop_item:cn {
-             g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop
-          } { padding ~ top } -
-          \prop_item:cn {
-            g_leporello_box_ \int_use:N \l_leporello_current_box_int _prop
-          } { padding ~ bottom }
-        }
-      \group_end:
-      \tl_gput_left:ce { g_leporello_box_ \int_use:N \l_leporello_box_flow_into_int _tl } {
-        \exp_not:N \box_use_drop:c {
-          g_leporello_box_flow_ \int_use:N \l_leporello_box_flow_into_int _box
-        }
-      }
     }
-    \vbox_top:n {
-      \vbox_unpack_drop:N \g_leporello_box_flow_temp_box
-    }
+
+    \__leporello_box_store:Vn \g_leporello_box_int {#2}
+  \group_end:
+} { }
+
+\NewDocumentCommand { \leporelloset } { m } {
+  \keys_set:nn { leporello / global } {#1}
+}
+
+\NewDocumentCommand { \leporellosetstyle } { m m } {
+  \keys_define:nn { leporello / box } {
+    #1  .meta:n = {#2}
   }
 }
 
+\NewDocumentCommand { \leporelloboxwidth } { } {
+  \dim_use:N \l_leporello_typeset_box_width_dim
+}
+
+\NewDocumentCommand { \leporellobleed } { } {
+  \dim_use:N \l_leporello_bleed_dim
+}
+
 \NewDocumentCommand { \leporelloboxbreak } { } {
   \tex_relax:D
 }
@@ -1259,4 +1461,20 @@
   \skip_zero:N \tex_leftskip:D
 }
 
-% EOF
+\NewDocumentCommand { \leporellocolordefine } { m m m } {
+  \color_set:nnn {#1} {#2} {#3}
+}
+
+\NewDocumentCommand { \leporellocolorselect } { m } {
+  \color_select:n {#1}
+}
+
+\NewDocumentCommand { \leporelloimage } { O{} m } {
+  \leporello_typeset_image:nn {#1} {#2}
+}
+
+\NewDocumentCommand { \leporellotypesetcolumns } { O{} m } {
+  \leporello_typeset_columns:nn {#1} {#2}
+}
+
+% EOF
\ No newline at end of file



More information about the tex-live-commits mailing list.