我正在制作一个两列的文档,但我需要一个单列的摘要。代码:
\twocolumn[
\begin{@twocolumnfalse}
\maketitle
\begin{abstract}
...
\end{abstract}
\end{@twocolumnfalse}
]
不起作用,因为摘要足够长,需要两页,而且页面不会中断。我还尝试制作单列文档,并仅对文档“文本”(不是摘要)使用多列环境,但后来我在图形环境中遇到了问题。
那么,我怎样才能制作单列摘要呢?
答案1
您可以将以下代码复制为文件long2.sty
,将其放在您的文档文件夹中,然后按如下所示使用它:
%%
%% This is file `long2.sty'.
%%
%% Author: Tomas "tohecz" Hejda <[email protected]>
%%
%% Licenced under LaTeX-Project Public License version 1.3 or newer.
%%
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{long2}[2012/08/19 v0.1 long2: breakable one-column preamble in a two-column document]
\newlength\longtwo@top
\newlength\longtwo@bottom
\newsavebox\longtwo@box
\def\longtwo@repeat{%
\longtwo@column[{\@twocolumnfalse
\ifdim\ht\longtwo@box>1.00\textheight%1
\begingroup
\vbadness10000
\setbox0\vsplit\longtwo@box to 1.00\textheight%1
\setbox1\vbox{\unvbox\longtwo@box}
\global\setbox\longtwo@box\vbox{\unvbox1}
\setbox2\vbox to \textheight{%
\unvbox0
}
\ht2=0.9\textheight
\box2
\endgroup
\else
\ifdim\ht\longtwo@box>0.84\textheight
\global\let\longtwo@repeat\clearpage
\else
\global\let\longtwo@repeat\relax
\fi
\unvbox\longtwo@box
\vspace{15pt plus 15pt}
\fi
}]%
\longtwo@repeat
}
\long\def\longtwo@[#1]{%
\begingroup
\let\longtwo@column\twocolumn
\let\longtwo@mkttl\maketitle
\def\maketitle{
\begingroup
\let\newpage\relax
\longtwo@mkttl
\endgroup
}
\longtwo@column[{\@twocolumnfalse
\global\setbox\longtwo@box\vbox{#1}%
\ifdim\ht\longtwo@box>\textheight
\begingroup
\vbadness10000
\setbox0\vsplit\longtwo@box to 1.00\textheight%1
\setbox1\vbox{\unvbox\longtwo@box}%
\global\setbox\longtwo@box\vbox{\unvbox1}%
\setbox2\vbox to \textheight{%
\unvbox0
}
\ht2=0.9\textheight
\box2
\endgroup
\else
\ifdim\ht\longtwo@box>0.87\textheight
\global\let\longtwo@repeat\clearpage
\else
\global\let\longtwo@repeat\relax
\fi
\unvbox\longtwo@box
\fi
}]%
\longtwo@repeat
\endgroup
}
\def\longtwocolumn{\@ifnextchar[\longtwo@\twocolumn}
\endinput
%%
%% End of file `long2.sty'.
%%
然后文档看起来像这样(包lipsum
和命令\lipsum[x-y]
仅用于生成一些虚拟文本):
\documentclass[twocolumn]{article}
\usepackage{long2}
\usepackage{lipsum}
\parskip0pt plus 8pt
\title{My title}
\author{My the first}
\begin{document}
\longtwocolumn[{
\maketitle
\begin{abstract}
\lipsum[1-8]
\end{abstract}
\lipsum[9-15]
}]
\lipsum[16-25]
\end{document}
PS:我正在考虑将其制作成一个包(在我添加一些功能之后),这就是为什么我发布了一个完整的包文件;)
PPS:简单介绍一下思路:我们将整个一列部分存储在一个盒子里,然后检查盒子是否大于一页。如果是,则\vsplit
输出第一部分,然后调用\longtwo@repeat
其余部分,重复上述操作。
答案2
新的解决方案,用于\afterpage
在分页符后插入双列开关,将摘要的末尾与其可选参数对接。
\documentclass{article}
\usepackage{afterpage}
\let\xaddboxcontents\addboxcontents
\def\zzz#1\end#2{\end{abstract}\twocolumn[\unvbox\csname AP@partial\endcsname\par\small\quotation#1\endquotation]}
\def\addboxcontents#1{\aftergroup\zzz}
\author{me}
\date{today}
\title{test}
\def\b{abstract stuff }\def\c{\b\b\b. }\def\d{One \c. Two three \c. Four five six\c\c.\par}\def\e{\d\d\d\d\d}
\begin{document}
\maketitle
\afterpage{\clearpage}
\begin{abstract}
\e\e\e\e
\end{abstract}
\def\b{main body text }
\e\e\e\e\e
\end{document}
原始(更简单!)解决方案:
将标题和摘要切换为一列,然后再切换回两列
\documentclass{article}
\author{me}
\date{today}
\title{test}
\def\b{abstract stuff }\def\c{\b\b\b. }\def\d{One \c. Two three \c. Four five six\c\c.\par}\def\e{\d\d\d\d\d}
\begin{document}
\maketitle
\begin{abstract}
\e\e\e\e
\end{abstract}
\twocolumn
\def\b{main body text }
\e\e\e\e\e
\end{document}