flowfram 包 - 平衡 3 列并将 columnsep 行延伸至文本末尾

flowfram 包 - 平衡 3 列并将 columnsep 行延伸至文本末尾

问题:最近问了一个问题关于将 2 列摘要和标题放在 3 列文档中,约翰·科米洛提供了一个按预期工作的答案,后面还有有用的评论。将代码放入主文档时,我面临的问题是两个问题:1)\columnsep无论页面上有多少内容,线条都会完全延伸到页面下方;2) 我看不出平衡列的方法,也不知道如何让分隔线仅延伸到平衡文本的末尾。我的知识flowfram有限,我不确定这是否可行,但理想情况下,我希望我的文献综述与第二张图片相似,而不是第一张图片。

目前的情况:

在此处输入图片描述

如果可能的话,我希望平衡和线路扩展看起来如何:

在此处输入图片描述

我已尝试过:诚然,我理解得很少,flowfram尽管这个包很有用,但在某些时候我必须理解。我尝试使用这个包flushend,但阅读文档后,我发现这仅适用于双列。

MWE(由@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}

我不知道从哪里开始解决这个问题。我希望社区不介意我问这个问题,因为我flushend不了解flowfram软件包,所以我没有尝试过不涉及简单软件包的严肃解决方案。

编辑1:阅读flowfram包裹后注释文献第 180-181 页, 看起来

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

可以使用可选参数进行修改,以将垂直线延伸到负方向,例如

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

现在给出:

在此处输入图片描述

如果需要的话可以手动完成,但要修改我的问题:1)有没有办法让 LaTeX 检测文本在页面上的位置,而不必手动猜测距离(-18.3cm 等)以及 2)有没有办法平衡其中的三列flowfram

答案1

由于必须在读取辅助文件之前设置 flowfram,因此这会写入一个FFsetup.tex先前读取的类似文件。它定义了宏\lastpage\lastheight

该宏处理页面数量 \firstFFsetup突然比以前少的情况。 处理页数与以前相同的情况。处理现在有更多文本的情况(自动转到溢出页面)。\secondFFsetupe\extraFFsetup

\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}

相关内容