2

Problem: I asked a question recently about putting a 2 column abstract and title within a 3 column document for which John Kormylo provided an answer that worked as intended followed by helpful comments. The issue I face when putting the code into my main document is two things: 1) The \columnsep lines extend fully down the page irrespective of how much content is on the page and 2) I cannot see a way to balance the columns and have the sep lines extend only to the end of the balanced text. My knowledge on flowfram is limited and I am not sure if this is possible, but ideally I would like for my literature reviews to resemble the second picture and not first if possible.

How it currently looks:

enter image description here

How I would like the balancing and line extensions to look if possible:

enter image description here

What I have tried: Admittedly, very little as I do not understand flowfram although I will have to at some point as the package is useful. I tried using the package flushend but after reading the documentation, this only applies to double columns.

MWE (courtesy of @John Kormylo):

\documentclass{article}
\usepackage[portrait,margin=1cm]{geometry}% http://ctan.org/pkg/geometry
\usepackage{flowfram}% http://ctan.org/pkg/flowfram
\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\newsavebox{\titlebox} \setlength{\columnwidth}{\dimexpr \textwidth-2\columnsep} \divide\columnwidth by 3 \makeatletter \renewenvironment{abstract}{\begin{lrbox}{\titlebox}% \maketitle inside \titlebox \begin{minipage}{\dimexpr 2\columnwidth+\columnsep}% @twocolumntrue \maketitle \small \begin{center}% {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}% \end{center} \itshape}% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY {\bigskip \end{minipage}% \end{lrbox}% \global\setbox\titlebox=\copy\titlebox } \makeatother

\title{\lipsum[1][1]}% must go before abstract

\author{% {\normalsize\bfseries Author Name} \[1ex] \normalsize University Name \ }

\date{\today}

\begin{abstract}% must go before flowfram setup \noindent \lipsum[1][1-3] \end{abstract}

% First page setup \newstaticframe[1]{\dimexpr 2\columnwidth+\columnsep}{\dimexpr \ht\titlebox+\dp\titlebox} {0pt}{\dimexpr \textheight-\ht\titlebox-\dp\titlebox}[titleabstract] \newflowframe[1]{\columnwidth}{\dimexpr \textheight-\ht\titlebox-\dp\titlebox} {0pt}{0pt}[shortleftcolumn] \newflowframe[1]{\columnwidth}{\dimexpr \textheight-\ht\titlebox-\dp\titlebox} {\dimexpr \columnwidth+\columnsep}{0pt}[shortcentercolumn]

% Subsequent pages setup
\newflowframe[>1]{\columnwidth}{\textheight} {0pt}{0pt}[leftcolumn] \newflowframe[>1]{\columnwidth}{\textheight} {\dimexpr \columnwidth+\columnsep}{0pt}[centercolumn] \newflowframe{\columnwidth}{\textheight} {\dimexpr \textwidth-\columnwidth}{0pt}[rightcolumn]

\begin{staticcontents}{titleabstract} \box\titlebox \end{staticcontents}

% draw rules \getflowid{\IDleft}{shortleftcolumn} \getflowid{\IDright}{shortcentercolumn} \insertvrule{flow}{\IDleft}{flow}{\IDright} \let\IDleft=\IDright \getflowid{\IDright}{rightcolumn} \insertvrule{flow}{\IDleft}{flow}{\IDright}

\getflowid{\IDleft}{leftcolumn} \getflowid{\IDright}{centercolumn} \insertvrule{flow}{\IDleft}{flow}{\IDright} \let\IDleft=\IDright \getflowid{\IDright}{rightcolumn} \insertvrule{flow}{\IDleft}{flow}{\IDright}

\begin{document}

\lipsum[1-10]

\end{document}

I have no idea where to begin with this problem. I hope the community does not mind me asking a question for which I have not attempted serious solutions not involving simple packages such as flushend due to not understanding the flowfram package.

Edit 1: After reading the flowfram package annotated documentation pp. 180-181, it appears that

\insertvrule{flow}{\IDleft}{flow}{\IDright}

can be modified with optional arguments to extend the the vertical lines in the negative direction such as

\insertvrule[0pt][-18.3cm]{flow}{\IDleft}{flow}{\IDright}

which now gives:

enter image description here

This can be done manually if needs be but to modify my questions: 1) Is there a way for LaTeX to detect how far the text comes down the page without having to resort to manual distances guess (-18.3cm etc) and 2) is there a way to balance the triple columns within flowfram?

1 Answers1

3

Since flowfram has to be set before the aux file is read, this writes a similar file FFsetup.tex which is read earlier. It defines macros \lastpage and \lastheight.

The macro \firstFFsetup handles the case when there is suddenly fewer pages than before. \secondFFsetupe handles the case when the number of pages is the same as before. \extraFFsetup handles the case when there is now more text (which automatically goes to overflow pages).

\documentclass{article}
\usepackage[portrait,margin=1cm]{geometry}% http://ctan.org/pkg/geometry
\usepackage{flowfram}% http://ctan.org/pkg/flowfram
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{refcount}

