| 1 |
% \iffalse^^A meta-comment |
| 2 |
% ====================================================================== |
| 3 |
% longtwocolumn.dtx |
| 4 |
% Copyright (c) Markus Kohm, 2021–2025 |
| 5 |
% |
| 6 |
% This file is part of the LaTeX2e package `longtwocolumn'. |
| 7 |
% |
| 8 |
% This work may be distributed and/or modified under the conditions of |
| 9 |
% the LaTeX Project Public License, version 1.3c of the license. |
| 10 |
% The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 and of this work. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status "author-maintained". |
| 16 |
% |
| 17 |
% The Current Maintainer and author of this work is Markus Kohm. |
| 18 |
% |
| 19 |
% This work consists of the files `longtwocolumn.dtx' and |
| 20 |
% `README.md'. |
| 21 |
% ====================================================================== |
| 22 |
% |
| 23 |
%\changes{v0.3}{2025-01-07}{needs at least \LaTeX{} 2020-10-01} |
| 24 |
%<identify>\NeedsTeXFormat{LaTeX2e}[2020/10/01] |
| 25 |
%<*dtx> |
| 26 |
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi |
| 27 |
\ProvidesFile{longtwocolumn.dtx} |
| 28 |
%</dtx> |
| 29 |
%<package&identify>\ProvidesPackage{longtwocolumn} |
| 30 |
%<*dtx|(package&identify)> |
| 31 |
[2025-07-21 v0.1 |
| 32 |
%</dtx|(package&identify)> |
| 33 |
%<*dtx> |
| 34 |
source of package scrlayer-scrpage] |
| 35 |
%</dtx> |
| 36 |
%<*package> |
| 37 |
%<identify> combining fancyhdr with KOMA-Script's scrlayer] |
| 38 |
%</package> |
| 39 |
%<*dtx> |
| 40 |
\ifx\documentclass\undefined |
| 41 |
\input docstrip.tex |
| 42 |
\generate{% |
| 43 |
\file{longtwocolumn.sty}{% |
| 44 |
\from{longtwocolumn.dtx}{package}% |
| 45 |
}% |
| 46 |
\file{longtwocolumn-example.tex}{% |
| 47 |
\from{longtwocolumn.dtx}{example}% |
| 48 |
}% |
| 49 |
} |
| 50 |
\else |
| 51 |
\let\endbatchfile\relax |
| 52 |
\fi |
| 53 |
\endbatchfile |
| 54 |
\documentclass{koma-script-source-doc}% KOMA-Script related packages use this. |
| 55 |
\usepackage[english]{babel} |
| 56 |
\usepackage{graphicx} |
| 57 |
\setcounter{StandardModuleDepth}{2} |
| 58 |
\GetFileInfo{longtwocolumn.dtx} |
| 59 |
\begin{document} |
| 60 |
\DocInput{longtwocolumn.dtx} |
| 61 |
\end{document} |
| 62 |
%</dtx> |
| 63 |
%\fi |
| 64 |
% |
| 65 |
% \changes{v0.1}{2025-06-30}{forum answer converted into package} |
| 66 |
% \changes{v0.1}{2025-07-21}{color support added} |
| 67 |
% |
| 68 |
% \GetFileInfo{longtwocolumn.dtx} |
| 69 |
% \title{The \pkg*{longtwocolumn} Package} |
| 70 |
% \author{\href{mailto:[email protected]}{Markus Kohm}\thanks{Repository and |
| 71 |
% bug reports: |
| 72 |
% \url{https://gitlab.com/latex9343737/packages/longtwocolumn}}} |
| 73 |
% \date{Version \filedate{} \fileversion} |
| 74 |
% \maketitle |
| 75 |
% \begin{abstract} |
| 76 |
% Package \pkg*{longtwocolumn} provides \cs{longtwocolumn} as variant of |
| 77 |
% \LaTeX's \cs{twocolumn} that allowes the optional argument to span several |
| 78 |
% pages on one column. |
| 79 |
% \end{abstract} |
| 80 |
% |
| 81 |
% \tableofcontents |
| 82 |
% |
| 83 |
% \section{How to use \pkg*{longtwocolumn}?} |
| 84 |
% \label{sec:usage} |
| 85 |
% |
| 86 |
% First of all, you need to load the package, so you should add |
| 87 |
%\begin{verbatim} |
| 88 |
% \usepackage{longtwocolumn} |
| 89 |
%\end{verbatim} |
| 90 |
% somewhere in your document preamble. Theoretically you would even be able to |
| 91 |
% do a |
| 92 |
%\begin{verbatim} |
| 93 |
% \RequirePackage{longtwocolumn} |
| 94 |
%\end{verbatim} |
| 95 |
% before |\documentclass|. However users should not need to do so and |
| 96 |
% therefore it is not recommended unless you know what you are doing. |
| 97 |
% |
| 98 |
% Now you can use \cs{longtwocolumn}\oarg{single column content}. The command |
| 99 |
% works similar to \LaTeX's \cs{twocolumn}, but if the \meta{single column |
| 100 |
% content} is higher than one page, it is automatically split to several |
| 101 |
% pages. Note, that currently \cs{newpage} or \cs{clearpage} inside |
| 102 |
% \meta{single column content} is not supported. In my opinion such a support |
| 103 |
% is not needed, because each \cs{longtwocolumn} starts a new page, so instead |
| 104 |
% of adding \cs{newpage} inside the optional argument of \cs{longtwocolumn} |
| 105 |
% you simply can use several \cs{longtwocolumn}. |
| 106 |
% |
| 107 |
% \begin{description} |
| 108 |
% \item[\textbf{Note:}] This is an early experimental package. So it may fail |
| 109 |
% in all cases except the one shown in the example. |
| 110 |
% \end{description} |
| 111 |
% |
| 112 |
% \section{Example} |
| 113 |
% \label{sec:example} |
| 114 |
% |
| 115 |
% \iffalse |
| 116 |
%<*example> |
| 117 |
% \fi |
| 118 |
% |
| 119 |
% Often \cs{longtwocolumn} is used for title + abstract in a two column |
| 120 |
% document, if the abstract needs more than one page: |
| 121 |
% \begin{macrocode} |
| 122 |
\documentclass[twocolumn,abstract]{scrartcl} |
| 123 |
\usepackage{longtwocolumn} |
| 124 |
\usepackage{lipsum} |
| 125 |
\begin{document} |
| 126 |
|
| 127 |
\title{Long One Column Abstract with Two Column Document} |
| 128 |
\author{Markus Kohm} |
| 129 |
|
| 130 |
\longtwocolumn[{ |
| 131 |
\maketitle |
| 132 |
\begin{abstract} |
| 133 |
\lipsum[1-8] |
| 134 |
\end{abstract} |
| 135 |
\vskip\baselineskip |
| 136 |
}] |
| 137 |
\section{Here we go} |
| 138 |
\lipsum[1-7] |
| 139 |
\end{document} |
| 140 |
% \end{macrocode} |
| 141 |
% Results in: |
| 142 |
% \begin{center} |
| 143 |
% \fbox{\includegraphics[page=1,width=.3\textwidth]{longtwocolumn-example.pdf}}% |
| 144 |
% \fbox{\includegraphics[page=2,width=.3\textwidth]{longtwocolumn-example.pdf}}% |
| 145 |
% \fbox{\includegraphics[page=3,width=.3\textwidth]{longtwocolumn-example.pdf}} |
| 146 |
% \end{center} |
| 147 |
% It results also in the warning message: |
| 148 |
%\begin{verbatim} |
| 149 |
% Package longtwocolumn Warning: \clearpage inside optional argument of |
| 150 |
% (longtwocolumn) \longtwocolumn ignored on input line 37. |
| 151 |
%\end{verbatim} |
| 152 |
% because the \cs{maketitle} in the optional argument of \cs{longtwocolumn} |
| 153 |
% runs \cs{clearpage} at the very beginning. But in this case this is not |
| 154 |
% really a problem, because \cs{longtwocolumn} runs \cs{onecolumn} at the very |
| 155 |
% beginning and this also runs \cs{clearpage}. |
| 156 |
% |
| 157 |
% \iffalse |
| 158 |
%</example> |
| 159 |
% \fi |
| 160 |
% |
| 161 |
% \MaybeStop{}^^A\PrintIndex} |
| 162 |
% |
| 163 |
% \section{Implementation} |
| 164 |
% \label{implementation} |
| 165 |
% |
| 166 |
% \iffalse |
| 167 |
%<*package> |
| 168 |
% \fi |
| 169 |
% \begin{command}{\longtwocolumn} |
| 170 |
% |
| 171 |
% \begin{macro}{\longtwocolumn@box} |
| 172 |
% Internal box register used by \cs{longtwocolumn}. |
| 173 |
% \begin{macrocode} |
| 174 |
\newsavebox\longtwocolumn@box |
| 175 |
% \end{macrocode} |
| 176 |
% \end{macro} |
| 177 |
% \begin{macrocode} |
| 178 |
\NewDocumentCommand{\longtwocolumn}{+o}{% |
| 179 |
\IfValueTF{#1}{% |
| 180 |
% \end{macrocode} |
| 181 |
% Switch to one column, because everything, which is longer than one page, |
| 182 |
% should be output in one column mode. |
| 183 |
% \begin{macrocode} |
| 184 |
\onecolumn |
| 185 |
% \end{macrocode} |
| 186 |
% We start a new group to allow local changes, e.g., of \cs{clearpage} and |
| 187 |
% \cs{newpage}, while we collect the content. |
| 188 |
% \begin{macrocode} |
| 189 |
\begingroup |
| 190 |
\renewcommand*{\cleardoublepage}{% |
| 191 |
\PackageWarning{longtwocolumn}{\string\cleardoublepage\space inside |
| 192 |
optional argument of\MessageBreak \string\longtwocolumn\space |
| 193 |
ignored}% |
| 194 |
}% |
| 195 |
\renewcommand*{\clearpage}{% |
| 196 |
\PackageWarning{longtwocolumn}{\string\clearpage\space inside optional |
| 197 |
argument of\MessageBreak \string\longtwocolumn\space ignored}% |
| 198 |
}% |
| 199 |
\renewcommand*{\newpage}{% |
| 200 |
\PackageWarning{longtwocolumn}{\string\newpage\space inside optional |
| 201 |
argument of\MessageBreak \string\longtwocolumn\space ignored}% |
| 202 |
} |
| 203 |
\global\setbox\longtwocolumn@box\color@vbox |
| 204 |
\normalcolor |
| 205 |
\@parboxrestore |
| 206 |
#1% |
| 207 |
\par |
| 208 |
\color@endbox |
| 209 |
\endgroup |
| 210 |
% \end{macrocode} |
| 211 |
% Now we can split the box using the same parameters that would be used for |
| 212 |
% normal page splitting. |
| 213 |
% \begin{macrocode} |
| 214 |
%<*trace> |
| 215 |
\typeout{^^J% |
| 216 |
TRACE: Initial height=\the\ht\longtwocolumn@box, |
| 217 |
depth=\the\dp\longtwocolumn@box}% |
| 218 |
%</trace> |
| 219 |
\@whiledim \textheight<\ht\longtwocolumn@box\do {% |
| 220 |
%<*trace> |
| 221 |
\typeout{TRACE: Split of \the\textheight\space from |
| 222 |
\the\ht\longtwocolumn@box}% |
| 223 |
%</trace> |
| 224 |
\splittopskip\topskip |
| 225 |
\splitmaxdepth\maxdepth |
| 226 |
\vsplit\longtwocolumn@box to \textheight\clearpage |
| 227 |
}% |
| 228 |
%<*trace> |
| 229 |
\typeout{TRACE: Final height=\the\ht\longtwocolumn@box, |
| 230 |
depth=\the\dp\longtwocolumn@box}% |
| 231 |
%</trace> |
| 232 |
% \end{macrocode} |
| 233 |
% Before we run \cs{twocolumn} to output the last part of the box, we need to |
| 234 |
% deactivate the \cs{normalcolor} at the beginning of |
| 235 |
% \cs{@topnewpage} to avoid resetting the color. |
| 236 |
% \begin{macrocode} |
| 237 |
\let\longtwocolumn@normalcolor\normalcolor |
| 238 |
\def\normalcolor{\let\normalcolor\longtwocolumn@normalcolor}% |
| 239 |
\twocolumn[\unvbox\longtwocolumn@box]% |
| 240 |
\let\normalcolor\longtwocolumn@normalcolor |
| 241 |
}{\twocolumn}% |
| 242 |
} |
| 243 |
% \end{macrocode} |
| 244 |
% \end{command} |
| 245 |
% |
| 246 |
% \iffalse |
| 247 |
%</package> |
| 248 |
% \fi |
| 249 |
% |
| 250 |
% \Finale |
| 251 |
% \PrintChanges |
| 252 |
% |
| 253 |
% \endinput |
| 254 |
% Local Variables: |
| 255 |
% mode: doctex |
| 256 |
% ispell-local-dictionary: "en_US" |
| 257 |
% eval: (flyspell-mode 1) |
| 258 |
% TeX-master: t |
| 259 |
% End: |