reworked spreadtopages, still not done...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-08-30 18:55:11 +03:00
parent 0ae612ce55
commit c7333e4a4b
2 changed files with 75 additions and 21 deletions

View File

@ -948,19 +948,19 @@
\photobook@ResettableMacro@args{#1}[#2]}} \photobook@ResettableMacro@args{#1}[#2]}}
% pre -- main command definition... % pre -- main command definition...
\def\photobook@ResettableMacro#1#2{% \def\photobook@ResettableMacro#1#2{%
\expandafter\newcommand\csname photobook@#1\endcsname{#2}% \expandafter\newcommand\csname photobook@ResettableMacro@#1\endcsname{#2}%
\photobook@ResettableMacro@tail{#1}} \photobook@ResettableMacro@tail{#1}}
\def\photobook@ResettableMacro@args#1[#2]#3{% \def\photobook@ResettableMacro@args#1[#2]#3{%
\expandafter\newcommand\csname photobook@#1\endcsname[#2]{#3}% \expandafter\newcommand\csname photobook@ResettableMacro@#1\endcsname[#2]{#3}%
\photobook@ResettableMacro@tail{#1}} \photobook@ResettableMacro@tail{#1}}
\def\photobook@ResettableMacro@args@dfl#1[#2][#3]#4{% \def\photobook@ResettableMacro@args@dfl#1[#2][#3]#4{%
\expandafter\newcommand\csname photobook@#1\endcsname[#2][#3]{#4}% \expandafter\newcommand\csname photobook@ResettableMacro@#1\endcsname[#2][#3]{#4}%
\photobook@ResettableMacro@tail{#1}} \photobook@ResettableMacro@tail{#1}}
% post... % post...
\def\photobook@ResettableMacro@tail#1{% \def\photobook@ResettableMacro@tail#1{%
% \reset<name> % \reset<name>
\expandafter\newcommand\csname reset#1\endcsname{% \expandafter\newcommand\csname reset#1\endcsname{%
\expandafter\let\csname #1\expandafter\endcsname\csname photobook@#1\endcsname} \expandafter\let\csname #1\expandafter\endcsname\csname photobook@ResettableMacro@#1\endcsname}
% initialize... % initialize...
\csname reset#1\endcsname} \csname reset#1\endcsname}
@ -1161,6 +1161,7 @@
%%%%% Save cells %%%%% Save cells
%% \DescribeMacro{\savecell\{..\}} %% \DescribeMacro{\savecell\{..\}}
%% \DescribeMacro{\gsavecell\{..\}}
% %
%% Create a saved cell. %% Create a saved cell.
% %
@ -1169,6 +1170,9 @@
%% This is similar to |\newsavebox{..}| and |\sbox{..}| but adds %% This is similar to |\newsavebox{..}| and |\sbox{..}| but adds
%% cell functionality. %% cell functionality.
%% %%
%% |\gsavecell{..}| is the same as |\savecell{..}| but greates a global
%% cell.
%%
% XXX can we make this an env??? % XXX can we make this an env???
% XXX should this be split into \newsavecell{..} and \scell{..} ??? % XXX should this be split into \newsavecell{..} and \scell{..} ???
% XXX can we use root cells inside this??? % XXX can we use root cells inside this???
@ -1183,6 +1187,16 @@
\end{inlinecell*}}% \end{inlinecell*}}%
\ignorespaces} \ignorespaces}
\newcommand\gsavecell[4]{%
% only define a savebox once...
\@ifundefined{#1}{%
\expandafter\newsavebox\csname #1\endcsname}{}
\global\expandafter\sbox\csname #1\endcsname{%
\begin{inlinecell*}{#2}{#3}%
#4%
\end{inlinecell*}}%
\ignorespaces}
% \usecell{..} variants... % \usecell{..} variants...
% %
@ -1975,6 +1989,7 @@
%% \DescribeMacro{spreadtopages} %% \DescribeMacro{spreadtopages}
%% \DescribeMacro{spreadtopages*}
% %
%% Spread cell into pages. %% Spread cell into pages.
%% %%
@ -2008,6 +2023,38 @@
% ...i.e. name + use... % ...i.e. name + use...
% XXX add nudge/grow support... % XXX add nudge/grow support...
% XXX revise name... % XXX revise name...
\NewEnviron{spreadtopages*}[2][2]{%
\newcounter{spreadtopages#2page}
\setcounter{spreadtopages#2page}{1}
\begingroup%
% create the actual cell...
\setlength\cellparentwidth{\cellwidth}%
\setlength\cellparentheight{\cellheight}%
\setlength\cellwidth{#1\pageblockwidth}%
\setlength\cellheight{\pageblockheight}%
%
\gsavecell{#2}{\cellwidth}{\cellheight}{\BODY}%
\endgroup%
\ignorespaces}
\newcommand\usespreadpage[2][]{%
\begin{page}%
\begin{pagecell}%
% auto advance pages...
\ifthenelse{\equal{#1}{}}{%
\usecell*{#2}%
(0pt, \numexpr \value{spreadtopages#2page} - 1 \relax\cellwidth)%
{\cellwidth}{\cellheight}%
\stepcounter{spreadtopages#2page}%
% manual page selected...
}{%
\usecell*{#2}%
(0pt, \numexpr #1 - 1 \relax\cellwidth)%
{\cellwidth}{\cellheight}}%
\end{pagecell}%
\end{page}}
\NewEnviron{spreadtopages}[1][2]{% \NewEnviron{spreadtopages}[1][2]{%
\begingroup% \begingroup%
% create the actual cell... % create the actual cell...
@ -2019,15 +2066,8 @@
\savecell{photobook@spreadtopages}{\cellwidth}{\cellheight}{\BODY}% \savecell{photobook@spreadtopages}{\cellwidth}{\cellheight}{\BODY}%
% %
% generate pages... % generate pages...
\foreach \photobook@spreadtopages@page in {0, ...,\numexpr #1 - 1 \relax}{% \foreach \photobook@spreadtopages@page in {1, ..., #1}{%
\null \usespreadpage[\photobook@spreadtopages@page]{photobook@spreadtopages}}%
\begin{pagecell}%
% NOTE: \cellwidth and \cellheight here are for a single page...
\usecell*{photobook@spreadtopages}%
(0pt, \photobook@spreadtopages@page\cellwidth)%
{\cellwidth}{\cellheight}%
\end{pagecell}%
\clearpage}%
\endgroup% \endgroup%
\ignorespaces} \ignorespaces}
@ -2288,14 +2328,14 @@
\def\ImagePageTemplate#1#2{% \def\ImagePageTemplate#1#2{%
% handle <macro>* version... % handle <macro>* version...
\expandafter\def\csname #1\endcsname{\@ifstar{% \expandafter\def\csname #1\endcsname{\@ifstar{%
\csname photobook@#1\endcsname% \csname photobook@ImagePageTemplate@#1\endcsname%
}{% }{%
\csname photobook@#1@captiontpl\endcsname}}% \csname photobook@ImagePageTemplate@#1@captiontpl\endcsname}}%
% main implementation (raw caption)... % main implementation (raw caption)...
\expandafter\newcommand\csname photobook@#1\endcsname[3][]{#2}% \expandafter\newcommand\csname photobook@ImagePageTemplate@#1\endcsname[3][]{#2}%
% main implementation with caption template... % main implementation with caption template...
\expandafter\newcommand\csname photobook@#1@captiontpl\endcsname[3][]{% \expandafter\newcommand\csname photobook@ImagePageTemplate@#1@captiontpl\endcsname[3][]{%
\csname photobook@#1\endcsname[##1]{% \csname photobook@ImagePageTemplate@#1\endcsname[##1]{%
\@ifundefined{#1caption}{% \@ifundefined{#1caption}{%
##2% ##2%
}{% }{%

View File

@ -18,14 +18,28 @@
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\begin{document} \begin{document}
\begin{spreadtopages*}{moo}{%
\imagecell[fill, clearance=-\bleed]{}{DSC00403-2}}
\end{spreadtopages*}
\usespreadpage{moo}
\usespreadpage{moo}
%\savecell{moo}{\paperwidth}{\paperheight}{
% \imagecell[fill, clearance=-\bleed]{}{DSC00403-2}}
%
%\usespreadpage[2]{moo}
%\usecell{moo}(3cm,3cm){10cm}{10cm}
%\imagepage*{moo}{DSC00403-2} %\imagepage*{moo}{DSC00403-2}
%\imagepage{moo}{DSC00403-2} %\imagepage{moo}{DSC00403-2}