working on more uniform bindingoffset support + gutter offsets...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-04-05 17:06:18 +03:00
parent 510c00192e
commit a72cee9c9c
2 changed files with 104 additions and 37 deletions

View File

@ -28,8 +28,7 @@ TEMPLATE_DIR := templates
# sources... # sources...
SETUP := \ SETUP := \
setup.tex \ setup.tex
macros.tex
TEMPLATE_FILES := \ TEMPLATE_FILES := \
$(wildcard $(TEMPLATE_DIR)/*) $(wildcard $(TEMPLATE_DIR)/*)
@ -83,26 +82,26 @@ block.pdf: $(SPREADS)
# XXX need to also include covers and endpapers (optionally?) # XXX need to also include covers and endpapers (optionally?)
# XXX this is broken... # XXX this is broken...
web.tex: setup.tex ##web.tex: setup.tex
{ \ ## { \
echo "% This file is generated via make web.tex" \ ## echo "% This file is generated via make web.tex" \
echo "% see the Makefile for info" \ ## echo "% see the Makefile for info" \
echo "% do not edit directly" \ ## echo "% do not edit directly" \
echo \ ## echo \
echo "\input{setup}" \ ## echo "\input{setup}" \
echo \ ## echo \
echo "\setlength\bleed{0mm}" \ ## echo "\setlength\bleed{0mm}" \
echo "\setlength\bindingoffset{0mm}" \ ## echo "\setlength\bindingoffset{0mm}" \
echo \ ## echo \
echo "\ChangeLayout{endpaper}" \ ## echo "\ChangeLayout{endpaper}" \
echo \ ## echo \
echo "\pagecolor{black}" \ ## echo "\pagecolor{black}" \
echo \ ## echo \
echo "\begin{document}" \ ## echo "\begin{document}" \
echo "\includepdf[pages={{},1-}, nup=2x1, delta=0.3mm 0.3mm]{block}" \ ## echo "\includepdf[pages={{},1-}, nup=2x1, delta=0.3mm 0.3mm]{block}" \
echo "\end{document}" \ ## echo "\end{document}" \
echo \ ## echo \
} > $@ ## } > $@

View File

@ -35,6 +35,29 @@
% %
% XXC FEATURE image spread: add ability to push image sides outward to % XXC FEATURE image spread: add ability to push image sides outward to
% account for gutter.,, % account for gutter.,,
%
% XXX ASAP \bindingoffset should also affect fill/bleed images...
% ...shift the macros that optionally account for \bindingoffset to
% account for \gutteroffset -- everything should respect \bindingoffset
% XXX ASAP add \gutteroffset and \gutterimageoffset to offset content
% from the gutter
% \gutterimageoffset is an additional offset added to bleed images...
% ...currently \bindingoffset is used for both...
% Q: should the gutter offsets be counted from the \bindingoffset???
%
% +-------------------------------=--
% | . . . =
% | . . . =
% | . . <-> \bindingoffset
% | . . . =
% | . <--> = \gutteroffset
% | . . . =
% | <--> . = \gutterimageoffset
% | . . . =
% +-------------------------------=--
%
%
%
% XXX revise \clearcaption / \captionclearpage... % XXX revise \clearcaption / \captionclearpage...
% XXX unify API -- see CellContent env... % XXX unify API -- see CellContent env...
% XXX make this loadable both as a class and as a package... % XXX make this loadable both as a class and as a package...
@ -224,6 +247,9 @@
%% \DescribeMacro{blockwidth=<len>} %% \DescribeMacro{blockwidth=<len>}
%% \DescribeMacro{blockheight=<len>} %% \DescribeMacro{blockheight=<len>}
%% \DescribeMacro{bindingoffset=<len>} %% \DescribeMacro{bindingoffset=<len>}
% XXX
%%% \DescribeMacro{gutteroffset=<len>}
%%% \DescribeMacro{gutterimageoffset=<len>}
%% \DescribeMacro{bleed=<len>} %% \DescribeMacro{bleed=<len>}
% %
%% This is similar to what |geometry| does, but adds bleed support. %% This is similar to what |geometry| does, but adds bleed support.
@ -263,7 +289,10 @@
% and \begin{document}... % and \begin{document}...
\DeclareStringOption{blockwidth} \DeclareStringOption{blockwidth}
\DeclareStringOption{blockheight} \DeclareStringOption{blockheight}
% XXX should these be renamed to \gutter*offset???
\DeclareStringOption[0pt]{bindingoffset}[10mm] \DeclareStringOption[0pt]{bindingoffset}[10mm]
\DeclareStringOption[0pt]{gutteroffset}[0mm]
\DeclareStringOption[0pt]{gutterimageoffset}[0mm]
\DeclareStringOption[5mm]{bleed}[5mm] \DeclareStringOption[5mm]{bleed}[5mm]
%% \DescribeMacro{flatfold=<len>} %% \DescribeMacro{flatfold=<len>}
@ -296,6 +325,7 @@
% %
%% \DescribeMacro{layoutmode=<layout>} %% \DescribeMacro{layoutmode=<layout>}
%% \DescribeMacro{block} %% \DescribeMacro{block}
%% \DescribeMacro{spread}
%% \DescribeMacro{endpaper} %% \DescribeMacro{endpaper}
%% \DescribeMacro{cover} %% \DescribeMacro{cover}
%% \DescribeMacro{jacket} %% \DescribeMacro{jacket}
@ -326,9 +356,9 @@
%% \end{minipage} %% \end{minipage}
%% %%
%% %%
%% |endpaper|: %% |spread|/|endpaper|:
%% %%
%% Endpaper layout. %% Spread/endpaper layout.
%% %%
% XXX should this use \flatfold??? % XXX should this use \flatfold???
%% \begin{minipage}{\textwidth} %% \begin{minipage}{\textwidth}
@ -340,7 +370,7 @@
%% +---------------+---------------+ %% +---------------+---------------+
%% | . | %% | . |
%% | . | %% | . |
%% | endpaper | %% | spread |
%% | . | %% | . |
%% | . | %% | . |
%% +---------------+---------------+ %% +---------------+---------------+
@ -348,6 +378,9 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
%% Note that |endpaper| is simply an alias to |spread|, this helps make
%% the book source to be more semantic and readable.
%%
%% %%
%% |cover| %% |cover|
%% %%
@ -422,7 +455,7 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
%% Note that for |cover|, |endpaper|, and |jacket|, %% Note that for |cover|, |spread|/|endpaper|, and |jacket|,
%% \href{https://ctan.org/pkg/fancyhdr}{fancyhdr}'s |\pagestyle{..}| is %% \href{https://ctan.org/pkg/fancyhdr}{fancyhdr}'s |\pagestyle{..}| is
%% set to |empty| by default. %% set to |empty| by default.
%% %%
@ -436,6 +469,7 @@
\@DeclareLiteralOptionTo{layoutmode}{block} \@DeclareLiteralOptionTo{layoutmode}{block}
%\@DeclareLiteralOptionTo{layoutmode}{web} %\@DeclareLiteralOptionTo{layoutmode}{web}
\@DeclareLiteralOptionTo{layoutmode}{endpaper} \@DeclareLiteralOptionTo{layoutmode}{endpaper}
\@DeclareLiteralOptionTo{layoutmode}{spread}
% XXX add overhang... % XXX add overhang...
% XXX minght be a good idea to add cover types as separate values and % XXX minght be a good idea to add cover types as separate values and
% preset defeaults per type, e.g: % preset defeaults per type, e.g:
@ -671,6 +705,7 @@
\newif\ifhardcoverlayout \newif\ifhardcoverlayout
\newif\ifsoftcoverlayout \newif\ifsoftcoverlayout
\newif\ifendpaperlayout \newif\ifendpaperlayout
\newif\ifspreadlayout
\newif\ifjacketlayout \newif\ifjacketlayout
% aggregates... % aggregates...
\newif\ifcoverlikelayout \newif\ifcoverlikelayout
@ -779,6 +814,16 @@
\newlength\bindingoffset \newlength\bindingoffset
\setlength\bindingoffset{\photobook@bindingoffset} \setlength\bindingoffset{\photobook@bindingoffset}
%%% \DescribeMacro{\gutteroffset=<len>}
%%% \DescribeMacro{\gutterimageoffset=<len>}
%
%%% Gutter offsets
%%%
\newlength\gutteroffset
\setlength\gutteroffset{\photobook@gutteroffset}
\newlength\gutterimageoffset
\setlength\gutterimageoffset{\photobook@gutterimageoffset}
%% \DescribeMacro{\defaultfoldout=<fold-spec>} %% \DescribeMacro{\defaultfoldout=<fold-spec>}
% %
%% Set the default fold specification. %% Set the default fold specification.
@ -972,6 +1017,7 @@
\hardcoverlayoutfalse \hardcoverlayoutfalse
\softcoverlayoutfalse \softcoverlayoutfalse
\endpaperlayoutfalse \endpaperlayoutfalse
\spreadlayoutfalse
\jacketlayoutfalse \jacketlayoutfalse
\coverlikelayoutfalse \coverlikelayoutfalse
\blocklayoutfalse \blocklayoutfalse
@ -989,7 +1035,11 @@
\ifdefstring{\layoutmode}{jacket}{% \ifdefstring{\layoutmode}{jacket}{%
\jacketlayouttrue \jacketlayouttrue
\coverlikelayouttrue }{} \coverlikelayouttrue }{}
\ifdefstring{\layoutmode}{spread}{
\spreadlayouttrue
\endpaperlayouttrue }{}
\ifdefstring{\layoutmode}{endpaper}{ \ifdefstring{\layoutmode}{endpaper}{
\spreadlayouttrue
\endpaperlayouttrue }{} \endpaperlayouttrue }{}
% pdf layout... % pdf layout...
\ifx\photobook@pdfpagelayout\empty \ifx\photobook@pdfpagelayout\empty
@ -1087,8 +1137,8 @@
+ 2\jacketwrap + 2\jacketwrap
+ \photobook@jacketflapfront@active + \photobook@jacketflapfront@active
+ \photobook@jacketflapback@active \relax}\fi + \photobook@jacketflapback@active \relax}\fi
% layout: endpaper... % layout: spread/endpaper...
\ifendpaperlayout \ifspreadlayout
\pagestyle{empty}% \pagestyle{empty}%
\readlist*\pagefoldpanels{% \readlist*\pagefoldpanels{%
\the\pageblockwidth, \the\pageblockwidth,
@ -1096,7 +1146,7 @@
\photobook@setpagefold{in} \photobook@setpagefold{in}
\setlength\blockwidth{2\blockwidth}\fi\fi \setlength\blockwidth{2\blockwidth}\fi\fi
\ifdim\blockheight=0pt \ifdim\blockheight=0pt
% layout: block / endpaper... % layout: block / spread...
\setlength\blockheight{ \setlength\blockheight{
\ifx\photobook@blockheight\empty \ifx\photobook@blockheight\empty
\dimexpr \paperheight - 2\bleed \relax \dimexpr \paperheight - 2\bleed \relax
@ -5175,7 +5225,7 @@
\begin{page} \begin{page}
\setlength{\parindent}{0em} \setlength{\parindent}{0em}
% NOTE: only the relevant blocks will be visible... % NOTE: only the relevant blocks will be visible...
\ifendpaperlayout% \ifspreadlayout%
\begin{leftside} \begin{leftside}
\photobook@TemplateCell[#1]{ENDPAPER LEFT} \photobook@TemplateCell[#1]{ENDPAPER LEFT}
\end{leftside} \end{leftside}
@ -5207,7 +5257,7 @@
\newcommand\ShowMarks[1][1pt]{% \newcommand\ShowMarks[1][1pt]{%
% general... % general...
% XXX corners / cut marks... % XXX corners / cut marks...
\ifendpaperlayout% \ifspreadlayout%
% XXX fold... % XXX fold...
\fi% \fi%
\ifcoverlikelayout% \ifcoverlikelayout%
@ -5332,18 +5382,32 @@
%% \DescribeMacro{\pdfspreadstopages\{..\}} %% \DescribeMacro{\pdfspreadstopages\{..\}}
% %
%% include pdf block spreads as pages %% \EXPERIMENTAL
%%
%% Include spreads from a pdf block as pages
%% %%
%% >> \pdfspreadstopages[<delta>]{<block-pdf>} %% >> \pdfspreadstopages[<delta>]{<block-pdf>}
%% %%
% XXX this needs the pdf view mode to be set to single page... %% |\pdfspreadstopages{..}| inserts an empty page before the first page
% XXX do we skip the first/last single pages? ...an option? %% in the block to push it to the right of the spread.
%%
%% To display other pages consistently it is recommended to set the
%% block width to |2\blockwidth| and set the |pdfpagelayout| to be
%% set to |SinglePage|, a simple way to do both is to:
%%
%% >> \ChangeLayout{spread}
%%
% XXX do we need to set the page format to double block width here???
% XXX TEST... % XXX TEST...
\newcommand\pdfspreadstopages[2][0.3mm]{% \newcommand\pdfspreadstopages[2][0mm]{%
\includepdf[pages={{},1-}, nup=2x1, delta=#1 #1]{#2}} \includepdf[pages={{},1-}, nup=2x1, delta=#1 #1]{#2}}
% XXX % XXX include the cover with the foldouts removed...
\newcommand\pdfcover[1]{%
% XXX crop to frontcover cell..
\includepdf{#1}}
% XXX include cover cells....
\newcommand\pdfcoverfront[1]{% \newcommand\pdfcoverfront[1]{%
% XXX crop to frontcover cell.. % XXX crop to frontcover cell..
\includepdf{#1}} \includepdf{#1}}
@ -5365,7 +5429,11 @@
% XXX DOC... %% \DescribeMacro{\TEX}
%% \DescribeMacro{\LATEX}
%
%% Convenience macros to display \TeX and \LaTeX in the correct font.
%%
\def\TEX{% \def\TEX{%
{\fontfamily{lmr}\selectfont \TeX}} {\fontfamily{lmr}\selectfont \TeX}}
\def\LATEX{% \def\LATEX{%