\newsavebox{\titlebox} \setlength{\columnwidth}{\dimexpr \textwidth-2\columnsep} \divide\columnwidth by 3

\makeatletter \renewenvironment{abstract}{\begin{lrbox}{\titlebox}% \maketitle inside \titlebox \begin{minipage}{\dimexpr 2\columnwidth+\columnsep}% @twocolumntrue \maketitle \small \begin{center}% {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}% \end{center} \itshape}% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY {\bigskip \end{minipage}% \end{lrbox}% \global\setbox\titlebox=\copy\titlebox } \makeatother

\title{\lipsum[1][1]}% must go before abstract

\author{% {\normalsize\bfseries Author Name} \[1ex] \normalsize University Name \ }

\date{\today}

\begin{abstract}% must go before flowfram setup \noindent \lipsum[1][1-3] \end{abstract}

% First page setup \newstaticframe[1]{\dimexpr 2\columnwidth+\columnsep}{\dimexpr \ht\titlebox+\dp\titlebox} {0pt}{\dimexpr \textheight-\ht\titlebox-\dp\titlebox}[titleabstract] \newflowframe[1]{\columnwidth}{\dimexpr \textheight-\ht\titlebox-\dp\titlebox} {0pt}{0pt}[shortleftcolumn] \newflowframe[1]{\columnwidth}{\dimexpr \textheight-\ht\titlebox-\dp\titlebox} {\dimexpr \columnwidth+\columnsep}{0pt}[shortcentercolumn] \newflowframe[1]{\columnwidth}{\textheight}{\dimexpr \textwidth-\columnwidth}{0pt}[shortrightcolumn]

\getflowid{\IDleft}{shortleftcolumn} \getflowid{\IDcenter}{shortcentercolumn} \getflowid{\IDright}{shortrightcolumn} \insertvrule{flow}{\IDleft}{flow}{\IDcenter} \insertvrule{flow}{\IDcenter}{flow}{\IDright}

\InputIfFileExists{FFsetup}{}{}% args not useful

\makeatletter @ifundefined{lastpage}{% first time only \newflowframe[>1]{\columnwidth}{\textheight}{0pt}{0pt}[leftcolumn] \newflowframe[>1]{\columnwidth}{\textheight}{\dimexpr \columnwidth+\columnsep}{0pt}[centercolumn] \newflowframe[>1]{\columnwidth}{\textheight}{\dimexpr \textwidth-\columnwidth}{0pt}[rightcolumn] \getflowid{\IDleft}{leftcolumn} \getflowid{\IDcenter}{centercolumn} \getflowid{\IDright}{rightcolumn} \insertvrule{flow}{\IDleft}{flow}{\IDcenter} \insertvrule{flow}{\IDcenter}{flow}{\IDright}% }{% \lastpage and \lastheight defined \ifnum\lastpage>2\relax \newcommand{\nextlastpage}{\the\numexpr \lastpage-1}% \newflowframe[2-\nextlastpage]{\columnwidth}{\textheight}{0pt}{0pt}[leftcolumn]% \newflowframe[2-\nextlastpage]{\columnwidth}{\textheight}{\dimexpr \columnwidth+\columnsep}{0pt}[centercolumn]% \newflowframe[2-\nextlastpage]{\columnwidth}{\textheight}{\dimexpr \textwidth-\columnwidth}{0pt}[rightcolumn]% \getflowid{\IDleft}{leftcolumn}% \getflowid{\IDcenter}{centercolumn}% \getflowid{\IDright}{rightcolumn}% \insertvrule{flow}{\IDleft}{flow}{\IDcenter}% \insertvrule{flow}{\IDcenter}{flow}{\IDright}% \fi \newflowframe[\lastpage]{\columnwidth}{\lastheight} {0pt}{\dimexpr \textheight-\lastheight}[topleftcolumn]% \newflowframe[\lastpage]{\columnwidth}{\lastheight} {\dimexpr \columnwidth+\columnsep}{\dimexpr \textheight-\lastheight}[topcentercolumn] \newflowframe[\lastpage]{\columnwidth}{\lastheight} {\dimexpr \textwidth-\columnwidth}{\dimexpr \textheight-\lastheight}[toprightcolumn] \getflowid{\IDleft}{topleftcolumn}% \getflowid{\IDcenter}{topcentercolumn}% \getflowid{\IDright}{toprightcolumn}% \insertvrule{flow}{\IDleft}{flow}{\IDcenter}% \insertvrule{flow}{\IDcenter}{flow}{\IDright}% % excess text \newflowframe[>\lastpage]{\columnwidth}{\textheight}{0pt}{0pt}% \newflowframe[>\lastpage]{\columnwidth}{\textheight}{\dimexpr \columnwidth+\columnsep}{0pt}% \newflowframe[>\lastpage]{\columnwidth}{\textheight}{\dimexpr \textwidth-\columnwidth}{0pt}% }

