summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tudscr/source/tudscr-twocolfix.dtx
blob: a5897f38d5a81350820c9b329c122c1e75335135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
% \iffalse meta-comment
%/GitFileInfo=tudscr-twocolfix.dtx
%
%  TUD-Script -- Corporate Design of Technische Universität Dresden
% ----------------------------------------------------------------------------
%
%  Copyright (C) Falk Hanisch <hanisch.latex@outlook.com>, 2012-2022
%
% ----------------------------------------------------------------------------
%
%  This work may be distributed and/or modified under the conditions of the
%  LaTeX Project Public License, either version 1.3c of this license or
%  any later version. The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
%  and version 1.3c or later is part of all distributions of
%  LaTeX version 2008-05-04 or later.
%
%  This work has the LPPL maintenance status "maintained".
%
%  The current maintainer and author of this work is Falk Hanisch.
%
% ----------------------------------------------------------------------------
%
% \fi
%
% \iffalse ins:batch + dtx:driver
%<*ins>
\ifx\documentclass\undefined
  \input docstrip.tex
  \ifToplevel{\batchinput{tudscr.ins}}
\else
  \let\endbatchfile\relax
\fi
\endbatchfile
%</ins>
%<*dtx>
\ProvidesFile{tudscr-twocolfix.dtx}[2022/08/09]
\RequirePackage{tudscr-gitinfo}
\documentclass[english,ngerman,xindy]{tudscrdoc}
\iftutex
  \usepackage{fontspec}
\else
  \usepackage[T1]{fontenc}
  \usepackage[ngerman=ngerman-x-latest]{hyphsubst}
\fi
\usepackage{babel}
\usepackage{tudscrfonts}
\usepackage[babel]{microtype}

\GitHubBase{\TUDScriptRepository}
\begin{document}
  \author{Falk Hanisch\TUDScriptContactTitle}
  \maketitle
  \tableofcontents
  \DocInput{\filename}
