Compare commits

..

No commits in common. "main" and "v0.1.12" have entirely different histories.

59 changed files with 401 additions and 1825 deletions

View File

@ -1,7 +0,0 @@
root = true
[**]
indent_style = tab
tab_width = 4
charset = utf-8
end_of_line = lf

View File

@ -18,18 +18,9 @@ jobs:
uses: xu-cheng/texlive-action/full@v1 uses: xu-cheng/texlive-action/full@v1
with: with:
run: | run: |
apk add make git zip grep apk add make git zip
git config --global --add safe.directory '*' git config --global --add safe.directory '*'
echo "VERSION=$(make version)" >> $GITHUB_ENV echo "VERSION=$(make version)" >> $GITHUB_ENV
# XXX not sure about this...
#COMMENT="$(git log -1 --pretty=%B | grep -v "Signed-off-by:")"
#COMMENT="${COMMENT//'%'/'%25'}"
#COMMENT="${COMMENT//$'\n'/'%0A'}"
#COMMENT="${COMMENT//$'\n'/'%0D'}"
#echo 'COMMENT<<EOF' >> $GITHUB_ENV
#echo "${COMMENT}" >> $GITHUB_ENV
#echo 'EOF' >> $GITHUB_ENV
# XXX if comment is multi-line it breaks the CTAN announcement...
echo 'COMMENT<<EOF' >> $GITHUB_ENV echo 'COMMENT<<EOF' >> $GITHUB_ENV
git log -1 --pretty=%B | grep -v "Signed-off-by:" >> $GITHUB_ENV git log -1 --pretty=%B | grep -v "Signed-off-by:" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV
@ -44,13 +35,13 @@ jobs:
photobook.pdf photobook.pdf
- name: Artifacts - build - name: Artifacts - build
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v3
with: with:
name: build artifacts name: build artifacts
path: photobook.pdf path: photobook.pdf
- name: Artifacts - dist - name: Artifacts - dist
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v3
with: with:
name: dist artifacts name: dist artifacts
path: dist/photobook-*.zip path: dist/photobook-*.zip
@ -78,9 +69,6 @@ jobs:
defining a set of parameters, meta-macros, macros and defining a set of parameters, meta-macros, macros and
environments with reasonable defaults to help typeset, environments with reasonable defaults to help typeset,
build and print books mainly based on visual/image content. build and print books mainly based on visual/image content.
# XXX multi-line comments will break things...
# ...another potential cause is an empty line in a commit,
# need more testing...
announcement: > announcement: >
${{ env.COMMENT }} ${{ env.COMMENT }}

View File

@ -43,6 +43,10 @@
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Config... # Config...
.EXPORT_ALL_VARIABLES:
#.ONESHELL:
# NOTE: this makes things run consistently on different systems including # NOTE: this makes things run consistently on different systems including
# things like Android... # things like Android...
SHELL := bash SHELL := bash
@ -56,9 +60,8 @@ MODULE := photobook
VERSION = $(strip $(shell \ VERSION = $(strip $(shell \
cat $(MODULE).cls \ cat $(MODULE).cls \
| grep 'VERSION{' \ | grep 'VERSION{' \
| sed \ | sed 's/.*{\(.*\)}.*/\1/' \
-e 's/.*{\(.*\)}.*/\1/' \ | sed 's/v//'))
-e 's/v//'))
DATE = $(strip $(shell date "+%Y%m%d%H%M")) DATE = $(strip $(shell date "+%Y%m%d%H%M"))
COMMIT = $(strip $(shell git rev-parse HEAD)) COMMIT = $(strip $(shell git rev-parse HEAD))
@ -85,7 +88,8 @@ endif
# markdown dialect... # markdown dialect...
# #
MD_FORMAT ?= gfm # XXX still needs some tweaking...
MD_FORMAT ?= markdown_github
# debug output... # debug output...
@ -121,7 +125,6 @@ DIST_NORMAL_FILES = \
README.md \ README.md \
LICENSE \ LICENSE \
Makefile \ Makefile \
DEPENDS.txt \
$(MODULE).cls \ $(MODULE).cls \
$(MODULE).pdf $(MODULE).pdf
DIST_FILES = \ DIST_FILES = \
@ -172,11 +175,26 @@ LN := cp -l
# - |..| - verbatim does not work... # - |..| - verbatim does not work...
# - || - parts of doc omitted... # - || - parts of doc omitted...
# - verbatim blocks get merged sometimes... # - verbatim blocks get merged sometimes...
# - does not resolve \jobname in include...
# - ... # - ...
# ...not sure if this can be tweaked... # ...not sure if this can be tweaked...
#%.md: %.tex
# pandoc -t $(MD_FORMAT) -s $< -o $@
# XXX EXPERIMENTAL...
# XXX revise:
# ...for this to work we need to replace:
# \documentclass{ltxdoc}
# to:
# \documentclass[markdownextra]{internet}
# XXX install the internet class...
# https://github.com/loopspace/latex-to-internet
# ...needs testing...
%.md: %.tex %.md: %.tex
pandoc -t $(MD_FORMAT) -s $< -o $@ cat $< \
| sed 's/documentclass{ltxdoc}/documentclass[markdownextra]{internet}/' \
> $<.tmp
mv $<{.tmp,}
$(TEX) $< $(STDERR)
# meta-section... # meta-section...
@ -207,7 +225,6 @@ LN := cp -l
# strip docs out... # strip docs out...
# #
# XXX can we unify these??? # XXX can we unify these???
# ....not sure how...
%-stripped.tex: %.tex %-stripped.tex: %.tex
$(DOC) --strip $< \ $(DOC) --strip $< \
$(DOC) --prefix M --strip \ $(DOC) --prefix M --strip \
@ -224,15 +241,6 @@ LN := cp -l
> $@ > $@
# list of dependencies...
#
DEPENDS.txt: $(MODULE).cls
make depends \
| grep -v make \
| sed -e 's/^/hard /' \
> $@
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Info targets... # Info targets...
@ -242,27 +250,10 @@ version:
@echo $(VERSION) @echo $(VERSION)
# NOTE: grep's -z flag generates a bunch if nulls that we need to clean
# out via tr.
# XXX this is a bit ugly -- adding/removing "hard" and then adding it
# again for DEPENDS.txt...
.PHONY: depends
depends: $(MODULE).cls
@cat $< \
| grep -Ezo '\s*\\RequirePackage(\[[^]]*\])?\{[^}]*\}' \
| sed -e 's/.*{\(.*\)}/hard \1\n/' \
| grep -a hard \
| tr -d '\000' \
| cut -d " " -f 2
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Main targets... # Main targets...
.PHONY: dep
dep: DEPENDS.txt
.PHONY: pdf .PHONY: pdf
pdf: $(MODULE).pdf pdf: $(MODULE).pdf
@ -304,7 +295,6 @@ tag:
@echo " v$(VERSION)" @echo " v$(VERSION)"
@echo "Last 5 tags:" @echo "Last 5 tags:"
@git tag -l 'v[0-9]*'\ @git tag -l 'v[0-9]*'\
| sort -V \
| tail -n 5 \ | tail -n 5 \
| sed 's/^/ /' \ | sed 's/^/ /' \
| tac | tac
@ -336,7 +326,7 @@ tag:
.PHONY: all .PHONY: all
all: pdf dep all: pdf
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -418,7 +408,7 @@ sweep:
.PHONY: clean .PHONY: clean
clean: sweep clean: sweep
rm -rf $(DIST_DIR) $(BUILD_DIR) $(MODULE).md DEPENDS.txt *.pdf rm -rf $(DIST_DIR) $(BUILD_DIR) $(MODULE).md *.pdf

View File

