# flowfram: more dynamic page range

My purpose is a document template which allows me to set up various text frames on each page including columns/graphics/... . To realize this, I chose flowfram because it seems to be the only package of this type out there.

So far, the package does its job but I've some headache about how the frames are defined. Each frame needs a specified page range (e.g. 1,3-6,>8) set in the preamble. Now when writing a long document with masses of frames declared, it maybe doesn't make any problems if you write your content straight down. But, when you like to edit and add some content somewhere in the middle of the document, the whole design breaks and ends in a mess. The only way - as I understand - is to redefine all the frames behind/afterwards of the edit.

Is there any trick to handle this more comfortably? I tried to make use of a counter defined by my own, but the counting sequence breaks in the preamble (because of flowfram).

For example:

I would like to have a 3-column-design (\Ncolumn...) over 4 pages or so, and on the second page of them I need a completely different layout to include e.g. a graphic. In this case you would - in my understanding - declare \Ncolumn[1]{3} followed by a more complex definition for page 2 and then end with something like \Ncolumn[>3]. As far as I know, there is no possibility to "pause" (save+resume) a running design.

Now let's assume that the document under discussion has about 106 pages with 2/3 unique layouts, and you need to add about 10 pages somewhere at the beginning. You add your text, and then you need to redefine all the defined pages. The simplest way would be to just add an increment of about 10.

Now be to honest, this isn't an adequate solution at all if you have more than 200 frames. Does anybody have a solution that allows to set the page ranges in a more dynamic/relative way? Or to overwrite layouts pagewise? Or, what about overlaying frames resulting in wrapped text (graphics)? It would help me so much.

-
I did this kind of thing in my "LaTeX for Complete Novices" book when switching from the main text (one column) to the summary and index (two column + dynamic frames) and then back again to one column. The source is available (dickimaw-books.com/latex/novices) but it's quite complex. I'll see if I can work out a simplified version. –  Nicola Talbot Oct 17 '12 at 11:54
@NicolaTalbot Thanks so far. I checked your source but sadly didn't find any frame definitions... =/ BTW: A command to reset all running frames (defined by >X) would be really great for the package. Also, as I mentioned before, an 'overlaying' option for frames (e.g. set a frame over another, and the existing gets shorter/smaller) would be perfect! –  triton Oct 17 '12 at 14:56
@NicolaTalbot ...okay, now I found what you mentioned. But indeed, it's really complex and specific. In principle, I tried even the same but with simple counters, which didn't work. I would be glad, if you could provide something for more conventional usage. =) –  triton Oct 17 '12 at 17:11

Version 1.14 of the flowfram package (uploaded to CTAN 2012-11-10, it may take a day or two to propagate through the mirrors) now provides a slightly easier way to do this kind of thing. Here's an example of a document that starts out with a single column layout, then switches to a 2-column layout, but the first page of each chapter has a slightly modified 2-column layout with a dynamic frame that contains the chapter title. Additionally, in the second sample chapter a single frame layout is switched on for just one page, which contains a figure. That requires the use of \clearpage to ensure the figure lands on the right page. Another approach is shown in the third sample chapter where a dynamic frame is switched on for one page and a static figure placed in it. This has the advantage of not interrupting the text flow. Maybe you might be able to adapt this example for your document.

\documentclass{book}

\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{color}
\usepackage[pages=absolute]{flowfram}

\onecolumn

% assign a label to make it easier to reference
\setflowframe{1}{label=single}

% create a layout for the first page of each chapter
\twocolumnDtop[none]{2in}

% assign labels to these new frames
\setdynamicframe{1}{label=title}
\setflowframe{2}{label=shortleft}
\setflowframe{3}{label=shortright}

% two column layout used for most of the main matter
\twocolumn[none]

% assign labels
\setflowframe{4}{label=left}
\setflowframe{5}{label=right}

% dynamic frame used for sample figure in chapter 3
\newdynamicframe[none]{\textwidth}{\textheight}{0pt}{0pt}[image]

\setdynamicframe*{image}{valign=c}

\title{Sample Document}
\author{A.N. Other}

\begin{document}\raggedright
\maketitle

\frontmatter
\tableofcontents
\chapter{Acknowledgements}

\lipsum[1]

% switch off the flow frame labelled 'single' on the next odd page
\flowswitchoffnextodd*{single}%
% switch on the flow frames labelled 'shortleft' and 'shortright'
% just on the next odd page
\flowswitchonnextoddonly*{shortleft,shortright}%
% switch on the dynamic frame labelled 'title' just for
% the next odd page
\dynamicswitchonnextoddonly*{title}%
% put the chapter headings in the dynamic frame labelled 'title'

\mainmatter
\chapter{Sample}

% switch on the flow frames labelled 'left' and 'right' on the next page
\flowswitchonnext*{left,right}%
% From this point onwards, automate the switch at the start of
% each chapter (this can't be done before as \mainmatter does
% \cleardoublepage, which causes interference).
\renewcommand{\ffprechapterhook}{%
\flowswitchoffnextoddonly*{left,right}%
\flowswitchonnextoddonly*{shortleft,shortright}%
\dynamicswitchonnextoddonly*{title}%
}

\lipsum

\lipsum

\chapter{Another Sample Chapter}

\lipsum[1-20]

% Switch to single column just for the next page

\flowswitchoffnextonly*{left,right}
\flowswitchonnextonly*{single}

\clearpage

\begin{figure}[p]
\centering
\includegraphics{image1}
\caption{A Sample Figure}
\label{fig:sample}
\end{figure}

\clearpage

\lipsum[21-30]

\chapter{Here's Another Chapter}

\lipsum[1-20]

% Switch of columns for next page only and switch on dynamic frame
% called "image":

\flowswitchoffnextonly*{left,right}
\dynamicswitchonnextonly*{image}

\setdynamiccontents*{image}{%
\begin{staticfigure}
\centering
\includegraphics{image2}
\caption{Another Sample Figure}
\label{fig:sample2}
\end{staticfigure}
}

\lipsum[21-40]

\end{document}


Edit: This example is now in the samples subdirectory of the flowfram distribution (called sample-pages.tex). The corresponding sample-pages.pdf shows the resulting document (the draft option is on, so all the frame bounding boxes are visible).

-
ctan announces after "giving the mirrors time to catch up"; mirrors are supposed to be no more than 24 hours behind. i installed the update at 08xx yesterday, so i've now sent an announcement. however, neither texlive nor miktex has picked up the new version, i'm afraid. (presumably they've taken a sunday rest...) –  wasteofspace Nov 12 '12 at 11:38