\end{document}
%</dtx>
% \fi
%
% \selectlanguage{ngerman}
%
% \changes{v2.05}{2016/04/25}{Überprüfen der Definition von \cs{@topnewpage}
%   des \LaTeXe"~Kernels}^^A
%
% \ToDo{Als eingenständiges Paket herauslösen}[v2.08]
% \ToDo{CheckCommand verwenden?}[v2.08]
%
%
%
% \section{Das Paket \pkg{twocolfix} -- Bugfix für den zweispaltigen Satz}
%
% Der \LaTeXe"~Kernel enthält einen
% \href{http://latex-project.org/cgi-bin/ltxbugs2html?pr=latex/3126}{Fehler},
% wodurch im zweispaltigen Satz Kapitelüberschriften höher als im 
% einspaltigen Layout gesetzt werden. Zwar ist dieser schon länger bekannt, 
% jedoch bisher noch nicht behoben (\GitHubRepo(latex3/latex2e)<509>).
%
% Das Paket \pkg{twocolfix} soll dies beheben. Eine Integration des Bugfixes 
% in \KOMAScript{} wurde bereits bei Markus Kohm angefragt, jedoch
% \href{http://www.komascript.de/node/1681}{von ihm nicht weiter verfolgt}.
%
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{twocolfix}[%
%!TUD@Version
  package (twocolumn layout bugfix)%
]
%</package>
%    \end{macrocode}
%
% \iffalse
%<*package>
% \fi
%
% Es wird der fehlerhafte Befehl aus dem \LaTeXe"~Kernel neu definiert. 
% Allerdings definieren die \KOMAScript-Klassen das Makro \cs{@topnewpage} 
% um und sichern vorher das Original in \cs{scr@topnewpage}. Daher wird der 
% neue Befehl erst temporär definiert. 
%    \begin{macrocode}
\long\def \@tempa [#1]{%
  \@nodocument%
  \@next\@currbox\@freelist{}{}%
  \global \setbox\@currbox%
    \vbox {%
      \break%
      \prevdepth\z@%
      \begingroup%
      \normalcolor%
      \hsize\textwidth%
%    \end{macrocode}
% Damit der Inhalt des optionale Argumentes mit den gleichen Absatzeinstellungen
% gesetzt wird, werden diese nach \cs{@parboxrestore} für \KOMAScript-Klassen
% wiederhergestellt.
%    \begin{macrocode}
      \@parboxrestore%
      \ifcsname KOMAClassName\endcsname%
        \KOMAoptionOf[\KOMAoption{parskip}]{\KOMAClassFileName}{parskip}%
      \fi%
      \col@number \@ne%
      \ignorespaces #1\par%
      \ifdim\parskip>\z@\null\fi%
      \vskip -\dbltextfloatsep%
      \endgroup%
      \ifdim\parskip>\z@\vskip\parskip\else\null\fi%
      \vskip -\topskip%
  }%
  \begingroup%
    \splitmaxdepth\maxdepth \splittopskip\topskip%
    \setbox\@tempboxa \vsplit\@currbox to\z@%
  \endgroup%
  \ifdim \ht\@currbox>\textheight%
    \ht\@currbox \textheight%
  \fi%
  \global \count\@currbox \tw@%
  \@tempdima -\ht\@currbox%
  \advance \@tempdima -\dbltextfloatsep%
  \global \advance \@colht \@tempdima%
  \ifx \@dbltoplist \@empty%
  \else%
    \@latexerr{Float(s) lost}\@ehb%
    \let \@dbltoplist \@empty%
  \fi%
  \@cons \@dbltoplist \@currbox%
  \global \@dbltopnum \m@ne%
  \ifdim \@colht<2.5\baselineskip%
    \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
                too tall on page \thepage}%
    \@emptycol%
    \if@firstcolumn%
    \else%
      \@emptycol%
    \fi%
  \else%
    \global \vsize \@colht%
    \global \@colroom \@colht%
    \@floatplacement%
  \fi%
}
%    \end{macrocode}
% Um eine Änderung am \LaTeXe-Kernel feststellen zu können, wird auf die zum
% Zeitpunkt des Paketes aktuelle Definition von \cs{@topnewpage} geprüft.
%    \begin{macrocode}
\long\def\@tempb[#1]{%
  \@nodocument
  \@next\@currbox\@freelist{}{}%
  \global \setbox\@currbox
    \color@vbox
      \normalcolor
      \vbox {%
        \hsize\textwidth
        \@parboxrestore
        \col@number \@ne
        #1%
        \vskip -\dbltextfloatsep
      }%
    \color@endbox
  \ifdim \ht\@currbox>\textheight
    \ht\@currbox \textheight
  \fi
  \global \count\@currbox \tw@
  \@tempdima -\ht\@currbox
  \advance \@tempdima -\dbltextfloatsep
  \global \advance \@colht \@tempdima
  \ifx \@dbltoplist \@empty
  \else
    \@latexerr{Float(s) lost}\@ehb
    \let \@dbltoplist \@empty
  \fi
  \@cons \@dbltoplist \@currbox
  \global \@dbltopnum \m@ne
  \ifdim \@colht<2.5\baselineskip
    \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
                        too tall on page \thepage}%
    \@emptycol
    \if@firstcolumn
    \else
      \@emptycol
    \fi
  \else
    \global \vsize \@colht
    \global \@colroom \@colht
    \@floatplacement
  \fi
}
%    \end{macrocode}
% \begin{macro}{\@topnewpage}
% \begin{macro}{\scr@topnewpage}
% Nachdem der neue Befehl sowie die Definition aus dem \LaTeXe-Kernel zuerst 
% temporär definiert wurden, wird nun abhängig von der aktiven Klasse der
% notwendige Befehl mit der neuen Definition überschrieben.
%    \begin{macrocode}
\ifx\scr@topnewpage\@undefined
  \@check@eq\@topnewpage\@tempb%
  \let\@topnewpage\@tempa%
\else
  \@check@eq\scr@topnewpage\@tempb%
  \let\scr@topnewpage\@tempa%
\fi
%    \end{macrocode}
% \end{macro}^^A \scr@topnewpage
% \end{macro}^^A \@topnewpage
%
% \iffalse
%</package>
% \fi
%
% \PrintBackMatter
%
\endinput