@ -4,59 +4,8 @@ photobook
[LaTeX](https://www.latex-project.org/) document class for making photo books. [LaTeX](https://www.latex-project.org/) document class for making photo books.
Available on: ## Build requirements for docs
- CTAN: https://ctan.org/pkg/photobook
- GitHub: https://github.com/flynx/photobook
## Install / Build
The simplest way to install is to use either
[TeX Live](https://www.tug.org/texlive/)'s or [MiKTeX](https://miktex.org/)'s
standard way to install modules.
Installing from source:
```shell
# get the source...
$ git clone https://github.com/flynx/photobook.git
# if desired, install in the user context...
$ cd ./photobook
$ make install
```
The `photobook` document class requires a set of modules to be installed
for it to function, the full list is included in the docs and can be
generated and printed by calling:
```shell
$ make depends
```
For more info on `make` targets see the: [./Makefile](./Makefile)
# Documentation
Pre-built documentation can be found in the
[Github releases](https://github.com/flynx/photobook/releases/latest) or on
[CTAN](http://mirrors.ctan.org/macros/latex/contrib/photobook/photobook.pdf).
A full book (dummy) example is included in [./examples/book/](./examples/book/)
and can be used as a reference / starting point.
## Building documentation
Building the reference from source is done by:
```shell
$ make pdf
```
Build requirements for docs:
- LaTeX tool chain (including: `lualatex`, `latexmk`, ..) - LaTeX tool chain (including: `lualatex`, `latexmk`, ..)
The simplest way to get started is [TeX Live](https://www.tug.org/texlive/), The simplest way to get started is [TeX Live](https://www.tug.org/texlive/),
either a full install or for specific modules see the _Packages_ section either a full install or for specific modules see the _Packages_ section
@ -68,14 +17,33 @@ Build requirements for docs:
## Build / Install
The package is available on:
- CTAN: https://ctan.org/pkg/photobook
- GitHub: https://github.com/flynx/photobook
To install from source:
```shell
# get the source...
$ git clone https://github.com/flynx/photobook.git
# if desired, install in the user context...
$ cd ./photobook
$ make install
```
If only building the docs is required without installing:
```shell
$ make pdf
```
For more info on `make` targets see the: [./Makefile](./Makefile)
## Notes ## Notes
- The main reference is maintained inline with the source [photobook.cls](./photobook.cls)
thus it is both human-readable next to the code it documents and is
used to build the `photobook.pdf`.
Extracting the documentation source (`photobook*.tex`) is done
by [make](./Makefile) via [cls2tex.sh](scripts/README.md#cls2texsh) when
building the docs, see them for more info.
- There is a bug in default captions not being typeset correctly if too - There is a bug in default captions not being typeset correctly if too
long, a workaround is to place them in a `minipage` like this: long, a workaround is to place them in a `minipage` like this:
```latex ```latex
@ -104,4 +72,3 @@ Copyright (c) 2021-2023, Alex A. Naanou,
All rights reserved. All rights reserved.
<!-- vim:set ts=4 sw=4 nowrap : -->

View File

@ -1,151 +0,0 @@
#----------------------------------------------------------------------
#
#
#
#----------------------------------------------------------------------
# make config...
.SECONDEXPANSION:
.DEFAULT_GOAL := all
#SHELL := bash
ifeq ($(DEBUG),)
STDERR := > /dev/null
endif
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# config...
DIST_DIR := dist/PRINT
SPREAD_DIR := spreads
TEMPLATE_DIR := templates
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# sources...
SETUP := \
setup.tex
TEMPLATE_FILES := \
$(wildcard $(TEMPLATE_DIR)/*)
SPREADS := \
spreads.tex
COMPONENTS := \
cover.pdf jacket.pdf endpaper.pdf \
block.pdf
# things that we need that does not need to be built my this Makefile,
# this could include custom graphics, manual layouts, ...etc.
EXTRAS :=
#----------------------------------------------------------------------
# config/commands...
MD = @mkdir -p
# primary engine, everything works...
# NOTE: several hacks had to be made -- see setup.tex
CMD = lualatex
#ARGS = -output-driver="xdvipdfmx -q -E -V 3"
MAKESPREADS := ../../scripts/make-spreads.sh
#----------------------------------------------------------------------
# components and rules...
# generic latex -> pdf...
%.pdf: %.tex $(SETUP)
-$(CMD) $< $(STDERR)
spreads.tex: $(SPREAD_DIR) $(wildcard $(SPREAD_DIR)/*/*) $(TEMPLATE_FILES)
$(MAKESPREADS) $< $(SPREAD) > $@
# in case we need multiple chapters/sections, i.e. sets of spreads...
# XXX needs testing -- % in the wildcard function...
%-spreads.tex: $(SPREAD_DIR)/% $(wildcard $(SPREAD_DIR)/%/*/*) $(TEMPLATE_FILES)
$(MAKESPREADS) $< $(SPREAD) > $@
block.pdf: $(SPREADS)
# XXX need to also include covers and endpapers (optionally?)
# XXX this is broken...
##web.tex: setup.tex
## { \
## echo "% This file is generated via make web.tex" \
## echo "% see the Makefile for info" \
## echo "% do not edit directly" \
## echo \
## echo "\input{setup}" \
## echo \
## echo "\setlength\bleed{0mm}" \
## echo "\setlength\bindingoffset{0mm}" \
## echo \
## echo "\ChangeLayout{endpaper}" \
## echo \
## echo "\pagecolor{black}" \
## echo \
## echo "\begin{document}" \
## echo "\includepdf[pages={{},1-}, nup=2x1, delta=0.3mm 0.3mm]{block}" \
## echo "\end{document}" \
## echo \
## } > $@
#----------------------------------------------------------------------
# production targets...
.PHONY: all
all: $(COMPONENTS) $(EXTRAS)
#----------------------------------------------------------------------
# packageing...
.PHONY: dist
dist: $(COMPONENTS) $(EXTRAS)
$(MD) $(DIST_DIR)
cp $? $(DIST_DIR)
#----------------------------------------------------------------------
# utility trgets...
.PHONY: sweep
sweep:
-rm -f *.out *.aux *.log *.upa ; true
.PHONY: clean
clean: sweep
-rm -rf *.pdf PRINT *.image-list $(SPREADS) ; true
.PHONY: clean-dist
clean-dist:
-rm -rf dist ; true
.PHONY: clean-all
clean-all: clean clean-dist
#----------------------------------------------------------------------
#

View File

@ -1,81 +0,0 @@
Full book example
=================
This directory contains a full book example.
```
book/
├── templates/ . . . . . . . . . . . . Templates used to buld spreads
│   └── ... (used by: make-spreads.sh)
├── spreads/ . . . . . . . . . . . . . Spread layout
│   └── ... (used by: make-spreads.sh)
├── captions/ . . . . . . . . . . . . . Image captions
│   └── ... (used by: make-spreads.sh)
├── hi-res/ . . . . . . . . . . . . . . High resolution graphics
│   └── ... (used by: make-spreads.sh)
├── Makefile
├── setup.tex . . . . . . . . . . . . . Book setup and configuration
│ This file contains all the book
│ geometry, colors and other
│ settings common to all comoponents
│ of the book.
├── block.tex . . . . . . . . . . . . . General page block layout.
├── spreads.tex . . . . . . . . . . . . Book spereads
│ (generated by: make-spreads.sh)
├── cover.tex
├── endpaper.tex
├── jacket.tex
└── ...
```
Note that this is by no means the only or most optomal project
structure, but it is a good enough starting point that evolved through
several, big and small project to start the next one from (at least
for me, subjectively).
Building
--------
To build all components:
```shell
$ make all
```
To build a specific component:
```shell
$ make block.pdf
```
`block.pdf` in this case.
<!-- XXX add basic introspection to Makefike??? -->
Structure
---------
### `setup.tex`
### `spreads.tex`
### `cover.tex` / `jacket.tex` / `endpaper.tex` / ..
### `web.tex`
<!-- XXX this is quite generic, can we generate it? -->
Workflow
--------
XXX
For information about building spreads see:
[make-spreads.sh](../../scripts/README.md)
<!-- vim:set ts=4 sw=4 nowrap : -->

View File

@ -1,28 +0,0 @@
%----------------------------------------------------------------------
\input{setup}
\begin{document} %-----------------------------------------------------
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% XXX half title...
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\BookInfoPage
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% XXX intro...
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% XXX title...
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\input{spreads}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\BookSoftwareInfoPage
\end{document} %-------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -1,17 +0,0 @@
%----------------------------------------------------------------------
\input{setup}
\ChangeLayout{cover}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\begin{document}
\GenerateTemplate
\end{document}
%----------------------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -1,17 +0,0 @@
%----------------------------------------------------------------------
\input{setup}
\ChangeLayout{endpaper}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\begin{document}
\GenerateTemplate
\end{document}
%----------------------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -1,17 +0,0 @@
%----------------------------------------------------------------------
\input{setup}
\ChangeLayout{jacket}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\begin{document}
\GenerateTemplate
\end{document}
%----------------------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -1,42 +0,0 @@
%----------------------------------------------------------------------
\documentclass[
layoutmode=block,
% page size...
blockwidth=240mm, blockheight=220mm,
bleed=4mm,
gutteroffset=5mm,
bindingoffset=1mm,
% cover...
coverboardgrow=3mm,
coverflap=17mm,
spinewidth=15mm,
spinefold=5mm,
spinefold=5mm,
% jacket...
jacketflap=50mm,
jacketwrap=1mm,
% image block configuration...
imageblockwidth=0.98, imageblockheight=0.98,
imageblockoffsettop=-0.1,
% misc...
9pt,final,openany
]{photobook}
\def\BookTitle{Info page demo}
\def\BookVersion{1.0}
\def\BookAuthors{John J. Smith}
\def\ByNotice{%
Graphics: none
Text: almost none}
\def\ThanksTo{%
Everyone}
\def\ISBN{000-0-0000000-0-0}
\def\Edition{I 500}
%----------------------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -1 +0,0 @@
Some text

View File

@ -1 +0,0 @@
Some text

View File

@ -1 +0,0 @@
page text

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

View File

@ -1 +0,0 @@
Some text

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

View File

@ -1 +0,0 @@
caption text

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

View File

@ -1,2 +0,0 @@
\cleardoublepage
\ImagePage{${CAPTION0}}{${IMAGE0}}

View File

@ -1 +0,0 @@
\ImageSpreadFill{${CAPTION}}{${IMAGE0}}

View File

@ -1,2 +0,0 @@
\ImagePage{${CAPTION0}}{${IMAGE0}}
\emptypage

View File

@ -1,2 +0,0 @@
\ImagePage{${CAPTION0}}{${IMAGE0}}
\ImagePage{${CAPTION1}}{${IMAGE1}}

View File

@ -1 +0,0 @@
\ImagePage{${CAPTION}}{${IMAGE}}

View File

@ -1,4 +0,0 @@
\parbox{\textwidth}{%
\setlength{\parskip}{1em}
\input{${TEXT}} }
\newpage

View File

@ -1,28 +0,0 @@
%----------------------------------------------------------------------
%
%
%
%
%----------------------------------------------------------------------
\input{setup}
\setlength\bleed{0mm}
\ChangeLayout{spread}
\pagestyle{empty}
\begin{document} %-----------------------------------------------------
\includepdfmerge{jacket.pdf}
\includepdfmerge{cover.pdf}
\pdfspreadstopages{block}
\end{document} %-------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -1,93 +0,0 @@
%----------------------------------------------------------------------
\documentclass[
layoutmode=block,
% page size...
blockwidth=240mm, blockheight=220mm,
bleed=4mm,
gutteroffset=5mm,
bindingoffset=0mm,
% image block configuration...
imageblockwidth=0.98, imageblockheight=0.98,
imageblockoffsettop=0,
% misc...
9pt,final,openany
]{photobook}
\usepackage{lipsum}
\usepackage{ragged2e}
% XXX for some reason this is not in the top/left corner...
% XXX bug in photobook???
\newcommand\CaptionBox[1][Caption]{%
\setlength\fboxsep{0pt}%
\fbox{%
\setlength\fboxsep{1pt}%
\colorbox{white}{\tiny #1}}}
\begin{document} %-----------------------------------------------------
\setlength\parindent{0em}
\newlength\cellsize
\setlength\cellsize{25mm}
\renewcommand\fbox{\fcolorbox{red}{white}}
\begin{page}%
|cliptocell| bleeds
\par%
\vspace{6mm}%
\setlength\fboxsep{0pt}%
\fbox{%
\begin{inlinecell*}{\cellsize}{\cellsize}%
\imagecell[fill, clearance=-6mm]{\CaptionBox[no clip]}{landscape}%
\end{inlinecell*}}%
\hspace{1cm}%
\fbox{%
\begin{inlinecell*}{\cellsize}{\cellsize}%
\begin{cliptocell}%
\imagecell[fill, clearance=-6mm]{\CaptionBox[default=0pt]}{landscape}%
\end{cliptocell}%
\end{inlinecell*}}%
\hspace{1cm}%
\fbox{%
\begin{inlinecell*}{\cellsize}{\cellsize}%
\begin{cliptocell}[5mm]%
\imagecell[fill, clearance=-6mm]{\CaptionBox[5mm]}{landscape}%
\end{cliptocell}%
\end{inlinecell*}}%
\hspace{1cm}%
\fbox{%
\begin{inlinecell*}{\cellsize}{\cellsize}%
\begin{cliptocell}[1mm 5mm]%
\imagecell[fill, clearance=-6mm]{\CaptionBox[1mm 5mm]}{landscape}%
\end{cliptocell}%
\end{inlinecell*}}%
\hspace{1cm}%
\fbox{%
\begin{inlinecell*}{\cellsize}{\cellsize}%
\begin{cliptocell}[1mm 2mm 3mm 4mm]%
\imagecell[fill, clearance=-6mm]{\CaptionBox[1mm 2mm 3mm 4mm]}{landscape}%
\end{cliptocell}%
\end{inlinecell*}}%
\end{page}%
\begin{page}%
% XXX this is padded by 1mm for some reason -- not sure if it's the
% image or the enclosing cell...
\fbox{%
\begin{inlinecell*}{\cellsize}{\cellsize}%
\imagecell[fit]{}{landscape}%
\end{inlinecell*}}%
\hspace{1cm}%
\fbox{%
\begin{inlinecell*}{\cellsize}{\cellsize}%
\imagecell[fit, clearance=-1mm -2mm -3mm -4mm]{}{landscape}%
\end{inlinecell*}}%
\end{page}%
\end{document} %-------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -1,30 +0,0 @@
%----------------------------------------------------------------------
\documentclass[
layoutmode=cover,
spinewidth=20mm,
spinefold=7mm,
coverboardgrow=3mm,
coverflap=17mm,
% page size...
blockwidth=240mm, blockheight=220mm,
bleed=4mm,
bindingoffset=5mm,
% image block configuration...
imageblockwidth=0.98, imageblockheight=0.98,
imageblockoffsettop=-0.1,
% misc...
9pt,final,openany
]{photobook}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\begin{document}
\GenerateTemplate
\end{document}
%----------------------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -21,40 +21,7 @@
\begin{document} \begin{document}
\begin{page} \GenerateTemplate
\begin{frontcover}
% NOTE: in the real world there is no need to extend the bleeds
% all the way to the end of the flaps, they need to go
% only 2-4 millimeters under the endpaper to account for
% cut and alignment errors...
\begin{cliptocell}[0mm {\coverflap} {\coverflap} {\coverflap}]
\imagecell[fill, clearance=-\coverflap]{}{landscape}
% title...
\begin{zinlinecell}
\begin{center}
\vfill
\color{white}
\Huge TITLE TEXT
\vfill
\end{center}
\end{zinlinecell}
\end{cliptocell}
\end{frontcover}
\begin{spine}
\begin{cliptocell}[0mm \coverflap]
\imagecell[fill, clearance=-\coverflap]{}{landscape}
\end{cliptocell}
\end{spine}
\begin{backcover}
\begin{cliptocell}[{\coverflap} {\coverflap} 0mm {\coverflap}]
\imagecell[fill, clearance=-\coverflap]{}{landscape}
\end{cliptocell}
\end{backcover}
\textblockrulecolour{white}
\textcolor{white}
\GenerateTemplate
\end{page}
\end{document} \end{document}

View File

@ -37,7 +37,7 @@
\end{inlinecell}% \end{inlinecell}%
\hspace{\textblockmargin}% \hspace{\textblockmargin}%
\begin{inlinecell}{0.75\cellwidth - \textblockmargin + \bleed}{\cellheight}% \begin{inlinecell}{0.75\cellwidth - \textblockmargin + \bleed}{\cellheight}%
\imagecell[fill]{}{landscape}% \imagecell[fill]{}{DSC00403-2}%
\end{inlinecell} \end{inlinecell}
\end{spreadtopages} \end{spreadtopages}
@ -45,7 +45,7 @@
\begin{spreadtopages}% \begin{spreadtopages}%
\hspace{-\bleed}% \hspace{-\bleed}%
\begin{inlinecell}{0.75\cellwidth - \textblockmargin + \bleed}{\cellheight}% \begin{inlinecell}{0.75\cellwidth - \textblockmargin + \bleed}{\cellheight}%
\imagecell[fill]{}{landscape}% \imagecell[fill]{}{DSC00403-2}%
\end{inlinecell}% \end{inlinecell}%
\hspace{\textblockmargin}% \hspace{\textblockmargin}%
\begin{inlinecell}{0.25\cellwidth}{\cellheight}% \begin{inlinecell}{0.25\cellwidth}{\cellheight}%

View File

@ -5,8 +5,7 @@
% page size... % page size...
blockwidth=240mm, blockheight=220mm, blockwidth=240mm, blockheight=220mm,
bleed=4mm, bleed=4mm,
gutteroffset=5mm, bindingoffset=5mm,
bindingoffset=0mm,
% image block configuration... % image block configuration...
imageblockwidth=0.98, imageblockheight=0.98, imageblockwidth=0.98, imageblockheight=0.98,
imageblockoffsettop=0, imageblockoffsettop=0,
@ -28,8 +27,8 @@
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\edef\TestImage{landscape} \edef\TestImage{DSC00403-2}
\edef\TestImageV{portrait} \edef\TestImageV{DSC00403-2vert}
\newcommand\Chapter[1]{ \newcommand\Chapter[1]{

View File

@ -1,27 +0,0 @@
%----------------------------------------------------------------------
\documentclass[
layoutmode=endpaper,
% page size...
blockwidth=240mm, blockheight=220mm,
bleed=4mm,
bindingoffset=5mm,
% image block configuration...
imageblockwidth=0.98, imageblockheight=0.98,
imageblockoffsettop=-0.1,
% misc...
9pt,final,openany
]{photobook}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\begin{document}
\GenerateTemplate
\end{document}
%----------------------------------------------------------------------
% vim:set ts=4 sw=4 :

View File

@ -14,52 +14,14 @@
]{photobook} ]{photobook}
\begin{document} % - - - - - - - - - - - - - - - - - - - - - - - - - - -
% the simplest way to fill...
\ImagePageFill{}{landscape}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% manual... \begin{document}
% NOTE: to fill the page the image cell needs to be placed relative to
% the page (papercell / pagecell) and not the text (page env)
\begin{page}
\begin{papercell}
\imagecell[fill, clearance=-\bleed]{}{landscape}
\end{papercell}
\end{page}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% control #1 -- works fine...
\begin{page}
\begin{leftside}
\imagecell[fit]{}{landscape}
\end{leftside}
\begin{rightside}
\imagecell[fit]{}{landscape}
\end{rightside}
\end{page}
\begin{page}
\begin{leftside}
\imagecell[fill, right, clearance=\cliptocellclearances]{}{landscape}
\end{leftside}
\begin{rightside}
\imagecell[fill, left, clearance=\cliptocellclearances]{}{landscape}
\end{rightside}
\end{page}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\GenerateTemplate \GenerateTemplate
\end{document}
\end{document} %-------------------------------------------------------
% vim:set ts=4 sw=4 : %----------------------------------------------------------------------
% vim:set ts=4 sw=4 :

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -1,130 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg1"
width="3840"
height="5495"
viewBox="0 0 3840 5495"
sodipodi:docname="Johannes Vermeer - The Girl With The Pearl Earring (1665).svg"
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
inkscape:export-filename="Johannes Vermeer - The Girl With The Pearl Earring (1665).png"
inkscape:export-xdpi="50"
inkscape:export-ydpi="50"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath2">
<path
style="fill:none;stroke:#ffffff;stroke-width:15.1181;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
d="M 1920,0 0,2747.5 1920,5495 3840,2747.5 Z"
id="path3" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath6">
<rect
style="fill:none;stroke:#ffffff;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect7"
width="500"
height="500"
x="318.06506"
y="257.89059" />
</clipPath>
</defs>
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showguides="true"
inkscape:zoom="0.11632839"
inkscape:cx="1916.9868"
inkscape:cy="2750.8331"
inkscape:window-width="2048"
inkscape:window-height="1115"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g1" />
<g
inkscape:groupmode="layer"
inkscape:label="Image"
id="g1">
<image
width="3840"
height="5495"
preserveAspectRatio="none"
xlink:href="Johannes%20Vermeer%20-%20The%20Girl%20With%20The%20Pearl%20Earring%20(1665).jpg"
id="image1"
sodipodi:insensitive="true"
style="display:inline" />
<g
id="g5"
inkscape:label="large diamond">
<path
style="fill:none;stroke:#000000;stroke-width:60.47244094;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke;stroke-linejoin:miter;stroke-miterlimit:10;stroke-linecap:square"
d="M 1920,0 0,2747.5 1920,5495 3840,2747.5 Z"
id="path1"
clip-path="none"
inkscape:label="black diamond" />
<path
style="fill:none;stroke:#ffffff;stroke-width:30.23622047;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke;stroke-linejoin:miter;stroke-miterlimit:10;stroke-linecap:square"
d="M 1920,0 0,2747.5 1920,5495 3840,2747.5 Z"
id="path4"
clip-path="url(#clipPath2)"
inkscape:label="white diamond" />
</g>
<g
id="g9"
inkscape:label="small diamond">
<rect
style="fill:none;stroke:#000000;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect8"
width="500"
height="500"
x="250"
y="-250"
clip-path="none"
transform="rotate(45)" />
<rect
style="fill:none;stroke:#ffffff;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect5"
width="500"
height="500"
x="318.06506"
y="257.89059"
clip-path="url(#clipPath6)"
transform="rotate(45,647.11071,171.7835)" />
</g>
<use
x="0"
y="0"
xlink:href="#g9"
id="use9"
transform="translate(3132.8932)" />
<use
x="0"
y="0"
xlink:href="#g9"
id="use10"
transform="translate(3132.8932,4787.8932)" />
<use
x="0"
y="0"
xlink:href="#g9"
id="use11"
transform="translate(2.0565886e-5,4789.4527)" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 KiB

View File

@ -1,174 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg1"
width="2000"
height="1350"
viewBox="0 0 2000 1350"
sodipodi:docname="Katsushika Hokusai - The Great Wave off Kanagawa.svg"
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
inkscape:export-filename="Katsushika Hokusai - The Great Wave off Kanagawa.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath6">
<rect
style="fill:none;stroke:#ffffff;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect7"
width="500"
height="500"
x="318.06506"
y="257.89059" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1">
<rect
style="fill:none;stroke:#ffffff;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1"
width="500"
height="500"
x="318.06506"
y="257.89059" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath3">
<rect
style="fill:none;stroke:#ffffff;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect3"
width="500"
height="500"
x="318.06506"
y="257.89059" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath4">
<path
style="fill:none;stroke:#ffffff;stroke-width:15.1181;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
d="M 1920,0 0,2747.5 1920,5495 3840,2747.5 Z"
id="path3" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath5">
<use
x="0"
y="0"
xlink:href="#g2"
id="use5" />
</clipPath>
</defs>
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="0.66962963"
inkscape:cx="1000.5531"
inkscape:cy="675"
inkscape:window-width="2048"
inkscape:window-height="1115"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g1" />
<g
inkscape:groupmode="layer"
inkscape:label="Image"
id="g1">
<image
width="2000"
height="1350"
preserveAspectRatio="none"
xlink:href="Katsushika%20Hokusai%20-%20The%20Great%20Wave%20off%20Kanagawa.jpg"
id="image1"
style="display:inline" />
<g
id="g5"
inkscape:label="large diamond"
transform="matrix(0.52086102,0,0,0.24566116,-0.05316214,0.04597332)"
style="display:inline">
<path
style="display:inline;fill:none;stroke:#000000;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
d="M 1920,0 0,2747.5 1920,5495 3840,2747.5 Z"
id="path1"
clip-path="none"
inkscape:label="black" />
<g
id="g3"
clip-path="url(#clipPath5)"
inkscape:label="white"
style="display:inline">
<g
inkscape:label="Clip"
id="g2">
<path
style="display:inline;fill:none;stroke:#ffffff;stroke-width:30.2362;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
d="M 1920,0 0,2747.5 1920,5495 3840,2747.5 Z"
id="path4"
clip-path="none"
inkscape:label="white diamond" />
</g>
</g>
</g>
<g
id="g9"
inkscape:label="small diamond"
transform="matrix(0.31062245,0,0,0.31062245,3.6225648,2.1883219)"
style="display:inline">
<rect
style="fill:none;stroke:#000000;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect8"
width="500"
height="500"
x="250"
y="-250"
clip-path="none"
transform="rotate(45)" />
<rect
style="fill:none;stroke:#ffffff;stroke-width:60.4724;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect5"
width="500"
height="500"
x="318.06506"
y="257.89059"
clip-path="url(#clipPath6)"
transform="rotate(45,647.11071,171.7835)" />
</g>
<use
x="0"
y="0"
xlink:href="#g9"
id="use9"
transform="translate(1776.7342,-2.1240179)" />
<use
x="0"
y="0"
xlink:href="#g9"
id="use10"
transform="translate(1776.7342,1128.1684)" />
<use
x="0"
y="0"
xlink:href="#g9"
id="use11"
transform="translate(-3.6225648,1128.1684)"
style="display:inline" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -24,18 +24,18 @@
\begin{page} \begin{page}
\begin{frontcover} \begin{frontcover}
\begin{cliptocell}[0mm \bleed] \begin{cliptocell}
\imagecell[fill, clearance=-\bleed]{}{landscape} \imagecell[fill]{}{DSC00403-2}
\end{cliptocell} \end{cliptocell}
\end{frontcover} \end{frontcover}
\begin{backcover} \begin{backcover}
\begin{cliptocell}[0mm \bleed] \begin{cliptocell}
\imagecell[fill, clearance=-\bleed]{}{landscape} \imagecell[fill]{}{DSC00403-2}
\end{cliptocell} \end{cliptocell}
\end{backcover} \end{backcover}
\begin{spine} \begin{spine}
\begin{cliptocell}[0mm \bleed] \begin{cliptocell}
\imagecell[fill, clearance=-\bleed]{}{landscape} \imagecell[fill]{}{DSC00403-2}
\end{cliptocell} \end{cliptocell}
\end{spine} \end{spine}
\begin{frontflap} \begin{frontflap}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 MiB

View File

@ -15,7 +15,7 @@
MAKESPREADS := ../../scripts/make-spreads.sh MAKESPREADS := ../../scripts/make-spreads.sh
spreads.tex: spreads $(wildcard spreads/*/*) spreads.tex: spreads
$(MAKESPREADS) $< $(SPREAD) > $@ $(MAKESPREADS) $< $(SPREAD) > $@
dist: dist:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 KiB

View File

@ -1,6 +0,0 @@
Manual template
\newpage
\ImagePage{${CAPTION}}{${IMAGE}}

View File

@ -1 +0,0 @@
\ImageSpreadFill{${CAPTION}}{${IMAGE0}}

View File

@ -19,8 +19,8 @@
\setlength\parindent{0pt} \setlength\parindent{0pt}
\edef\TestImage{landscape} \edef\TestImage{DSC00403-2}
\edef\TestImageV{portrait} \edef\TestImageV{DSC00403-2vert}
\writeimagelistfalse \writeimagelistfalse

View File

@ -19,8 +19,8 @@
\setlength\parindent{0pt} \setlength\parindent{0pt}
\edef\TestImage{landscape} \edef\TestImage{DSC00403-2}
\edef\TestImageV{portrait} \edef\TestImageV{DSC00403-2vert}
\writeimagelistfalse \writeimagelistfalse

View File

@ -1,44 +0,0 @@
%----------------------------------------------------------------------
\documentclass[
layoutmode=block,
% page size...
blockwidth=240mm, blockheight=220mm,
bleed=4mm,
gutteroffset=5mm,
bindingoffset=0mm,
% image block configuration...
imageblockwidth=0.98, imageblockheight=0.98,
imageblockoffsettop=0,
% misc...
9pt,final,openany
]{photobook}
\usepackage{lipsum}
\usepackage{ragged2e}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\edef\TestImage{landscape}
%----------------------------------------------------------------------
\begin{document}
% force what's next to left page of spread...
\cleartoleftpage
% text...
\begin{page}
\lipsum[1-3]
\end{page}
% image...
\ImagePage{}{\TestImage}
%----------------------------------------------------------------------
\end{document} % vim:set ts=4 sw=4 :

View File

@ -19,8 +19,8 @@
\setlength\parindent{0pt} \setlength\parindent{0pt}
\edef\TestImage{landscape} \edef\TestImage{DSC00403-2}
\edef\TestImageV{portrait} \edef\TestImageV{DSC00403-2vert}
\writeimagelistfalse \writeimagelistfalse

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,9 @@ Support scripts
<!-- TOC depthfrom:2 --> <!-- TOC depthfrom:2 -->
- [make-spreads.sh](#make-spreadssh) - [make-spreads.sh](#make-imagessh)
- [Theory of operation](#theory-of-operation) - [The process](#the-process)
- [Automatic template inferencing](#automatic-template-inferencing) - [Automatic template inferenceing](#automatic-template-inferenceing)
- [Manual template selection](#manual-template-selection) - [Manual template selection](#manual-template-selection)
- [Template tweaking](#template-tweaking) - [Template tweaking](#template-tweaking)
- [Manual spread layouts](#manual-spread-layouts) - [Manual spread layouts](#manual-spread-layouts)
@ -50,7 +50,7 @@ book/
│ ├── image-image.tex │ ├── image-image.tex
│ ├── fullbleed.tex │ ├── fullbleed.tex
│ └── ... │ └── ...
├── spreads/ . . . . . . . . . . . . . Main block layout. ├── spreads/ . . . . . . . . . . . . . . Main block layout.
│   ├── 00/ . . . . . . . . . . . . . . A basic spread. │   ├── 00/ . . . . . . . . . . . . . . A basic spread.
│   │   ├── tweaks.tex The spread template is built │   │   ├── tweaks.tex The spread template is built
│   │   └── 0-DSC02432.jpg automatically with tweaks.tex │   │   └── 0-DSC02432.jpg automatically with tweaks.tex
@ -77,22 +77,23 @@ book/
├── block.tex . . . . . . . . . . . . . Block skeletal layout. ├── block.tex . . . . . . . . . . . . . Block skeletal layout.
│ This usually includes the titles, │ This usually includes the titles,
│ technical pages and sources the │ technical pages and sources the
│ ./block-spreads.tex. │ ./block-pages.tex.
├── block-spreads.tex . . . . . . . . . The generated block content. ├── block-pages.tex . . . . . . . . . . The generated block content.
├── cover.tex . . . . . . . . . . . . . Cover layout. ├── cover.tex . . . . . . . . . . . . . Cover layout.
├── jacket.tex . . . . . . . . . . . . Dust jacket layout. ├── jacket.tex . . . . . . . . . . . . Dust jacket layout.
└── ... └── ...
``` ```
For a full example see: ../examples/book <!-- XXX
For a live example see: ../examples/book -->
Generate the block: Generate the block:
```shell ```shell
$ make-spreads.sh ./spreads > block-spreads.tex $ make-spreads.sh ./pages > block-pages.tex
``` ```
Note that `make-spreads.sh` does not force a specific layout outside of Note that `make-spreads.sh` does not force a specific layout outside of
the `spreads` directory, all paths are configurable. The way the root the `pages` directory, all paths are configurable. The way the root
files are structured in this example is just one way to organize a files are structured in this example is just one way to organize a
book's source code with minimal code duplication. book's source code with minimal code duplication.
@ -103,7 +104,7 @@ $ make-spreads.sh --help
``` ```
### Theory of operation ### The process
<!-- XXX spreads vs. pages --> <!-- XXX spreads vs. pages -->
@ -120,24 +121,24 @@ work is starting to look like a book.
When starting work on a layout it is good to at least have a basic When starting work on a layout it is good to at least have a basic
understanding of the book's: understanding of the book's:
- structure and how it may change, - structure and how it may change,
- general look (i.e. core templates), - core templates,
- exceptions from the above. - exceptions from the above.
In most cases all of the above will change in one way or another during In most cases all of the above will change in one way or another during
the project's lifespan, and the main goal of this stage is to make this the project's lifespan, and the main goal of this stage is to make this
change as efgortless as possible -- it's all about providing the freedom change as simple as possible -- it's all about providing the freedom to
to make changes instead of growing the work invested and thus making make changes instead of growing work invested and thus making change
change more and more expensive. more and more expensive.
The first question is what is the _structure_ of the book we are making? The first question is what is the _structure_ of the book we are making?
Will it have chapters? How many? Text? how much, how should it be Will it have chapters? How many? Text? how much, how should it be
placed? How are we going to deal with the title? How are we going structured? How are we going to deal with the title? How are we going
to present the images, full bleed, no bleeds, small, big, one per page to present the images, full bleed, no bleeds, small, big, one per page
or multiples, ...etc.? At this stage this is about the presentation, or multiple images, ...etc.? At this stage this is about the presentation
the flow of the work and not about the actual design. How many typical the flow of the work and not about the actual design. How many typical
spreads (i.e. spread templates) should it have? A good number should be spreads (i.e. spread templates) should it have? A good number should be
small-ish, for example 3-4 spread templates is a good number, if you small-ish, for example 3-4 spread templates is a good number, if you
count 10+ then you might be overcomplicating things, but note, there are count 10+ then you might be overcomplicating tings, but note, there are
no rules, a book where each spread is individually and manually layed out no rules, a book where each spread is individually and manually layed out
may work as well as a book with just a single template spread, but in may work as well as a book with just a single template spread, but in
general for a photo book the focus is on the project and the layout general for a photo book the focus is on the project and the layout
@ -195,18 +196,7 @@ If only one image/text file is provided then `make-spreads.sh` will set it
on the right page of the spread using the appropriate page template and on the right page of the spread using the appropriate page template and
leave the left page blank. leave the left page blank.
A black page uses `blankpage.tex` template if available, otherwise a <!-- XXX do we need a `blankpage.tex` template??? -->
trivial blank page is used:
```latex
\null
\newpage
```
<!-- XXX
Template search order:
- spread directory
- template directory
-->
#### Manual template selection #### Manual template selection
@ -260,8 +250,6 @@ If `layout.tex` is present it will be included as the page layout/template.
Any paths in the `layout.tex` should be relative to the location the Any paths in the `layout.tex` should be relative to the location the
built block .tex file will be located, usually to the project root. built block .tex file will be located, usually to the project root.
Template field substitution is done as for all other templates.
### Templates ### Templates
@ -310,7 +298,7 @@ environment variable.
Inline captions are also supported: Inline captions are also supported:
```bnf ```bnf
spreads/ pages/
├── <spread>/ ├── <spread>/
│   ├── ... │   ├── ...
│   ├── 00-<image-name>.<ext> │   ├── 00-<image-name>.<ext>
@ -344,8 +332,6 @@ IMAGE_FORMATS=jpeg|jpg|png|pdf|svg|eps
SPREADS_DIR=spreads/ SPREADS_DIR=spreads/
# if non-empty link link images to matching ones from this directory... # if non-empty link link images to matching ones from this directory...
# NOTE: this is ignored if --graphicx-path is passed or GRAPHICX_PATH
# is set.
IMAGE_HIRES_DIR= IMAGE_HIRES_DIR=
# directory where external captions are stored... # directory where external captions are stored...
@ -372,10 +358,6 @@ IMAGE_SPREAD=(
[0]=text-spread [0]=text-spread
[2]=image-image [2]=image-image
) )
# if set (or --graphicx-path is passed) the images are identified by their
# basename so as to let graphicx package resolve the paths internally.
GRAPHICX_PATH=1
``` ```
An explicit configuration file can be manually specified: An explicit configuration file can be manually specified:
@ -392,19 +374,11 @@ $ make-spreads.sh -c <path> ..
Extract the documentation from photobook.cls which is used to build the Extract the documentation from photobook.cls which is used to build the
photobook.pdf reference manual. photobook.pdf reference manual.
This makes it possible to keep the documentation and code it describes
in the same place/file.
The format is in part inspired by LaTeX's [.dtx](http://tug.ctan.org/info/dtxtut/dtxtut.pdf)
format but is far simpler and retains human readability with less effort.
```shell ```shell
$ cls2tex.sh --help $ cls2tex.sh --help
``` ```
The `--help` says it all: The `--help` says it all:
<!-- :r !cl2tex.sh --help -->
``` ```
Generate docs from latex package/class Generate docs from latex package/class
@ -422,8 +396,8 @@ This will:
- read the INPUT - read the INPUT
- keep lines starting with \def\<module-name>@[A-Z]\+ - keep lines starting with \def\<module-name>@[A-Z]\+
- keep lines starting with '%%' - keep lines starting with '%%'
- %%%%% Text -> \subsection{Text} - %%%%% Text -> \subsection(Text)
- %%%% Text -> \section{Text} - %%%% Text -> \section(Text)
- %% >> code -> \begin{verbatim}code\end{verbatim} - %% >> code -> \begin{verbatim}code\end{verbatim}
- write the result to OUTPUT - write the result to OUTPUT
@ -450,4 +424,4 @@ NOTE: the idea of keeping latex docs in a latex file is far simpler
in both the repo and in installed form, so .dtx is not used. in both the repo and in installed form, so .dtx is not used.
``` ```
<!-- vim:set ts=4 sw=4 nowrap : -->

View File

@ -26,8 +26,8 @@ printhelp(){
echo " - read the INPUT" echo " - read the INPUT"
echo " - keep lines starting with \\def\\<module-name>@[A-Z]\\+" echo " - keep lines starting with \\def\\<module-name>@[A-Z]\\+"
echo " - keep lines starting with '%%'" echo " - keep lines starting with '%%'"
echo " - %%%%% Text -> \\subsection{Text}" echo " - %%%%% Text -> \\subsection(Text)"
echo " - %%%% Text -> \\section{Text}" echo " - %%%% Text -> \\section(Text)"
echo " - %% >> code -> \\begin{verbatim}code\\end{verbatim}" echo " - %% >> code -> \\begin{verbatim}code\\end{verbatim}"
echo " - write the result to OUTPUT" echo " - write the result to OUTPUT"
echo echo
@ -54,6 +54,13 @@ printhelp(){
echo " in both the repo and in installed form, so .dtx is not used." echo " in both the repo and in installed form, so .dtx is not used."
} }
# Usage: printerror MESSAGE...
printerror(){
echo Error: $@
echo
printusage
}
# Usage: printmsg TEXT # Usage: printmsg TEXT
printmsg(){ printmsg(){
# print message... # print message...
@ -81,23 +88,21 @@ while true ; do
;; ;;
-p|--prefix) -p|--prefix)
PREFIX=$2 PREFIX=$2
shift 2 shift
continue shift
;; ;;
-s|--strip) -s|--strip)
STRIP_DOC=1 STRIP_DOC=1
shift shift
continue
;; ;;
-n|--no-msg) -n|--no-msg)
NO_MSG=1 NO_MSG=1
shift shift
continue
;; ;;
# handle unknown options... # handle unknown options...
-*|--*) -*|--*)
echo "Error: unknown option: \"$1\"" >&2 printerror "unknown option \"$1\""
exit exit
;; ;;
@ -126,7 +131,7 @@ if [ -z $STRIP_DOC ] ; then
printmsg "Documentation" \ printmsg "Documentation" \
> "$OUTPUT" > "$OUTPUT"
cat "$INPUT" \ cat "$INPUT" \
| grep -E '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \ | egrep '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \
| sed \ | sed \
-e 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \ -e 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \
-e 's/%'$PREFIX'%%%% \(.*\)/%'$PREFIX'\\subsubsection{\1}\\label{subsubsec:\1}/' \ -e 's/%'$PREFIX'%%%% \(.*\)/%'$PREFIX'\\subsubsection{\1}\\label{subsubsec:\1}/' \
@ -141,8 +146,8 @@ else
printmsg "Stripped code" \ printmsg "Stripped code" \
> "$OUTPUT" > "$OUTPUT"
cat "$INPUT" \ cat "$INPUT" \
| grep -Ev '%'$PREFIX'' \ | egrep -v '%'$PREFIX'' \
| grep -Ev '^(\s*%)?\s*$' \ | egrep -v '^(\s*%)?\s*$' \
>> "$OUTPUT" >> "$OUTPUT"
fi fi

297
scripts/make-spreads.sh Executable file → Normal file
View File

@ -1,16 +1,76 @@
#!/usr/bin/env bash #!/bin/bash
shopt -s nullglob extglob shopt -s nullglob extglob
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# #
# For docs see README.md # TIP: It is better to think of a visual book as a set of spreads
# # rather than a set of pages, hence the focus on spreads in the
# code below.
# The main unit of a "visual" book is a spread, it's the thing
# you see when you hold the book open, and the main workflow
# when building a book is creating spreads and ordering them so
# a single page is almost never treated as an independent unit.
# TIP: it is not recommended to use too many templates, the layout
# should be and feel structured and this structure should not be
# too complex for the average reader to get comfortable in.
#
# #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# #
# XXX DOC: # Template structure:
# $TEMPLATE_DIR/
# spread.tex
# imagepage.tex
# textpage.tex
# ...
# $CAPTION_DIR/
# <image>.txt
# image caption.
# this is separated to decouple caption writing from the
# changes to the layout/sequencing and this drastically
# simplify the work with writers.
# For this reason this takes priority over local captions (XXX revise).
# ...
# $SPREADS_DIR/
# $spread/ # $spread/
# ... # tweaks.tex
# template tweaks.
# loaded before the templates are handled.
# layout.tex
# manual layout of spread.
# if given rest of directory contents are
# ignored.
# fields:
# ${IMAGE0}
# replaced with image path
# ${CAPTION0}
# replaced with content of caption file if found
# and empty otherwise.
# ${TEXT0}
# replaced with the content of a text file if
# found and empty otherwise.
# ...
# NOTE: if images are included, hi-res source
# substitution is not done here.
# NOTE: fields are ordered and matched according to their
# position and not their number, e.g. in the following
# sequence:
# IMAGE, IMAGE10, IMAGE20, ..,
# CAPTION2, CAPTION7, CAPTION12, ..
# IMAGE10 will be filled with the second found image
# and CAPTION7 will be filled with the second found
# caption.
# <spread-template-name>.tpl
# indicates the spread template to use.
# if given the rest of the .tex files in
# directory are ignored.
# resolves to:
# templates/<spread-template-name>.tex
# fields:
# ${IMAGE0}
# ${CAPTION0}
# ${TEXT0}
# ...
# imagepage.tex # imagepage.tex
# image page template. # image page template.
# fields: # fields:
@ -27,7 +87,46 @@ shopt -s nullglob extglob
# <spread-template-name>-textpage.tpl # <spread-template-name>-textpage.tpl
# indicates the image/text page template to use. # indicates the image/text page template to use.
# ignored if explicit templates are given. # ignored if explicit templates are given.
# fields:
# ${IMAGE}
# ${CAPTION}
# ${TEXT}
# ...
# 00-<image>.png
# image.
# if $IMAGE_HIRES_DIR is set then this will
# resolve to:
# $IMAGE_HIRES_DIR/<image>
# supported formats:
# .jpeg, .png, .pdf, .svg, .eps
# (see $IMAGE_FORMATS)
# 00-<image>.txt
# local image caption text.
# NOTE: this must be named the same as the image.
# 01-<text>.txt
# text.
# ... # ...
# ...
#
#
# Env variables:
# ANOTATE_IMAGE_PATHS=
# TEXT_FORMATS=<ext>|..
# IMAGE_FORMATS=<ext>|..
# SPREADS_DIR=<path>
# IMAGE_HIRES_DIR=<path>
# sets the path to which the hi-res images are resolved.
# CAPTION_DIR=<path>
# TEMPLATE_DIR=<path>
# EMPTY_PAGE=<name>
# TEXT_PAGE=<name>
# IMAGE_PAGE=<name>
# IMAGE_SPREAD=<array>
#
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# XXX
# #
# #
# #
@ -56,11 +155,9 @@ ANOTATE_IMAGE_PATHS=${ANOTATE_IMAGE_PATHS:=}
# supported formats/extensions... # supported formats/extensions...
TEXT_FORMATS=${TEXT_FORMATS:=$CFG_TEXT_FORMATS} TEXT_FORMATS=${TEXT_FORMATS:=$CFG_TEXT_FORMATS}
TEXT_FORMATS=${TEXT_FORMATS:=txt} TEXT_FORMATS=${TEXT_FORMATS:=txt}
TEXT_FORMATS=${TEXT_FORMATS,,}
IMAGE_FORMATS=${IMAGE_FORMATS:=$CFG_IMAGE_FORMATS} IMAGE_FORMATS=${IMAGE_FORMATS:=$CFG_IMAGE_FORMATS}
IMAGE_FORMATS=${IMAGE_FORMATS:=jpeg|jpg|png|pdf|svg|eps} IMAGE_FORMATS=${IMAGE_FORMATS:=jpeg|jpg|png|pdf|svg|eps}
IMAGE_FORMATS=${IMAGE_FORMATS,,}
SPREADS_DIR=${SPREADS_DIR:=$CFG_SPREADS_DIR} SPREADS_DIR=${SPREADS_DIR:=$CFG_SPREADS_DIR}
@ -93,7 +190,7 @@ IMAGE_PAGE=${IMAGE_PAGE:=imagepage}
# NOTE: the index here corresponds to the number of images found in a # NOTE: the index here corresponds to the number of images found in a
# spread directory... # spread directory...
if [ ${#IMAGE_SPREAD[@]} = 0 ] ; then if [ ${#IMAGE_SPREAD[@]} = 0 ] ; then
if [ ${#CFG_IMAGE_SPREAD[@]} != 0 ] ; then if ! [ ${#CFG_IMAGE_SPREAD[@]} = 0 ] ; then
IMAGE_SPREAD=() IMAGE_SPREAD=()
for i in ${!CFG_IMAGE_SPREAD[@]} ; do for i in ${!CFG_IMAGE_SPREAD[@]} ; do
IMAGE_SPREAD[$i]=${CFG_IMAGE_SPREAD[$i]} IMAGE_SPREAD[$i]=${CFG_IMAGE_SPREAD[$i]}
@ -132,9 +229,6 @@ printhelp(){
echo " - text spread default template (default: ${IMAGE_SPREAD[0]})." echo " - text spread default template (default: ${IMAGE_SPREAD[0]})."
echo " --captions PATH" echo " --captions PATH"
echo " - path to search for captions (default: $CAPTION_DIR)." echo " - path to search for captions (default: $CAPTION_DIR)."
echo " --graphicx-path"
echo " - reference images by their basenames and let graphicx manage"
echo " searching."
echo echo
echo "Parameters:" echo "Parameters:"
echo " PATH - path to root pages directory (default: $SPREADS_DIR)" echo " PATH - path to root pages directory (default: $SPREADS_DIR)"
@ -182,50 +276,38 @@ while true ; do
-a|--annotate) -a|--annotate)
ANOTATE_IMAGE_PATHS=1 ANOTATE_IMAGE_PATHS=1
shift shift
continue
;; ;;
-c) -c)
$CONFIG="$2" $CONFIG="$2"
[ -e "$CONFIG" ] \ [ -e "$CONFIG" ] \
&& source "$CONFIG" && source "$CONFIG"
shift 2 shift 2
continue
;; ;;
--templates) --templates)
TEMPLATE_DIR=$2 TEMPLATE_DIR=$2
shift 2 shift 2
continue
;; ;;
--single-image-tpl) --single-image-tpl)
IMAGE_SPREAD[1]=$2 IMAGE_SPREAD[1]=$2
shift 2 shift 2
continue
;; ;;
--double-image-tpl) --double-image-tpl)
IMAGE_SPREAD[2]=$2 IMAGE_SPREAD[2]=$2
shift 2 shift 2
continue
;; ;;
--text-spread-tpl) --text-spread-tpl)
IMAGE_SPREAD[0]=$2 IMAGE_SPREAD[0]=$2
shift 2 shift 2
continue
;; ;;
--captions) --captions)
CAPTION_DIR=$2 CAPTION_DIR=$2
shift 2 shift 2
continue
;;
--graphicx-path)
GRAPHICX_PATH=1
shift
continue
;; ;;
# handle unknown options... # handle unknown options...
-*|--*) -*|--*)
echo "Error: unknown option \"$1\"" >&2 echo "Error: unknown option \"$1\""
exit exit
;; ;;
@ -296,44 +378,24 @@ readCaption(){
# getTemplate SPREAD TYPE # getTemplate SPREAD TYPE
# #
getTemplate(){ getTemplate(){
local spread=$1 local SPREAD=$1
local name=$2 local TYPE=$2
local template local TEMPLATE=($SPREAD/*-$TYPE.tex)
if [ -z $TEMPLATE ] ; then
if [[ $name =~ .*\.tex ]] ; then TEMPLATE=($SPREAD/*-$TYPE.tpl)
# already an existing template... if ! [ -z $TEMPLATE ] ; then
if [ -e "$name" ] ; then TEMPLATE=${TEMPLATE/$SPREAD\//}
echo $name TEMPLATE=${TEMPLATE/[0-9]-/}
return TEMPLATE="$TEMPLATE_DIR/${TEMPLATE[0]%-${TYPE}.*}.tex"
fi fi
# normalize...
name=${name%.tex}
# normalize template name...
elif [[ $name =~ .*\.tpl ]] ; then
name=$( echo $name \
| sed \
-e 's/.tpl$//' \
-e "s%$spread/%%" \
-e 's/^[0-9]\+-//' )
fi fi
if [ -z $TEMPLATE ] ; then
# local template... TEMPLATE="$TEMPLATE_DIR/${TYPE}.tex"
template=($spread/*-$name.tex)
if [ ${#template[@]} != 0 ] ; then
template=${template[0]}
else
template=($spread/$name.tex)
fi fi
# global template... if ! [ -e $TEMPLATE ] ; then
if [ -z $template ] \ return
|| ! [ -e "$template" ] ; then
template="$TEMPLATE_DIR/${name}.tex"
fi fi
# check if the thing exists... echo $TEMPLATE
if ! [ -e $template ] ; then
return 1
fi
echo $template
} }
@ -358,12 +420,6 @@ templateSlots(){
# usage: # usage:
# populateTemplate SPREAD TEMPLATE ITEMS... # populateTemplate SPREAD TEMPLATE ITEMS...
# #
# closure: $populateTemplate_img, $populateTemplate_txt
#
# NOTE: this is the least hacky/ugly but could not figure out a better
# way to update a list from within a function...
populateTemplate_img=
populateTemplate_txt=
populateTemplate(){ populateTemplate(){
local spread="$1" local spread="$1"
local tpl="$2" local tpl="$2"
@ -382,22 +438,12 @@ populateTemplate(){
local txt=() local txt=()
local elem local elem
for elem in "${items[@]}" ; do for elem in "${items[@]}" ; do
if [[ "${elem,,}" =~ $IMAGE_FORMATS ]] ; then if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then
img+=("$elem") img+=("$elem")
elif [[ "${elem,,}" =~ $TEXT_FORMATS ]] ; then elif [[ "$elem" =~ $TEXT_FORMATS ]] ; then
txt+=("$elem") txt+=("$elem")
fi fi
done done
local global_img=
if ! [ -z $populateTemplate_img ] ; then
global_img=1
img=(${populateTemplate_img[@]})
fi
local global_txt=
if ! [ -z $populateTemplate_txt ] ; then
global_txt=1
txt=(${populateTemplate_txt[@]})
fi
local var local var
local val local val
@ -413,7 +459,7 @@ populateTemplate(){
local i=0 local i=0
for var in ${slots[@]} ; do for var in ${slots[@]} ; do
name=${var//[0-9]/} name=${var//[0-9]/}
if [ ${name} != "IMAGE" ] ; then if ! [ ${name} = "IMAGE" ] ; then
continue continue
fi fi
@ -433,17 +479,14 @@ populateTemplate(){
i=$(( i + 1 )) i=$(( i + 1 ))
val=${val//\//\\/} val=${val//\//\\/}
text=$(echo "${text}" | \ text=$(echo -e "${text}" | \
sed "s/\${${var}}/${val%.*}/g") sed "s/\${${var}}/${val%.*}/g")
done done
if ! [ -z $global_img ] ; then
populateTemplate_img=("${populateTemplate_img[@]:$i}")
fi
# pass 2: captions... # pass 2: captions...
for var in ${slots[@]} ; do for var in ${slots[@]} ; do
name=${var//[0-9]/} name=${var//[0-9]/}
if [ ${name} != "CAPTION" ] ; then if ! [ ${name} = "CAPTION" ] ; then
continue continue
fi fi
@ -459,7 +502,7 @@ populateTemplate(){
val=$(readCaption "${val}") val=$(readCaption "${val}")
fi fi
text=$(echo "${text}" | \ text=$(echo -e "${text}" | \
sed "s/\${${var}}/${val}/g") sed "s/\${${var}}/${val}/g")
done done
@ -480,17 +523,14 @@ populateTemplate(){
done done
val=${val//\//\\/} val=${val//\//\\/}
text=$(echo "${text}" | \ text=$(echo -e "${text}" | \
sed "s/\${${var}}/${val}/g") sed "s/\${${var}}/${val}/g")
done done
if ! [ -z $global_txt ] ; then
populateTemplate_txt=("${txt[@]}")
fi
# print out the filled template... # print out the filled template...
echo % template: $tpl echo % template: $tpl
echo "${text}" echo -e "${text}"
return return 0
} }
@ -498,7 +538,7 @@ populateTemplate(){
# usage: # usage:
# handleSpread SPREAD # handleSpread SPREAD
# #
# closure: $GRAPHICX_PATH, $IMAGE_HIRES_DIR, $IMAGE_SPREAD # closure: $IMAGE_HIRES_DIR, $IMAGE_SPREAD
handleSpread(){ handleSpread(){
local spread="$1" local spread="$1"
# skip non-spreads... # skip non-spreads...
@ -523,41 +563,30 @@ handleSpread(){
local txt=() local txt=()
local items=() local items=()
for elem in "$spread"/* ; do for elem in "$spread"/* ; do
if [[ "${elem,,}" =~ $IMAGE_FORMATS ]] ; then if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then
img+=("$elem") img+=("$elem")
items+=("$elem") items+=("$elem")
elif [[ "${elem,,}" =~ $TEXT_FORMATS ]] ; then elif [[ "$elem" =~ $TEXT_FORMATS ]] ; then
txt+=("$elem") txt+=("$elem")
items+=("$elem") items+=("$elem")
fi fi
done done
# graphicx paths...
if ! [ -z $GRAPHICX_PATH ] ; then
local C=0
for image in "${img[@]}" ; do
local new=`basename ${image}`
new="${new#+([0-9])-}"
img[$C]=$new
C=$(( C + 1 ))
done
# get hi-res image paths... # get hi-res image paths...
elif ! [ -z $IMAGE_HIRES_DIR ] ; then if ! [ -z $IMAGE_HIRES_DIR ] ; then
local C=0 local C=0
for image in "${img[@]}" ; do for image in "${img[@]}" ; do
# skip non-images... # skip non-images...
local new=`basename ${image}` local new="$IMAGE_HIRES_DIR/`basename ${image/[0-9]-/}`"
new="$IMAGE_HIRES_DIR/${new#+([0-9])-}"
# ignore file ext for availability test... # ignore file ext for availability test...
# NOTE: the first match may be an unsupported format... # NOTE: the first match may be an unsupported format...
new="${new%.*}" new="${new%.*}"
local target=$new
new=($new.*) new=($new.*)
if [ -e "${new[0]}" ] ; then if [ -e "${new[0]}" ] ; then
img[$C]=${new[0]} img[$C]=${new[0]}
else else
echo % echo %
echo "% WARNING: hi-res image not found for: \"${image}\" -> \"${target}\"" \ echo "% WARNING: hi-res image not found for: \"${image}\" -> \"${new}\"" \
| tee >(cat >&2) | tee >(cat >&2)
echo % echo %
fi fi
@ -578,7 +607,7 @@ handleSpread(){
# XXX this will also eat 0-imagepage.tpl / 20-textpage.tpl -- do a better pattern... # XXX this will also eat 0-imagepage.tpl / 20-textpage.tpl -- do a better pattern...
if ! [ -z $template ] ; then if ! [ -z $template ] ; then
template=(`ls "$spread/"*.tpl \ template=(`ls "$spread/"*.tpl \
| grep -E -v '.*-('${IMAGE_PAGE}'|'${TEXT_PAGE}')\.tpl'`) | egrep -v '.*-('${IMAGE_PAGE}'|'${TEXT_PAGE}')\.tpl'`)
fi fi
# no template explicitly defined -> match auto-template... # no template explicitly defined -> match auto-template...
if [ -z $layout ] && [ -z $template ] ; then if [ -z $layout ] && [ -z $template ] ; then
@ -606,61 +635,63 @@ handleSpread(){
cat "${template}" cat "${template}"
fi fi
fi fi
populateTemplate_img=("${img[@]}")
populateTemplate_txt=("${txt[@]}")
for elem in "${items[@]}" ; do for elem in "${items[@]}" ; do
C=$(( C + 1 )) C=$(( C + 1 ))
P=$([ $C == 1 ] \ P=$([ $C == 1 ] \
&& echo "left" \ && echo "left" \
|| echo "right") || echo "right")
# XXX need to use populateTemplate here...
# ...to do this need to somehow remove the used
# slots/files from list...
# image... # image...
if [[ "${elem,,}" =~ $IMAGE_FORMATS ]] ; then if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then
echo % echo %
echo "% $P page (image)..." echo "% $P page (image)..."
template=`getTemplate "$spread" "$IMAGE_PAGE"` template=`getTemplate "$spread" "$IMAGE_PAGE"`
populateTemplate "$spread" "$template" echo % template: $template
anotatePath "${elem}"
local caption=$(getCaption "$spread" "${elem}")
caption=$(readCaption "$caption")
cat "${template}" \
| sed -e "s%\${IMAGE0\?}%${elem%.*}%" \
-e "s%\${CAPTION0\?}%${caption}%"
# text... # text...
else else
echo % echo %
echo "% $P page (text)..." echo "% $P page (text)..."
template=$(getTemplate "$spread" "$TEXT_PAGE") template=$(getTemplate "$spread" "$TEXT_PAGE")
populateTemplate "$spread" "$template" echo % template: $template
cat "${template}" \
| sed "s%\${TEXT}%${elem}%"
fi fi
# reset for next page... # reset for next page...
template= template=
# ignore the rest of the items when we are done # ignore the rest of the items when we are done
# creating two pages... # creating two pages...
if [ $C == 2 ] ; then [ $C == 2 ] \
populateTemplate_img= && return 0
populateTemplate_txt=
return
fi
done done
fi fi
fi fi
# formatting done... # formatting done...
[ -z $template ] \ [ -z $template ] \
&& return && return 0
# resolve the template path... # format template path...
local p=$template template=${template/$spread\//}
template=$(getTemplate "$spread" "$template") template=${template/[0-9]-/}
# get...
# not found... template="${template[0]%.*}.tex"
if [ -z $template ] ; then if ! [ -e "$template" ] ; then
echo "%" template="$TEMPLATE_DIR/${template[0]%.*}.tex"
echo "% ERROR: could not resolve template: $p" | tee >(cat >&2)
echo "%"
fi fi
fi fi
populateTemplate_img=
populateTemplate_txt=
populateTemplate "$spread" "$template" "${img[@]}" "${txt[@]}" populateTemplate "$spread" "$template" "${img[@]}" "${txt[@]}"
return $? return 0
} }

View File

@ -45,7 +45,7 @@
\usepackage{fontspec} \usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Open Sans} \setmainfont[Mapping=tex-text]{Open Sans}
\setsansfont[Mapping=tex-text]{Open Sans} \setsansfont[Mapping=tex-text]{Open Sans}
%\setmonofont[Mapping=tex-text, Scale=0.8]{Courier New} \setmonofont[Mapping=tex-text, Scale=0.8]{Courier New}
\newfontfamily\titlefont[Mapping=tex-text]{Open Sans Light} \newfontfamily\titlefont[Mapping=tex-text]{Open Sans Light}
\newfontfamily\sectiontitlefont[Mapping=tex-text]{Open Sans Light} \newfontfamily\sectiontitlefont[Mapping=tex-text]{Open Sans Light}

View File

@ -42,13 +42,10 @@
%\fontsize{30pt}{36pt}\selectfont %\fontsize{30pt}{36pt}\selectfont
% fonts... % fonts...
%\usepackage{ascii}
%\usepackage[default,oldstyle,scale=0.95]{opensans}
%\usepackage[T1]{fontenc}
\usepackage{fontspec} \usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Open Sans} \setmainfont[Mapping=tex-text]{Open Sans}
\setsansfont[Mapping=tex-text]{Open Sans} \setsansfont[Mapping=tex-text]{Open Sans}
%\setmonofont[Mapping=tex-text, Scale=0.8]{Courier New} \setmonofont[Mapping=tex-text, Scale=0.8]{Courier New}
\newfontfamily\titlefont[Mapping=tex-text]{Open Sans Light} \newfontfamily\titlefont[Mapping=tex-text]{Open Sans Light}
\newfontfamily\sectiontitlefont[Mapping=tex-text]{Open Sans Light} \newfontfamily\sectiontitlefont[Mapping=tex-text]{Open Sans Light}