\newcommand{\firstFFsetup}{% first time \edef\lastpage{\arabic{page}}% \dimen0=\dimexpr \textheight-\pagegoal+\pagetotal+2\baselineskip\relax \ifnum\value{displayedframe}>1 \advance\dimen0 by \textheight \fi \ifnum\value{displayedframe}>2 \advance\dimen0 by \textheight \fi \count1=\numexpr \dimen0/\baselineskip\relax \divide\count1 by 3 \dimen0=\baselineskip \multiply\dimen0 by \count1 \edef\lastheight{\the\dimen0}}

\newcommand{\secondFFsetup}{% same last page \dimen0=\dimexpr \lastheight-\pagegoal+\pagetotal+2\baselineskip\relax \ifnum\value{displayedframe}>1 \advance\dimen0 by \lastheight \fi \ifnum\value{displayedframe}>2 \advance\dimen0 by \lastheight \fi \count1=\numexpr \dimen0/\baselineskip\relax \divide\count1 by 3 \dimen0=\baselineskip \multiply\dimen0 by \count1 \edef\lastheight{\the\dimen0}}

\newcommand{\extraFFsetup}{% extra pages \dimen0=\lastheight\relax \multiply\dimen0 by 3 \advance\dimen0 by \dimexpr \textheight-\pagegoal+\pagetotal+2\baselineskip\relax \ifnum\value{displayedframe}>1 \advance\dimen0 by \textheight \fi \ifnum\value{displayedframe}>2 \advance\dimen0 by \textheight \fi \count1=\value{page}% \ifdim\dimen0<3\textheight\relax \advance\count1 by -1 \else \advance\dimen0 by -3\textheight \fi \edef\lastpage{\number\count1}% \count1=\numexpr \dimen0/\baselineskip\relax \divide\count1 by 3 \dimen0=\baselineskip \multiply\dimen0 by \count1 \edef\lastheight{\the\dimen0}}

\AtEndDocument{@ifundefined{lastpage}{% first time \firstFFsetup }{% \ifnum\lastpage>\value{page}\relax \firstFFsetup \else\ifnum\lastpage=\value{page}\relax \secondFFsetup \else \extraFFsetup \fi \fi }% \newwrite\FFid \immediate\openout\FFid=FFsetup \immediate\write\FFid{\string\gdef\string\lastpage{\lastpage}}% \immediate\write\FFid{\string\gdef\string\lastheight{\lastheight}}%\thedisplayedframe \closeout\FFid} \makeatother

\begin{staticcontents}{titleabstract} \box\titlebox \end{staticcontents}

\begin{document} \sloppy \lipsum[1-20]

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Accepted and upvoted as it did as required although I still cannot work out how to balance the columns - it's sad that flushend and balance only work on two columns! Might need to look at the multicol .sty file to see how that balances multiple columns, doesn't seem possible in flowfram. Thanks for the answers you have provided. –  Mar 15 '22 at 18:17
  • To no-one in particular, a crude method to balance the final page is to manually insert \newpage \noindent\ on text until the columns are balanced. Not sure how to do this with bibliography entries if used but at least there is a method. –  Mar 15 '22 at 20:04
  • Alas, multicol and frowfram appear to be incompatible, Even loading both at the same time causes major problems. – John Kormylo Mar 16 '22 at 14:01
  • Yeah the packages broke on me whilst using them too. I adapted your first answer and asked a new question regarding how to break biblatex entries so that they could be balanced, your second answer worked in my main document too, appreciate it. –  Mar 16 '22 at 18:20
  • The main problem is that flowfram is set up before the aux file is read, so there is no way to communicate the information needed. Unless you used a different file... – John Kormylo Mar 16 '22 at 22:55
  • 1
    I was wondering if one could set up flowfram using \AtBeginDocument, but no joy. – John Kormylo Mar 17 '22 at 16:09
  • Thank you for trying. It is an incredibly good package for custom layouts but it's extremely fidgety and the manual is quite bright to look at. Even float pages require custom flowpages, really impressive package but complicated. I appreciate your time with this package and questions, I'm going to learn it better as it is useful. –  Mar 17 '22 at 17:01
  • I replaced both versions with a new one which (finally) does what you want. It still takes two runs to adjust to changes. – John Kormylo Mar 22 '22 at 20:50
  • Thank you, that's genuinely amazing and everything I needed rather than doing it manually, I appreciate the time and effort you put into so gave a bounty. –  Mar 22 '22 at 20:56
  • 1
    @JohnKormylo Really such a nice work, is it possible to place the figure upto two column and three column, please advise... – MadyYuvi Mar 23 '22 at 10:01
  • 1
    @MadyYuvi yeah I was going to open a new question on that issue, it looks like new flowframes need to be setup for each page the table or figure on which is unfortunate. If the figure or table environment could force itself in and wrap text then that would be incredible but probably a new question is needed. –  Mar 23 '22 at 10:58
  • 1
    @LaccaseTVersicolor Thanks for your comment, if you open a new question, kindly share the link to me (anyhow, I'm looking this cite continuously...) – MadyYuvi Mar 23 '22 at 11:04