summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmutils/gmparts.sty
blob: 004bbb15db02ebc21a569619552ca5ffe522346e (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
%% 
%% \iffalse ^^A we skip the debug setting
\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{}
%% \fi
%% ^^A $Id: TheUltimateMaster.gmd,v 0.297 2011/02/02 18:13:11 natror Exp natror $
%% This is file “gmparts.sty” generated with the DocStrip utility.
%% 
%%
%% The original source files were:
%%
%% gmutils/gmutils.gmd  (with options: `parts')
%%
%% 
%% Copyright ©  
%% by Grzegorz ‘Natror’ Murzynowski
%% natror (at) o2 (dot) pl
%% 
%% This program is subject to the LaTeX Project Public License.
%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
%% for the details of that license.
%%
%% LPPL status: "author-maintained".
%%
%% 
%% 
%% For the documentation please refer to the file(s)
%% gmutils.{gmd,pdf}.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmparts}
    [2010/10/24 v0.993 modification of \string \include \space \string & in/excluding parts of main file (GM)]


%%
%%
%%     ^^A\typeout{\unexpanded{#4}}%%


\RequirePackage{gmcommand}

\def\gmu@getext#1.#2\@nil{%\UnDef
  \def\gmu@filename{#1}%\UnDef
  \def\gmu@fileext{#2}}

\def\include#1{\relax
  \ifnum\@auxout=\@partaux
  \@latex@error{\string\include\space cannot be nested}\@eha
  \else \@include#1 \fi}

\def\@include#1 {%
  \gmu@getext#1.\@nil
  % \UnDef
  \ifx\gmu@fileext\empty\def\gmu@fileext{tex}\fi
  \clearpage
  \if@filesw
    \immediate\write\@mainaux{\string\@input{\gmu@filename.aux}}%
  \fi
  \@tempswatrue
  \if@partsw
    \@tempswafalse
    \edef\reserved@b{#1}%
    \@for\reserved@a:=\@partlist\do{%
      \ifx\reserved@a\reserved@b\@tempswatrue\fi}%
  \fi
  \if@tempswa
    \let\@auxout\@partaux
    \if@filesw
      \immediate\openout\@partaux \gmu@filename.aux
      \immediate\write\@partaux{\relax}%
    \fi
    \@input@{\gmu@filename.\gmu@fileext}%
    \inclasthook
    \clearpage
    \@writeckpt{\gmu@filename}%
    \if@filesw
      \immediate\closeout\@partaux
    \fi
  \else
    \deadcycles\z@
    \@nameuse{cp@\gmu@filename}%
  \fi
  \let\@auxout\@mainaux}

\newcommand\whenonly[3]{%
  \def\gmu@whonly{#1,}%
  \ifx\gmu@whonly\@partlist\afterfi{#2}\else\afterfi{#3}\fi}

\def\inclasthook{\thispagestyle{closing}}

\def\filepart#1{\relax
  \ifnum\@auxout=\@partaux
  \@latex@error{\string\filepart\space cannot be nested}\@eha
  \else\afterfi{\@filepart#1 }\fi}

\def\@filepart#1 {%
  \clearpage
  \edef\gmu@filepartname{#1}% we'll use it later
  \if@filesw
    \immediate\write\@mainaux{\string\@input{#1.aux}}%
  \fi
  \@tempswatrue
  \if@partsw
    \@tempswafalse
    \@for\gmu@filepart@resa:=\@partlist\do{%
      \ifx\gmu@filepart@resa\gmu@filepartname\@tempswatrue\fi}%
  \fi
  \if@tempswa
    \let\@auxout\@partaux
    \if@filesw
      \immediate\openout\@partaux #1.aux
      \immediate\write\@partaux{\relax}%
    \fi
    \@xa\@firstoftwo
    % \label{spart:iftrue}
  \else
    \deadcycles\z@
    \@nameuse{cp@\gmu@filepartname}%
    \let\@auxout\@mainaux
    \@xa\@secondoftwo
  \fi
  {\iftrue}%
  {\let\endfilepart\fi
    \csname gm@skipped@#1\endcsname
    \def\next{\Restore@MacroSt {endfilepart}%
      \@ifnextchar\bgroup{\show\NextBgroup\@gobble}{}}%
    \@xa\next\iffalse}%
}

\DeclareCommand\endfilepart{b}{% Note the argument is  not used really. Maybe later we'll
  % use it for checking of proper matching. Or maybe not.
  \inclasthook
  \clearpage
  \@writeckpt{\gmu@filepartname}%
  \if@filesw
  \immediate\closeout\@partaux
  \fi
  \fi% this |\fi| closes |\Iftrue| put by line \ref{spart:iftrue}.
  \let\@auxout\@mainaux
}

\Store@Macro\endfilepart

\def\nofileparts{%
  \let\filepart\@gobble
  \DeclareCommand\endfilepart{b}{}%
}


\def\includecountfix{%
  \def\@wckptelt##1{%
    \immediate\write\@partaux{%
      \providecounter{##1}% to
      % provide the font counters defined
      % in parts of the document.
      \string\setcounter{##1}{\the\@nameuse{c@##1}}}}%
}

\pdef\providecounter#1{%
  \unless\ifcsname c@#1\endcsname\newcounter{#1}\fi}

\endinput
%%
%% End of file `gmparts.sty'.