foldout almost done... still need to calc panel widths + fold marks on every page...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-10-01 03:45:25 +03:00
parent b021d37253
commit 467a3b9724
2 changed files with 137 additions and 101 deletions

View File

@ -33,28 +33,25 @@
\begin{document} \begin{document}
\begin{foldoutA}[10cm 10cm] \edef\foldmarkoffset{-2mm}
%\foldmarksfalse
\begin{foldout}[10cm 10cm 10cm]
explicit widths\\ explicit widths\\
\end{foldoutA} \end{foldout}
--- \begin{foldout}[in in]
\begin{foldoutA}[in in]
auto-calculate\\ auto-calculate\\
\end{foldoutA} \end{foldout}
--- \begin{foldout}[3]
\begin{foldoutA}[3]
count\\ count\\
\end{foldoutA} \end{foldout}
--- \begin{foldout}[in]
\begin{foldoutA}[in]
in\\ in\\
\end{foldoutA} \end{foldout}
%
%\ImagePageFill{\PageInfo}{\TestImage} %\ImagePageFill{\PageInfo}{\TestImage}
% %
%\begin{foldout}[3] %\begin{foldout}[3]

View File

@ -1106,7 +1106,8 @@
% ...also see cell env... % ...also see cell env...
% XXX needs more digging... % XXX needs more digging...
% XXX do this at beginshipout/beginpage... (???) % XXX do this at beginshipout/beginpage... (???)
\null% %\null%
\hbox{}%
}{% }{%
\endgroup% \endgroup%
% reset... % reset...
@ -1441,26 +1442,28 @@
% XXX SYNTAX: place the second arg in braces... % XXX SYNTAX: place the second arg in braces...
% \begin{cell*}(<left>, <top>){<width>}{<height>} % \begin{cell*}(<left>, <top>){<width>}{<height>}
\newenvironment{cell*}[3]{% \newenvironment{cell*}[3]{%
\setsepchar{,}% \begingroup%
\readlist*\photobook@cell@offset{#1}% \setsepchar{,}%
% \readlist*\photobook@cell@offset{#1}%
% NOTE: if there is no \null before textblock then it can reset the %
% non-standard page boxes... % NOTE: if there is no \null before textblock then it can reset the
% ...not sure yet if this is an issue with how/when foldout env % non-standard page boxes...
% updates the boxes or with textblock internals, needs % ...not sure yet if this is an issue with how/when foldout env
% investigating... % updates the boxes or with textblock internals, needs
% XXX report this as a bug if issue is in textblock... % investigating...
% XXX another place where this is relevant is in the resizedpages % XXX report this as a bug if issue is in textblock...
% env... % XXX another place where this is relevant is in the resizedpages
\null% % env...
\begin{textblock*}{#2}(#1)% \null%
\begin{inlinecell*}{#2}{#3}% \begin{textblock*}{#2}(#1)%
\setlength\celloffsettop{\photobook@cell@offset[1]}% \begin{inlinecell*}{#2}{#3}%
\setlength\celloffsetleft{\photobook@cell@offset[2]}% \setlength\celloffsettop{\photobook@cell@offset[1]}%
\ignorespaces% \setlength\celloffsetleft{\photobook@cell@offset[2]}%
\ignorespaces%
}{% }{%
\end{inlinecell*}% \end{inlinecell*}%
\end{textblock*}% \end{textblock*}%
\endgroup%
\ignorespaces} \ignorespaces}
\newenvironment{cell}[3]{% \newenvironment{cell}[3]{%
@ -2704,8 +2707,28 @@
%% %%
%% Create 2 or more pages in foldout mode. %% Create 2 or more pages in foldout mode.
% %
%% >> \begin{foldout}[<count>] ... \end{foldout} %% >> \begin{foldout}[<fold-spec>] ... \end{foldout}
% %
%% |<fold-spec>| grammar:
%%
%% \begin{minipage}{\textwidth}
%% \begin{verbatim}
%% <fold-spec> ::=
%% <count>
%% | <fold>
%% | <panels>
%% <panels> ::=
%% <panel>
%% | <panel> <panels>
%% <panel> ::=
%% <width> <fold>
%% | <width>
%% | <fold>
%% <fold> ::=
%% in | out
%% \end{verbatim}
%% \end{minipage}
%%
%% \begin{minipage}{\textwidth} %% \begin{minipage}{\textwidth}
%% \begin{verbatim} %% \begin{verbatim}
%% %%
@ -2835,17 +2858,60 @@
\newlength\foldoutwidth \newlength\foldoutwidth
\setlength\foldoutwidth{\blockwidth} \setlength\foldoutwidth{\blockwidth}
\newlength\foldoutcellwidth \edef\foldoutspec{2}
\setlength\foldoutcellwidth{\blockwidth}
\newlength\clearfoldoutblock \newlength\clearfoldoutclearblock
\setlength\clearfoldoutblock{0.5mm} \setlength\clearfoldoutclearblock{0.5mm}
\newlength\clearfoldoutfold \newlength\clearfoldoutfold
\setlength\clearfoldoutfold{5mm} \setlength\clearfoldoutfold{5mm}
\newlength\clearfoldoutedge
\setlength\clearfoldoutedge{1mm}
\def\foldoutcellwidths{} \def\foldoutcellwidths{}
% XXX length or command???
\def\foldmarkoffset{0.5\bleed}
\newif\iffoldmarks
\foldmarkstrue
% XXX make this a box... (???)
\newcommand\photobook@foldmark[2]{%
\begin{textblock*}{0pt}(#2)%
\setlength{\unitlength}{1mm}%
\begin{picture}(0, 0)(0,0)%
\thicklines
\color{white}
\put(0,0){\line(1,#1){1}}
\put(0,0){\line(-1,#1){1}}
\thinlines
\color{black}
\put(0,0){\line(1,#1){1}}
\put(0,0){\line(-1,#1){1}}
\end{picture}
\end{textblock*}}
\newcommand\photobook@topfoldmark[1]{%
\photobook@foldmark{4}{#1}}
\newcommand\photobook@bottomfoldmark[1]{%
\photobook@foldmark{-4}{#1}}
% XXX also add this to jacket/cover...
% XXX test position correctness...
% >> \photobook@markfold[<fold>]{<offset>}
\newcommand\photobook@markfold[2][in]{%
\iffoldmarks%
\photobook@topfoldmark{
#2,
\bleed
- \foldmarkoffset}%
\photobook@bottomfoldmark{
#2,
\blockheight
+ \bleed
+ \foldmarkoffset}\fi}
% >> \photobook@setfoldoutoffset{<name>}{<from>}{<to>} % >> \photobook@setfoldoutoffset{<name>}{<from>}{<to>}
% XXX doc [from, to[ % XXX doc [from, to[
% XXX this can't be used outside of a foldout... % XXX this can't be used outside of a foldout...
@ -2867,52 +2933,54 @@
% in|out ... -- fold direction % in|out ... -- fold direction
% <dim> in|out <dim> ... % <dim> in|out <dim> ...
% -- fold direction with panel widths % -- fold direction with panel widths
\newlength\foldoutpanelwidth \newlength\photobook@foldout@panelwidth
\setlength\foldoutpanelwidth{0pt} \setlength\photobook@foldout@panelwidth{0pt}
\newlength\photobook@foldout@maxpanelwidth
\setlength\photobook@foldout@maxpanelwidth{0pt}
\edef\photobook@foldout@count{} \edef\photobook@foldout@count{}
\edef\photobook@foldout@prevfold{in} \edef\photobook@foldout@prevfold{in}
\edef\foldoutspec{2}
% XXX revise numbers... % XXX setup numbers...
\newlength\foldoutmaxpanelwidth
\newcommand\photobook@foldout@pushpanel[2]{% \newcommand\photobook@foldout@pushpanel[2]{%
% use default width.... % use default width....
% XXX might need to make this a bit more elaborate... % XXX might need to make this a bit more elaborate...
\ifdim #1 = 0pt% \ifdim #1 = 0pt%
% double fold twice in same direction... % double fold twice in same direction...
\ifthenelse{\equal{#2}{\photobook@foldout@prevfold}}{% \ifthenelse{\equal{#2}{\photobook@foldout@prevfold}}{%
\setlength\foldoutpanelwidth{% \setlength\photobook@foldout@panelwidth{%
\foldoutmaxpanelwidth \photobook@foldout@maxpanelwidth
% XXX % XXX
+ 0pt}% + 0pt}%
% different fold directions... % different fold directions...
}{% }{%
\setlength\foldoutpanelwidth{% \setlength\photobook@foldout@panelwidth{%
\foldoutmaxpanelwidth \photobook@foldout@maxpanelwidth
% XXX % XXX
+ 0pt}}% + 0pt}}%
\setlength\foldoutmaxpanelwidth{\foldoutpanelwidth}% \setlength\photobook@foldout@maxpanelwidth{\photobook@foldout@panelwidth}%
% explicit width... % explicit width...
\else% \else%
\setlength\foldoutpanelwidth{#1}\fi% \setlength\photobook@foldout@panelwidth{#1}\fi%
% accumulate width... % accumulate width...
\setlength\foldoutwidth{ \setlength\foldoutwidth{
\foldoutwidth \foldoutwidth
+ \foldoutpanelwidth}% + \photobook@foldout@panelwidth}%
% panel widths list... % panel widths list...
\edef\foldoutcellwidths{% \edef\foldoutcellwidths{%
\foldoutcellwidths, \the\foldoutpanelwidth}} \foldoutcellwidths, \the\photobook@foldout@panelwidth}}
\edef\foldoutfold{in} \edef\foldoutfold{in}
% XXX mark folds on every page...
% XXX in/out branches are identical -- unify... % XXX in/out branches are identical -- unify...
\newenvironment{foldoutA}[1][\foldoutspec]{% \newenvironment{foldout}[1][\foldoutspec]{%
\begingroup% \begingroup%
\setsepchar{ }% \setsepchar{ }%
\readlist*\photobook@foldout@args{#1}% \readlist*\photobook@foldout@args{#1}%
% %
% defaults... % defaults...
\setlength\foldoutwidth{0pt}% \setlength\foldoutwidth{0pt}%
\setlength\foldoutmaxpanelwidth{\blockwidth}% \setlength\photobook@foldout@maxpanelwidth{\blockwidth}%
\edef\photobook@foldout@prevfold{\foldoutfold}% \edef\photobook@foldout@prevfold{\foldoutfold}%
% %
% panel count... % panel count...
@ -2932,75 +3000,46 @@
% build the panels... % build the panels...
\xintFor* ##1 in {\xintSeq{1}{\photobook@foldout@count}} \do {% \xintFor* ##1 in {\xintSeq{1}{\photobook@foldout@count}} \do {%
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
0pt}{\photobook@foldout@prevfold}}% 0pt}{\photobook@foldout@prevfold}%
% skip for last panel...
\ifnum \photobook@foldout@count = ##1 \else%
\photobook@markfold{\foldoutwidth}\fi}%
% fold spec... % fold spec...
\else% \else%
\foreachitem \photobook@foldout@opt \in \photobook@foldout@args{% \foreachitem \photobook@foldout@opt \in \photobook@foldout@args{%
% in... % in...
\ifthenelse{\equal{\photobook@foldout@opt}{in}}{% \ifthenelse{\equal{\photobook@foldout@opt}{in}}{%
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
\foldoutpanelwidth}{\photobook@foldout@opt}% \photobook@foldout@panelwidth}{\photobook@foldout@opt}%
\photobook@markfold{\foldoutwidth}%
% prep for next panel... % prep for next panel...
\edef\photobook@foldout@prevfold{% \edef\photobook@foldout@prevfold{%
\photobook@foldout@opt}% \photobook@foldout@opt}%
\setlength\foldoutpanelwidth{0pt}% \setlength\photobook@foldout@panelwidth{0pt}%
% out... % out...
}{\ifthenelse{\equal{\photobook@foldout@opt}{out}}{% }{\ifthenelse{\equal{\photobook@foldout@opt}{out}}{%
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
\foldoutpanelwidth}{\photobook@foldout@opt} \photobook@foldout@panelwidth}{\photobook@foldout@opt}
\photobook@markfold{\foldoutwidth}%
% prep for next panel... % prep for next panel...
\edef\photobook@foldout@prevfold{% \edef\photobook@foldout@prevfold{%
\photobook@foldout@opt}% \photobook@foldout@opt}%
\setlength\foldoutpanelwidth{0pt}% \setlength\photobook@foldout@panelwidth{0pt}%
% explicit size... % explicit size...
}{% }{%
% finalize prev panel... % finalize prev panel...
\ifdim \foldoutpanelwidth > 0pt% \ifdim \photobook@foldout@panelwidth > 0pt%
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
\foldoutpanelwidth}{\photobook@foldout@prevfold}\fi \photobook@foldout@panelwidth}{\photobook@foldout@prevfold}%
\photobook@markfold{\foldoutwidth}\fi
% %
% XXX need to disable clearences here... % XXX need to disable clearences here...
\setlength\foldoutpanelwidth{\photobook@foldout@opt}}}}% \setlength\photobook@foldout@panelwidth{\photobook@foldout@opt}}}}%
% we ended by a fold -> add trailing panel... % we ended by a fold -> add trailing panel...
\photobook@foldout@pushpanel{% \photobook@foldout@pushpanel{%
\foldoutpanelwidth}{\photobook@foldout@prevfold}% \photobook@foldout@panelwidth}{\photobook@foldout@prevfold}%
\fi% \fi%
% %
% XXX place fold markers...
}{%
args: \showitems\photobook@foldout@args\\
%w: \lenprint[mm]\foldoutpanelwidth\\
W: \lenprint[mm]\foldoutwidth\\
\endgroup}
% XXX revise starting dimensions...
% XXX add fold marks in bleeds...
\newenvironment{foldout}[1][2]{%
\begingroup%
% calculate fold geometry...
\setlength\foldoutwidth{0pt}%
\edef\foldoutcellwidths{}
\xintFor* ##1 in {\xintSeq{1}{#1}} \do {%
% foldout cell...
\setlength\foldoutcellwidth{
\dimexpr
\blockwidth
+ \clearfoldoutblock
% NOTE: this is an expanded (i - 1) because magic of LaTeX math =)
- ##1\clearfoldoutfold
+ \clearfoldoutfold \relax}%
% add cell to cell lengths....
\edef\foldoutcellwidths{%
\foldoutcellwidths, \the\foldoutcellwidth}%
% accumulate total width...
\setlength\foldoutwidth{
\dimexpr
\foldoutwidth
+ \foldoutcellwidth \relax}}%
% format the panel width list...
\setsepchar{,}%
\ignoreemptyitems%
\readlist\foldoutcellwidths{\foldoutcellwidths}%
%
% pages... % pages...
% NOTE: we'll keep the start of the foldout set at the right page % NOTE: we'll keep the start of the foldout set at the right page
% and end it on the left page. % and end it on the left page.
@ -4478,7 +4517,7 @@
\edef\photobook@pdfboxesset@r{\strip@pt\dimexpr \edef\photobook@pdfboxesset@r{\strip@pt\dimexpr
0.996264009963\dimexpr #2 - #1 \relax\relax}% 0.996264009963\dimexpr #2 - #1 \relax\relax}%
% %
\edef\photobook@pdfboxes{ \edef\photobook@pdfboxes{%
/MediaBox [0 0 \photobook@pdfboxesset@w\space \photobook@pdfboxesset@h] /MediaBox [0 0 \photobook@pdfboxesset@w\space \photobook@pdfboxesset@h]
/BleedBox [0 0 \photobook@pdfboxesset@w\space \photobook@pdfboxesset@h] /BleedBox [0 0 \photobook@pdfboxesset@w\space \photobook@pdfboxesset@h]
/ArtBox [ /ArtBox [