foldouts now fully working..

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-10-12 16:44:11 +03:00
parent 089b345781
commit c98b70a5cf
2 changed files with 93 additions and 117 deletions

View File

@ -51,6 +51,7 @@
auto-calculate auto-calculate
\end{foldout} \end{foldout}
%\begin{foldout}[in 15cm 10cm]
\begin{foldout}[in in 10cm] \begin{foldout}[in in 10cm]
count count
\begin{foldoutcell}[2] \begin{foldoutcell}[2]
@ -89,6 +90,14 @@
\lipsum \lipsum
\lipsum \lipsum
\end{foldoutcell} \end{foldoutcell}
%
\newpage
%
\begin{foldoutcell}[2-3]
\lipsum
\lipsum
\lipsum
\end{foldoutcell}
\end{foldout} \end{foldout}
\begin{foldout}[in] \begin{foldout}[in]

View File

@ -2951,22 +2951,6 @@
+ \bleed + \bleed
+ \foldmarkoffset}} + \foldmarkoffset}}
% >> \photobook@setfoldoutoffset{<name>}{<from>}{<to>}
% XXX doc [from, to[
% XXX this can't be used outside of a foldout...
\newcommand\photobook@setfoldoutoffset[3]{%
\expandafter\setlength\csname #1\endcsname{0pt}%
\ifnum \numexpr #2 \relax < \numexpr #3 \relax%
\xintFor* ##1 in {%
\ifnumodd{\thepage}{%
\xintSeq{#2}{\xintiiMin{#3}{\foldoutcellwidthslen + 1} - 1}
}{%
\xintSeq{\xintiiMin{#3}{\foldoutcellwidthslen + 1} - 1}{#2}
}} \do {%
\expandafter\setlength\csname #1\endcsname{%
\csname #1\endcsname%
+ \foldoutcellwidths[##1]}}\fi}
\newlength\photobook@foldout@panelwidth \newlength\photobook@foldout@panelwidth
\setlength\photobook@foldout@panelwidth{0pt} \setlength\photobook@foldout@panelwidth{0pt}
\newlength\photobook@foldout@maxpanelwidth \newlength\photobook@foldout@maxpanelwidth
@ -3064,7 +3048,6 @@
\newcounter{photobook@foldoutpanel} \newcounter{photobook@foldoutpanel}
\setcounter{photobook@foldoutpanel}{1} \setcounter{photobook@foldoutpanel}{1}
% XXX in/out branches are identical -- unify...
\newenvironment{foldout}[1][\foldoutspec]{% \newenvironment{foldout}[1][\foldoutspec]{%
\begingroup% \begingroup%
\setsepchar{ }% \setsepchar{ }%
@ -3077,17 +3060,15 @@
% %
% panel count... % panel count...
\ifnum \photobook@foldout@argslen = 1% \ifnum \photobook@foldout@argslen = 1%
% in... % in/out...
\ifthenelse{\equal{#1}{in}}{% \ifthenelse{
\edef\photobook@foldout@count{2}% \equal{#1}{in}
\edef\photobook@foldout@prevfold{#1}% \OR \equal{#1}{out}}{%
% out...
}{\ifthenelse{\equal{#1}{out}}{%
\edef\photobook@foldout@count{2}% \edef\photobook@foldout@count{2}%
\edef\photobook@foldout@prevfold{#1}% \edef\photobook@foldout@prevfold{#1}%
% count... % count...
}{% }{%
\edef\photobook@foldout@count{#1}}}% \edef\photobook@foldout@count{#1}}%
% %
% build the panels... % build the panels...
\xintFor* ##1 in {\xintSeq{1}{\photobook@foldout@count}} \do {% \xintFor* ##1 in {\xintSeq{1}{\photobook@foldout@count}} \do {%
@ -3096,22 +3077,16 @@
% fold spec... % fold spec...
\else% \else%
\foreachitem \photobook@foldout@opt \in \photobook@foldout@args{% \foreachitem \photobook@foldout@opt \in \photobook@foldout@args{%
% in... % in/out...
\ifthenelse{\equal{\photobook@foldout@opt}{in}}{% \ifthenelse{
\equal{\photobook@foldout@opt}{in}
\OR \equal{\photobook@foldout@opt}{out}}{%
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
\photobook@foldout@panelwidth}{\photobook@foldout@opt}% \photobook@foldout@panelwidth}{\photobook@foldout@opt}%
% prep for next panel... % prep for next panel...
\edef\photobook@foldout@prevfold{% \edef\photobook@foldout@prevfold{%
\photobook@foldout@opt}% \photobook@foldout@opt}%
\setlength\photobook@foldout@panelwidth{0pt}% \setlength\photobook@foldout@panelwidth{0pt}%
% out...
}{\ifthenelse{\equal{\photobook@foldout@opt}{out}}{%
\photobook@foldout@pushpanel{%
\photobook@foldout@panelwidth}{\photobook@foldout@opt}
% prep for next panel...
\edef\photobook@foldout@prevfold{%
\photobook@foldout@opt}%
\setlength\photobook@foldout@panelwidth{0pt}%
% explicit size... % explicit size...
}{% }{%
% finalize prev panel... % finalize prev panel...
@ -3119,7 +3094,7 @@
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
\photobook@foldout@panelwidth}{\photobook@foldout@prevfold}\fi% \photobook@foldout@panelwidth}{\photobook@foldout@prevfold}\fi%
% %
\setlength\photobook@foldout@panelwidth{\photobook@foldout@opt}}}}% \setlength\photobook@foldout@panelwidth{\photobook@foldout@opt}}}%
% add trailing panel... % add trailing panel...
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
\photobook@foldout@panelwidth}{\photobook@foldout@prevfold}% \photobook@foldout@panelwidth}{\photobook@foldout@prevfold}%
@ -3157,7 +3132,12 @@
% %
%% >> \begin{foldoutcell} ... \end{foldoutcell} %% >> \begin{foldoutcell} ... \end{foldoutcell}
% %
%% This will also auto-advance the page when all panels are created. %% This will also auto-advance the page when all panels are filled.
%%
%% Note that manual panel placement has no effect on the panel counter
%% thus care must be taken when mixing manual and auto-advanced panels.
%% Also note that |foldoutpanel|'s value is not maintained within manually
%% placed panels and should be treated as undefined.
%% %%
%% |foldoutcell*| is the same as the non-star version but creates cells %% |foldoutcell*| is the same as the non-star version but creates cells
%% including bleeds. %% including bleeds.
@ -3167,12 +3147,32 @@
%% %%
%% These can only be used from within a |foldout| cell. %% These can only be used from within a |foldout| cell.
%% %%
% XXX should we be able to turn clipping on/off???
\newlength\photobook@foldoutcell@left \newlength\photobook@foldoutcell@left
\setlength\photobook@foldoutcell@left{0pt} \setlength\photobook@foldoutcell@left{0pt}
\newlength\photobook@foldoutcell@width \newlength\photobook@foldoutcell@width
\setlength\photobook@foldoutcell@width{0pt} \setlength\photobook@foldoutcell@width{0pt}
% XXX % calculate offset via \foldoutcellwidths and write to dimension <name>...
% >> \photobook@foldoutcell@setfoldoutoffset{<name>}{<from>}{<to>}
%
% NOTE: [<from>, <to>[ -- i.e. <to> is not included...
\newcommand\photobook@foldoutcell@setfoldoutoffset[3]{%
\expandafter\setlength\csname #1\endcsname{0pt}%
\ifnum \numexpr #2 \relax < \numexpr #3 \relax%
\xintFor* ##1 in {%
\xintSeq{#2}{\xintiiMin{#3}{\foldoutcellwidthslen + 1} - 1}} \do {%
\ifnumodd{\thepage}{%
\expandafter\setlength\csname #1\endcsname{%
\csname #1\endcsname%
+ \foldoutcellwidths[##1]}
}{%
\expandafter\setlength\csname #1\endcsname{%
\csname #1\endcsname%
+ \foldoutcellwidths[-\numexpr ##1 \relax]}}}\fi}
% foldout panel auto-advance counter...
\newcounter{foldoutpanel} \newcounter{foldoutpanel}
\setcounter{foldoutpanel}{0} \setcounter{foldoutpanel}{0}
\edef\photobook@foldoutcell@from{0} \edef\photobook@foldoutcell@from{0}
@ -3182,51 +3182,52 @@
\edef\photobook@foldoutcell@from{% \edef\photobook@foldoutcell@from{%
\thefoldoutpanel}} \thefoldoutpanel}}
% XXX the following two envs are almost identical... % set panel left/width dimensions (helper)...
% XXX BUG: even (left) page panel sizes are in the same order as odd % >> \photobook@foldoutcell@setdimensions[<panel-spec>]
% page -- should be reversed... %
% ...use same strategy as for foldmarks... % NOTE: for <panel-spec> see docs for foldoutcell/foldoutcell*...
% XXX revise naming.... \newcommand\photobook@foldoutcell@setdimensions[1][0]{
% foldoutcell - 1:1 (unclipped) % parse args...
% should be clipped to bleeds, i.e. should use \setsepchar{-}%
% foldoutcell* and create a new offset cell inside... \readlist*\photobook@foldoutcell@panels{#1}%
% foldoutcell* - with bleeds like cell* (unclipped)... %
% XXX need to be able to turn clipping on/off (???) % auto advance panel...
% XXX should these clip by default??? \ifnum \photobook@foldoutcell@panels[1] = 0%
% XXX doc [from, to] % auto advance page...
% XXX this can't be used outside of a foldout -- warn... \ifnum \value{foldoutpanel} = \foldoutcellwidthslen%
\newenvironment{foldoutcell}[1][0]{% % NOTE: this will reset the counter...
\begingroup% \newpage\fi%
\setsepchar{-}% \stepcounter{foldoutpanel}%
\readlist*\photobook@foldoutcell@panels{#1}% \global\edef\photobook@foldoutcell@from{%
% auto advance panel... \thefoldoutpanel}%
\ifnum \photobook@foldoutcell@panels[1] = 0% % explicit panels...
% auto advance page... \else%
\ifnum \value{foldoutpanel} = \foldoutcellwidthslen% \global\edef\photobook@foldoutcell@from{
% NOTE: this will reset the counter... \photobook@foldoutcell@panels[1]}\fi%
\newpage\fi% % left offset...
\stepcounter{foldoutpanel}% \photobook@foldoutcell@setfoldoutoffset{photobook@foldoutcell@left}{%
\global\edef\photobook@foldoutcell@from{% 1
\thefoldoutpanel}% }{%
% explicit panels... \photobook@foldoutcell@from}%
\else% % panel from-to width...
\global\edef\photobook@foldoutcell@from{ \ifnum \photobook@foldoutcell@panelslen > 1%
\photobook@foldoutcell@panels[1]}\fi% \photobook@foldoutcell@setfoldoutoffset{photobook@foldoutcell@width}{%
% left offset... \photobook@foldoutcell@from%
\photobook@setfoldoutoffset{photobook@foldoutcell@left}{%
1
}{% }{%
\photobook@foldoutcell@from}% \photobook@foldoutcell@panels[2] + 1}%
% panel width... % panel N width...
\ifnum \photobook@foldoutcell@panelslen > 1% \else%
\photobook@setfoldoutoffset{photobook@foldoutcell@width}{% \ifnumodd{\thepage}{%
\photobook@foldoutcell@from%
}{%
\photobook@foldoutcell@panels[2] + 1}%
\else%
\setlength\photobook@foldoutcell@width{% \setlength\photobook@foldoutcell@width{%
\foldoutcellwidths[{\photobook@foldoutcell@from}]}\fi% \foldoutcellwidths[{\photobook@foldoutcell@from}]}
% }{%
\setlength\photobook@foldoutcell@width{%
\foldoutcellwidths[-\numexpr \photobook@foldoutcell@from \relax]}}\fi}
\newenvironment{foldoutcell}[1][0]{%
% XXX check if outside of foldout -> warn...
\begingroup%
\photobook@foldoutcell@setdimensions[#1]%
\begin{cell*}{% \begin{cell*}{%
\bleed \bleed
+ \photobook@foldoutcell@left,% + \photobook@foldoutcell@left,%
@ -3236,44 +3237,11 @@
}{% }{%
\end{cell*}% \end{cell*}%
\endgroup} \endgroup}
% bleed version...
\newenvironment{foldoutcell*}[1][0]{% \newenvironment{foldoutcell*}[1][0]{%
% XXX check if outside of foldout -> warn...
\begingroup% \begingroup%
\setsepchar{-}% \photobook@foldoutcell@setdimensions[#1]%
\readlist*\photobook@foldoutcell@panels{#1}%
% auto advance...
\ifnum \photobook@foldoutcell@panels[1] = 0%
% auto advance page...
\ifnum \value{foldoutpanel} = \foldoutcellwidthslen%
% NOTE: this will reset the counter...
\newpage\fi%
\stepcounter{foldoutpanel}%
\global\edef\photobook@foldoutcell@from{%
\thefoldoutpanel}%
% explicit panels...
\else%
\global\edef\photobook@foldoutcell@from{
\photobook@foldoutcell@panels[1]}\fi%
% left offset...
\photobook@setfoldoutoffset{photobook@foldoutcell@left}{%
1
}{%
\photobook@foldoutcell@from}%
% panel width...
\ifnum \photobook@foldoutcell@panelslen > 1%
\photobook@setfoldoutoffset{photobook@foldoutcell@width}{%
\photobook@foldoutcell@from%
}{%
\photobook@foldoutcell@panels[2] + 1}%
% add bleed to last panel...
\ifnum \photobook@foldoutcell@panels[2] = \foldoutcellwidthslen%
\setlength\photobook@foldoutcell@width{%
\bleed
+ \photobook@foldoutcell@width}\fi%
\else%
\setlength\photobook@foldoutcell@width{%
\foldoutcellwidths[{\photobook@foldoutcell@from}]}
\fi%
% add bleed to first/last panel... % add bleed to first/last panel...
\ifnum \photobook@foldoutcell@from = 1% \ifnum \photobook@foldoutcell@from = 1%
\setlength\photobook@foldoutcell@width{% \setlength\photobook@foldoutcell@width{%
@ -3287,7 +3255,6 @@
\setlength\photobook@foldoutcell@width{% \setlength\photobook@foldoutcell@width{%
\bleed \bleed
+ \photobook@foldoutcell@width}\fi% + \photobook@foldoutcell@width}\fi%
%
\begin{cell*}{% \begin{cell*}{%
\photobook@foldoutcell@left,% \photobook@foldoutcell@left,%
0pt}% 0pt}%