summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmeometric/gmeometric.sty
blob: e2b71576076054b9842e6c53e4a743f6a86a2707 (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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
%
% \GetFileInfo{gmeometric.sty}
% \title{The \pk{gmeometric} Package\thfileinfo}
% \author{Grzegorz Murzynowski}
% \maketitle
%
%
% \begin{copyrnote}
%
%%   Written by Grzegorz Murzynowski,
%%   natror at o2 dot pl
%%
%% \copyright\,2006, 2007, 2008 by Grzegorz Murzynowski.
%%
%% This program is subject to the \LaTeX\ Project Public License.
%% See
%% \url{http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html}
%% for the details of that license.
%%
%% LPPL status: "author-maintained".\par
%
%\end{copyrnote}
%
% \CheckSum{61}
% \chschange{v0.69}{2007/4/26}{40}
% \chschange{v0.70}{2007/4/29}{36}
% \chschange{v0.71}{2007/11/16}{41}
% \chschange{v0.72}{2007/11/17}{239}
% \chschange{v0.73}{2008/11/22}{237}
% \toCTAN{v0.73}{2008/11/22}
%
% 
% \skiplines we skip the driver
\ifnum\catcode`\@=12
\documentclass[codespacesgrey, noindex, pagella, fontspec=quiet]{gmdocc}
\twocoltoc
\begin{document}
\GetFileInfo{\jobname.sty}
\DocInput{\jobname.sty}

\PrintChanges
\thispagestyle{empty}

\typeout{%
  Produce change log with^^J%
  makeindex -r -s gmglo.ist -o \jobname.gls \jobname.glo^^J
  (gmglo.ist should be put into some texmf/makeindex directory.)^^J}

\afterfi{\end{document}
% The package is too small to make index of it.
%^^A\typeout{%
%^^A  Produce index with^^J%
%^^A  makeindex -r \jobname^^J}
}
\fi % of driver pass
% \endskiplines
%% \FileInfo

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmeometric}
     [2008/11/22 v0.73 to allow the `geometry' macro in the document (GM)]

%
%% \division{Introduction, usage}
%%
%% This package allows you to use the |\geometry| macro, provided by
%% the \pk{geometry} v3.2 and v4.1 by Hideo Umeki, anywhere in a~document:
%% originally it's claused |\@onlypreamble| and the main work of
%% \pk{gmeometric} is to change that.
%%
%% Note it's rather queer to change the page layout \emph{inside}
%% a~document and it should be considered as drugs or alcohol: it's
%% O.K.\ only if you \emph{really} know what you're doing.
%%
%% In order to work properly, the macro should launch the |\clearpage|
%% or the \cs{cleardoublepage} to `commit' the changes. So, the
%% unstarred version trigges the first while the starred the
%% latter. If that doesn't work quite as expected, try to precede or
%% succede it with |\onecolumn| or |\twocolumn|.
%%
%% It's important that |\clear(double)page| launched by |\geometry|
%% not to be a~no-op, i.e., |\clear(double)page| immediately
%% preceding |\geometry| (nothing is printed in between) discards the
%% `commitment'.
%%
%% \stanza
%% You may use \pk{gmeometric} just like \pk{geometry} i.e., to specify
%% the layout as the package options: they shall be passed to
%% \pk{geometry}.
%%
%% This package also checks if the engine is \XeTeX\ and sets the
%% proper driver if so. Probably it's redundant since decent \XeTeX\
%% packages provide their \pk{geometry.cfg} file that does that.
%%
%
% \begin{gmlonely}
%   \subdivision{Installation}
%   
%   Unpack the \file{gmeometric.tds.zip} archive in a~\file{texmf}
%   directory or put the \pk{gmeometric.sty} somewhere in the
%   \file{texmf/tex/latex} branch on your own. Creating
%   a~\file{texmf/tex/latex/gm} directory may be advisable if
%   you consider using other packages written by me.
%
%   Then you should refresh your \TeX\ distribution's files' database
%   most probably. 
% \end{gmlonely}
%
%
% \subdivision{Contents of the \pk{gmeometric.zip} archive}
%
% The distribution of the \pk{gmeometric} package consists of the
% following four files.
% \begin{verse}
%   \pk{gmeometric.sty}\\
%   \pk{README}\\
%   \pk{gmeometric.pdf}\\
%   \pk{gmeometric.tds.zip}
% \end{verse}
%
%
% \begin{gmlonely}
%   \subdivision{Compiling of the documentation}
%
%   The last of the above files (the \pk{.pdf}, i.e., \emph{this
%     file}) is a~documentation compiled from the \pk{.sty} file by
%   running \LaTeX\ (twice) on the \pk{gmeometric.sty} file 
%   (|xelatex gmeometric.sty|  in the directory you wish the
%   documentation to be in, you don't have copy the \file{.sty} file
%   there, \TeX\ will find it).
%   Compiling of the documentation requires the packages: \pk{gmdoc}
%   (\pk{gmdoc.sty} and \pk{gmdocc.cls}), \pk{gmverb.sty},
%   \pk{gmutils.sty}, \pk{gmiflink.sty} and also some standard
%   packages: \pk{hyperref.sty}, \pk{color.sty}, \pk{geometry.sty},
%   \pk{multicol.sty}, \pk{lmodern.sty}, \pk{fontenc.sty} that should
%   be installed on your computer by default.
%
%   If you have not installed the \pk{mwart.cls} class (available on
%   CTAN in \pk{mwcls} package), the result of your compilation may
%   differ a bit from the \pk{.pdf} provided in this \pk{.zip} archive
%   in formattings: If you have not installed \pk{mwart.cls}, the
%   standard \pk{article.cls} class will be used.
% \end{gmlonely}
%
%
% \division{Usage} The main use of this package is to allow the
% |\geometry| command also inside the \env{document} (originally it's
% |\@onlypreamble|). To make |\geometry| work properly is quite
% a~different business. It may be advisable to `commit' the layout
% changes with |\newpage|, |\clearpage|, or |\cleardoublepage| and
% maybe |\one/twocolumn|. 
%
% Some layout commands should be put before |\one/twocolumn| and other
% after it. An example:
%
%\begin{verbatim}
% \thispagestyle{empty}
%
% \advance\textheight 3.4cm\relax
% \onecolumn
% \newpage
%
% \advance\footskip-1.7cm
% \geometry{hmargin=1.2cm,vmargin=1cm}
% \clearpage
%\end{verbatim}
%
% And another:
%\begin{verbatim}
% \newpage
% \geometry{bottom=3.6cm}
%\end{verbatim}
%
% In some cases it doesn't work perfectly
% anyway. Well, the \acro{(LPPL)} license warns about it.
% 
% \division{The code}

\RequirePackage{gmutils}[2008/11/21]% this package defines the storing and
% restoring commands.

% Redefine |\@onlypreamble|, add storing to BeginDocument.
\newcommand*\gme@tobestored{{% this list consists of the \CS'es
    % relaxed at begin document by \pk{geometry} (the only
    % \incs{AtBeginDocument} in \pk{geometry} v4.1).
    % \changes{v0.73}{2008/11/22}{ two \CS'es added to the
    %   list for compatibility with \pk{geometry} v4.1}
    \Gm@cnth \Gm@cntv \c@Gm@tempcnt \Gm@bindingoffset \Gm@wd@mp
    \Gm@odd@mp \Gm@even@mp \Gm@orgpw \Gm@orgph \Gm@orgw \Gm@orgh
    \Gm@dimlist}}


\AtBeginDocument{\@xa\StoreMacros\gme@tobestored}
% \changes[\AtBeginDocument]{v0.73}{2008/11/22}{removed two
%   \cs{expandafter}s expanding \cs{gme@tobestored}: much less tokens
%   added to the begin-document hook}

\StoreMacro\@onlypreamble
\let\@onlypreamble\@gobble

% To make it work properly in \XeTeX:
\@ifXeTeX{%
  \@ifundefined{pdfoutput}{\newcount\pdfoutput}{}%
  \PassOptionsToPackage{dvipdfm}{geometry}%
}{}

\RequirePackageWithOptions{geometry}

% Restore |\@onlypreamble|:
\RestoreMacro\@onlypreamble

% Hypothesis: |\ifx...\@undefined| fails in the document because
% something made |\csname Gm@lines\endcsname|. So we change the test
% to decent. And i~think I've found the guilty: |\@ifundefined| in
% |\Gm@showparams|. So I~change it to the more elegant
% |\ifx\@undefined|. 
%^^A at first I~rewrote \cs{Gm@process}, let it be, maybe
%^^A one day I'll rewrite entire \pk{geometry}
%^^A \def\Gm@process{%
%^^A  \ifGm@pass
%^^A   \Gm@dorg
%^^A  \else
%^^A   \Gm@processdimlist
%^^A   \@ifundefined{Gm@hmarginratio}{%
%^^A     \if@twoside
%^^A       \edef\Gm@hmarginratio{\Gm@Dhratiotwo}%
%^^A     \else
%^^A       \edef\Gm@hmarginratio{\Gm@Dhratio}%
%^^A     \fi
%^^A   }{}%
%^^A   \@ifundefined{Gm@vmarginratio}{%
%^^A     \edef\Gm@vmarginratio{\Gm@Dvratio}%
%^^A   }%
%^^A   \Gm@checkpaper
%^^A   \ifGm@sworient
%^^A     \@tempdima=\paperwidth
%^^A     \paperwidth=\paperheight
%^^A     \paperheight=\@tempdima
%^^A     \Gm@setpaper(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
%^^A     \Gm@sworientfalse
%^^A   \fi
%^^A   \advance\paperwidth by-\Gm@bindingoffset
%^^A   \ifGm@includemp
%^^A     \Gm@mpfix
%^^A   \fi
%^^A   \ifGm@hbody
%^^A     \@ifundefined{Gm@width}{%
%^^A       \@ifundefined{Gm@hscale}{%
%^^A         \edef\Gm@width{\Gm@Dhscale\paperwidth}%
%^^A       }{%
%^^A         \edef\Gm@width{\Gm@hscale\paperwidth}%
%^^A       }%
%^^A     }%
%^^A     \@ifundefined{Gm@textwidth}{}{%
%^^A       \setlength\@tempdima{\Gm@textwidth}%
%^^A       \ifGm@includemp
%^^A         \advance\@tempdima\Gm@wd@mp
%^^A       \fi
%^^A       \edef\Gm@width{\the\@tempdima}%
%^^A     }%
%^^A   \fi
%^^A   \ifGm@vbody
%^^A     \@ifundefined{Gm@height}{%
%^^A       \@ifundefined{Gm@vscale}{%
%^^A         \edef\Gm@height{\Gm@Dvscale\paperheight}%
%^^A       }{%
%^^A         \edef\Gm@height{\Gm@vscale\paperheight}%
%^^A       }%
%^^A     }{}%
%^^A     \@ifundefined{Gm@lines}{}{%
%^^A       \@tempdima=\baselineskip
%^^A       \multiply\@tempdima\Gm@lines
%^^A       \advance\@tempdima by\topskip
%^^A       \advance\@tempdima by-\baselineskip
%^^A       \edef\Gm@textheight{\the\@tempdima}%
%^^A     }%
%^^A     \@ifundefined{Gm@textheight}{}{%
%^^A       \@tempdima=\Gm@textheight
%^^A       \ifGm@includehead
%^^A         \advance\@tempdima by\headheight
%^^A         \advance\@tempdima by\headsep
%^^A       \fi
%^^A       \ifGm@includefoot
%^^A         \addtolength\@tempdima{\footskip}%
%^^A       \fi
%^^A       \edef\Gm@height{\the\@tempdima}%
%^^A     }%
%^^A   \fi
%^^A   \Gm@detall{h}{width}{lmargin}{rmargin}%
%^^A   \Gm@detall{v}{height}{tmargin}{bmargin}%
%^^A   \setlength\textwidth{\Gm@width}%
%^^A   \setlength\textheight{\Gm@height}%
%^^A   \setlength\topmargin{\Gm@tmargin}%
%^^A   \setlength\oddsidemargin{\Gm@lmargin}%
%^^A   \addtolength\oddsidemargin{-1\Gm@truedimen in}%
%^^A   \ifGm@includemp
%^^A     \advance\textwidth-\Gm@wd@mp
%^^A     \advance\oddsidemargin\Gm@odd@mp
%^^A   \fi
%^^A   \if@mparswitch
%^^A     \setlength\evensidemargin{\Gm@rmargin}%
%^^A     \addtolength\evensidemargin{-1\Gm@truedimen in}%
%^^A     \ifGm@includemp
%^^A       \advance\evensidemargin\Gm@even@mp
%^^A     \fi
%^^A     \ifGm@compatii
%^^A       \@ifundefined{Gm@twosideshift}{%
%^^A         \def\Gm@twosideshift{20\Gm@truedimen pt}%
%^^A       }%
%^^A       \addtolength\oddsidemargin{\Gm@twosideshift}%
%^^A       \addtolength\evensidemargin{-\Gm@twosideshift}%
%^^A     \fi
%^^A   \else
%^^A     \evensidemargin\oddsidemargin
%^^A   \fi
%^^A   \advance\oddsidemargin\Gm@bindingoffset
%^^A   \addtolength\topmargin{-1\Gm@truedimen in}%
%^^A   \ifGm@includehead
%^^A     \addtolength\textheight{-\headheight}%
%^^A     \addtolength\textheight{-\headsep}%
%^^A   \else
%^^A     \addtolength\topmargin{-\headheight}%
%^^A     \addtolength\topmargin{-\headsep}%
%^^A   \fi
%^^A   \ifGm@includefoot
%^^A     \addtolength\textheight{-\footskip}%
%^^A   \fi
%^^A   \ifGm@heightrounded
%^^A     \setlength\@tempdima{\textheight}%
%^^A     \addtolength\@tempdima{-\topskip}%
%^^A     \@tempcnta\@tempdima
%^^A     \@tempcntb\baselineskip
%^^A     \divide\@tempcnta\@tempcntb
%^^A     \setlength\@tempdimb{\baselineskip}%
%^^A     \multiply\@tempdimb\@tempcnta
%^^A     \advance\@tempdima-\@tempdimb
%^^A     \multiply\@tempdima\tw@
%^^A     \ifdim\@tempdima>\baselineskip
%^^A       \addtolength\@tempdimb{\baselineskip}%
%^^A     \fi
%^^A     \addtolength\@tempdimb{\topskip}%
%^^A     \textheight\@tempdimb
%^^A   \fi
%^^A   \addtolength\paperwidth{\Gm@bindingoffset}%
%^^A  \fi}%

\def\Gm@showparams{% \changes{v0.72}{2007/11/17}{a~bug fix:
  %% \cs{@ifundefined\{Gm@lines\}} raised an error when \cs{geometry}
  %% used inside the \env{document}, I~change it to
  %% \cs{ifx}\cs{@undefined}}
  -------------------- Geometry parameters^^J%
  \ifGm@pass
  'pass' is specified!! (disables the geometry layouter)^^J%
  \else
  paper: \ifx\Gm@paper\@undefined class default\else\Gm@paper\fi^^J%
  \Gm@checkbool{landscape}%
  twocolumn: \if@twocolumn\Gm@true\else--\fi^^J%
  twoside: \if@twoside\Gm@true\else--\fi^^J%
  asymmetric: \if@mparswitch --\else\if@twoside\Gm@true\else --\fi\fi^^J%
  h-parts: \Gm@lmargin, \Gm@width, \Gm@rmargin%
  \ifnum\Gm@cnth=\z@\space(default)\fi^^J%
  v-parts: \Gm@tmargin, \Gm@height, \Gm@bmargin%
  \ifnum\Gm@cntv=\z@\space(default)\fi^^J%
  hmarginratio: \ifnum\Gm@cnth<5 \ifnum\Gm@cnth=3--\else%
    \Gm@hmarginratio\fi\else--\fi^^J%
  vmarginratio: \ifnum\Gm@cntv<5 \ifnum\Gm@cntv=3--\else%
    \Gm@vmarginratio\fi\else--\fi^^J%
  lines: \ifx\Gm@lines\@undefined--\else\Gm@lines\fi^^J% here
  % I~(natror) fix the bug: it was \inverb|\@ifundefined| that of
  % course was assigning \inverb|\relax| to \inverb|\Gm@lines| and
  % that resulted in an error when \inverb|\geometry| was used inside
  % document.
  \Gm@checkbool{heightrounded}%
  bindingoffset: \the\Gm@bindingoffset^^J%
  truedimen: \ifx\Gm@truedimen\@empty --\else\Gm@true\fi^^J%
  \Gm@checkbool{includehead}%
  \Gm@checkbool{includefoot}%
  \Gm@checkbool{includemp}%
  driver: \Gm@driver^^J%
  \fi
  -------------------- Page layout dimensions and switches^^J%
  \string\paperwidth\space\space\the\paperwidth^^J%
  \string\paperheight\space\the\paperheight^^J%
  \string\textwidth\space\space\the\textwidth^^J%
  \string\textheight\space\the\textheight^^J%
  \string\oddsidemargin\space\space\the\oddsidemargin^^J%
  \string\evensidemargin\space\the\evensidemargin^^J%
  \string\topmargin\space\space\the\topmargin^^J%
  \string\headheight\space\the\headheight^^J%
  \string\headsep\@spaces\the\headsep^^J%
  \string\footskip\space\space\space\the\footskip^^J%
  \string\marginparwidth\space\the\marginparwidth^^J%
  \string\marginparsep\space\space\space\the\marginparsep^^J%
  \string\columnsep\space\space\the\columnsep^^J%
  \string\skip\string\footins\space\space\the\skip\footins^^J%
  \string\hoffset\space\the\hoffset^^J%
  \string\voffset\space\the\voffset^^J%
  \string\mag\space\the\mag^^J%
  \if@twocolumn\string\@twocolumntrue\space\fi%
  \if@twoside\string\@twosidetrue\space\fi%
  \if@mparswitch\string\@mparswitchtrue\space\fi%
  \if@reversemargin\string\@reversemargintrue\space\fi^^J%
  (1in=72.27pt, 1cm=28.45pt)^^J%
  -----------------------}

% Add restore to BeginDocument:

\AtBeginDocument{\@xa\RestoreMacros\gme@tobestored}

\endinput
% \ChangesGeneral
%
% \changes{v0.70}{2007/04/29}{Back to the v0.68 settings because
% \cs{not@onlypreamble} was far too little. Well, in this version the
% redefinition of \cs{geometry} is given up since the `committing'
% commands depend on the particular situation so defining only two
% options doesn't seem advisable}
%
% \changes{v0.71}{2007/11/17}{a~\acro{TDS}-compliant \file{zip}
% archive made}
%
% \changes{v0.72}{2008/08/06}{2008/08/06 only the way of documenting changes so
% I~don't increase the version number}
%
%
% \NoEOF

% (For my GNU Emacs:)
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: "../../../../LaTeX/TeXGuru/gmeometric/gmeometricDoc.tex"
%%% End: