Debian Codegraph @

texmf-dist/source/latex/ncctools/textarea.dtx

raw
1 % \iffalse
2 %%
3 %% File: textarea.dtx Copyright (C) 2005 by Alexander I. Rozhenko
4 %%
5 %<package>\NeedsTeXFormat{LaTeX2e}
6 %<package>\ProvidesPackage{textarea}
7 %<package> [2005/12/26 v1.0 Text area control (NCC)]
8 %
9 % \changes{v1.0}{2005/12/26}{Initial version}
10 %
11 %<*driver>
12 \let\makeindex\relax
13 \documentclass{ltxdoc}
14 \usepackage{textarea}
15 \GetFileInfo{textarea.sty}
16 \begin{document}
17 \title{The \textsf{textarea} package\thanks{This file
18 has version number \fileversion, last
19 revised \filedate.}}
20 \author{Alexander I. Rozhenko\\[email protected]}
21 \date{\filedate}
22 \maketitle
23 \DocInput{textarea.dtx}
24 \end{document}
25 %</driver>
26 % \fi
27 %
28 % The package allows expand the text area of a document on other
29 % areas: footer, header, and margin. There are two ways for such
30 % expansion --- temporary expansion of a current page on the header using
31 % a special negative vertical skip, or global change of page layout
32 % parameters with possibility of later restoration them to the original
33 % values. All these actions should be applied at the beginning of page.
34 %
35 % \section{User Interface}
36 %
37 % \DescribeMacro\StartFromTextArea
38 % Applied at the beginning of page, it allows using the non-starred
39 % form of the |\vspace| command after it. The introduced command provides
40 % exact vertical skips at the beginning of page. Unlike it, the standard
41 % \LaTeX's |\vspace*| command skips more space at the beginning of page
42 % than it is required in its parameter. So, using the
43 % |\StartFromTextArea| command prevents
44 % incorrect spacing at the beginning of page.
45 %
46 % \DescribeMacro\StartFromHeaderArea
47 % Applied at the beginning of page, it adjusts the beginning of text area
48 % to the header area by inserting a negative vertical skip. The header
49 % of this page should be empty. Otherwise, the consequent text will
50 % overprint the header.
51 %
52 % \DescribeMacro{\ExpandTextArea\oarg{hfm}}
53 % Expands the text area on other areas of page by changing page layout
54 % parameters. It can be used in one-column mode only.
55 % The letters in optional argument mean the following: |h| (header),
56 % |f| (footer), and |m| (margins). If an optional argument is omitted
57 % or equals to |[*]|, the temporary expansion to the header is applied
58 % with the |\StartFromHeaderArea| command. Anyway, you can use the
59 % non-starred form of the |\vspace| command after expansion of the
60 % text area.
61 %
62 % When a text area is expanded (non-temporary), the repeated call of
63 % this command is disallowed.
64 %
65 % \DescribeMacro\RestoreTextArea
66 % Restores page layout parameters to their previous values. After that,
67 % the |\ExpandTextArea| command can be applied again.
68 %
69 % \DescribeMacro\NCC@restoretextarea
70 % This hook can be used to provide an automatic restoration of the text
71 % area. In \textbf{ncc} class, we use it as follows: set it empty at
72 % the beginning of |titlepage| environment and call this command at
73 % the end of |titlepage| environment. So, if the text area will be
74 % expanded within the |titlepage| environment, it will be automatically
75 % restored at the end of it.
76 %
77 % \StopEventually{}
78 %
79 % \section{The Implementation}
80 %
81 % \begin{macro}{\StartFromTextArea}
82 % \begin{macro}{\StartFromHeaderArea}
83 % Both these commands are defined in two packages: in this and in
84 % \textbf{nccsect}. To be sure that the commands are specified
85 % in these packages only, we mutually test packages to be loaded.
86 % \begin{macrocode}
87 %<*package>
88 \@ifpackageloaded{nccsect}{}{%
89 \newcommand\StartFromTextArea{\par
90 {\parskip\z@ \strut\par}\vskip -\baselineskip
91 }
92 \newcommand\StartFromHeaderArea{%
93 \StartFromTextArea
94 \vskip -\headsep \vskip -\ht\strutbox
95 }
96 }
97 % \end{macrocode}
98 % \end{macro}
99 % \end{macro}
100 %
101 % \begin{macro}{\RestoreTextArea}
102 % This command is usually empty. But it is globally redefined
103 % when the layout of page is modified by the |\ExpandTextArea|
104 % command.
105 % \begin{macrocode}
106 \newcommand*\RestoreTextArea{}
107 % \end{macrocode}
108 % \end{macro}
109 %
110 % \begin{macro}{\ExpandTextArea}
111 % This command should be applied at the beginning of page
112 % in one-column mode only.
113 % \begin{macrocode}
114 \newcommand*\ExpandTextArea[1][*]{%
115 \if@twocolumn
116 \PackageError{textarea}%
117 {The \string\ExpandTextArea\space command\MessageBreak
118 cannot work in two-column mode}{}%
119 % \end{macrocode}
120 % Test for temporary expansion mode and do it.
121 % \begin{macrocode}
122 \else
123 \def\@tempa{*}\edef\@tempb{#1}%
124 \ifx\@tempa\@tempb
125 \StartFromHeaderArea
126 % \end{macrocode}
127 % Otherwise, apply the permanent expansion but in the only case if
128 % it was not already applied.
129 % \begin{macrocode}
130 \else
131 \ifx\RestoreTextArea\@empty
132 % \end{macrocode}
133 % |\NCC@|\meta{x} hooks will be applied right here to modify the layout and
134 % |\NCC@resore@|\meta{x} hooks will applied later when the original layout
135 % will be restored.
136 % \begin{macrocode}
137 \let\NCC@h\@empty \global\let\NCC@restore@h\@empty
138 \let\NCC@f\@empty \global\let\NCC@restore@f\@empty
139 \let\NCC@m\@empty \global\let\NCC@restore@m\@empty
140 % \end{macrocode}
141 % Analyze letters in the optional parameter and prepare the respective hooks.
142 % The first parameter in all adjustment commands is a sign of adjustment:
143 % the empty value means adjust and the minus sign means restore.
144 % \begin{macrocode}
145 \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=#1\do{%
146 \if h\@tempa
147 \def\NCC@h{\NCC@adjusttoheader{}}%
148 \gdef\NCC@restore@h{\NCC@adjusttoheader-}%
149 \else
150 \if f\@tempa
151 \def\NCC@f{\NCC@adjusttofooter{}}%
152 \gdef\NCC@restore@f{\NCC@adjusttofooter-}%
153 \else
154 \if m\@tempa
155 \if@reversemargin \@tempcnta\@ne \else \@tempcnta\tw@ \fi
156 \edef\NCC@m{\noexpand\NCC@adjusttomargin{}{\the\@tempcnta}}%
157 \xdef\NCC@restore@m{\noexpand\NCC@adjusttomargin-{\the\@tempcnta}}%
158 \fi
159 \fi
160 \fi
161 }%
162 % \end{macrocode}
163 % Modify the layout, apply the |\StartFromTextArea| command, and prepare
164 % the |\RestoreTextArea| command and the auto-restoration hook.
165 % \begin{macrocode}
166 \NCC@h\NCC@f\NCC@m
167 \StartFromTextArea
168 \gdef\RestoreTextArea{%
169 \NCC@restore@h\NCC@restore@f\NCC@restore@m
170 \global\let\RestoreTextArea\@empty
171 }%
172 \def\NCC@restoretextarea{\RestoreTextArea}%
173 \fi
174 \fi
175 \fi
176 }
177 % \end{macrocode}
178 % \end{macro}
179 %
180 % \begin{macro}{\NCC@adjusttoheader}
181 % Adjust text height parameters and |\topmargin|.
182 % \begin{macrocode}
183 \def\NCC@adjusttoheader#1{%
184 \@tempdima #1\headheight
185 \advance\@tempdima #1\headsep
186 \global\advance\textheight\@tempdima
187 \global\advance\topmargin-\@tempdima
188 \global\@colht\textheight
189 \global\@colroom\textheight
190 \global\vsize\textheight
191 }
192 % \end{macrocode}
193 % \end{macro}
194 %
195 % \begin{macro}{\NCC@adjusttofooter}
196 % Adjust text height parameters.
197 % \begin{macrocode}
198 \def\NCC@adjusttofooter#1{%
199 \global\advance\textheight#1\footskip
200 \global\@colht\textheight
201 \global\@colroom\textheight
202 \global\vsize\textheight
203 }
204 % \end{macrocode}
205 % \end{macro}
206 %
207 % \begin{macro}{\NCC@adjusttomargin}
208 % Adjust text width parameters, |\oddsidemargin| or
209 % |\evensidemargin|. The second parameter specifies
210 % the mode of marginal notes: reverse (1) or normal (2) margins.
211 % \begin{macrocode}
212 \def\NCC@adjusttomargin#1#2{%
213 \@tempdima #1\marginparwidth
214 \advance\@tempdima #1\marginparsep
215 \@tempcnta#2%
216 \ifodd\@tempcnta
217 \global\advance\oddsidemargin -\@tempdima
218 \else
219 \global\advance\evensidemargin -\@tempdima
220 \fi
221 \global\advance\textwidth\@tempdima
222 \global\columnwidth\textwidth
223 \global\linewidth\textwidth
224 \global\hsize\textwidth
225 }
226 % \end{macrocode}
227 % \end{macro}
228 %
229 % \begin{macro}{\NCC@restoretextarea}
230 % Text area auto-restoration hook.
231 % \begin{macrocode}
232 \let\NCC@restoretextarea\@empty
233 %</package>
234 % \end{macrocode}
235 % \end{macro}
236 \endinput