summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ncclatex/ncc.cls
blob: ffc2a048e203a84fd814d5b23251185e3813ecec (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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{ncc}
         [2006/01/17 v1.10 NCC-LaTeX document class (NCC)]
%
% \changes{v1.01}{2002/03/24}{This version is uploaded to CTAN}
% \changes{v1.02}{2002/04/03}{Bug in loading book class fixed}
% \changes{v1.03}{2004/04/08}{The processing of 'russian' option is improved}
% \changes{v1.04}{2004/09/23}{Provide index making commands via the makeidx}
% \changes{v1.05}{2004/11/30}{Remove \NCC@null from the titlepage env.}
% \changes{v1.05}{2004/11/30}{Rename \NCC@null to \StartFromTextArea}
% \changes{v1.05}{2004/11/30}{Add the \StartFromHeaderArea command}
% \changes{v1.06}{2004/12/16}{Remove \NCC@gempty command}
% \changes{v1.07}{2005/01/12}{Remove options passed to packages}
% \changes{v1.07}{2005/02/21}{Set tbtags as default option}
% \changes{v1.07}{2005/03/23}{Add optional arg. to \alloweqbreak}
% \changes{v1.07}{2005/03/30}{Fix bug in the \preprint command}
% \changes{v1.07}{2005/05/20}{Move \StartFromTextArea to the nccsect package}
% \changes{v1.07}{2005/05/20}{Move \StartFromHeaderArea to the nccsect package}
% \changes{v1.08}{2005/06/18}{Add titlepage*, \ExpandTextArea, \RestoreTextArea}
% \changes{v1.08}{2005/07/02}{Improve \ExpandTextArea command}
% \changes{v1.09}{2005/12/24}{Move biblist to a separate package}
% \changes{v1.09}{2005/12/24}{Unify toc-headers using topsection package}
% \changes{v1.09}{2005/12/26}{Move titlepage and text area controls to separate packages}
% \changes{v1.09}{2005/12/26}{Loading ncctitle package instead of ncctitle.clo}
% \changes{v1.09}{2005/12/28}{Code revision and minor changes}
% \changes{v1.09}{2005/12/28}{More minor changes}
% \changes{v1.09}{2006/01/05}{The \SetTOCStyle was removed from here}
% \changes{v1.10}{2006/01/17}{addtopackage -> afterpackage}
% 
\newcommand\@ptsize{}
\newif\if@restonecol
\newif\if@openright
%
% What goes first in title: author or title?
%
\newif\ifNCC@authorbeforetitle
\newcommand{\AuthorBeforeTitle}{\NCC@authorbeforetitletrue}
\newcommand{\TitleBeforeAuthor}{\NCC@authorbeforetitlefalse}
\@onlypreamble\AuthorBeforeTitle
\@onlypreamble\TitleBeforeAuthor
%
% Paper size options
%
\DeclareOption{a4paper}
   {\setlength\paperheight {297mm}%
    \setlength\paperwidth  {210mm}}
\DeclareOption{a5paper}
   {\setlength\paperheight {210mm}%
    \setlength\paperwidth  {148mm}}
\DeclareOption{a5a4paper}
   {\setlength\paperheight {210mm}%
    \setlength\paperwidth  {210mm}}
\DeclareOption{b5paper}
   {\setlength\paperheight {250mm}%
    \setlength\paperwidth  {176mm}}
\DeclareOption{letterpaper}
   {\setlength\paperheight {11in}%
    \setlength\paperwidth  {8.5in}}
\DeclareOption{legalpaper}
   {\setlength\paperheight {14in}%
    \setlength\paperwidth  {8.5in}}
\DeclareOption{executivepaper}
   {\setlength\paperheight {10.5in}%
    \setlength\paperwidth  {7.25in}}
\DeclareOption{landscape}
   {\setlength\@tempdima   {\paperheight}%
    \setlength\paperheight {\paperwidth}%
    \setlength\paperwidth  {\@tempdima}}
\DeclareOption{fittopage}{}
%
% Base font size options
%
\DeclareOption{10pt}{\renewcommand\@ptsize{0}}
\DeclareOption{11pt}{\renewcommand\@ptsize{1}}
\DeclareOption{12pt}{\renewcommand\@ptsize{2}}
\DeclareOption{14pt}{\renewcommand\@ptsize{4}%
                     \PassOptionsToPackage{small}{ncclatex}}
%
% Layout options
%
\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
\DeclareOption{twoside}{\@twosidetrue \@mparswitchtrue}
\DeclareOption{draft}{\setlength\overfullrule{5pt}}
\DeclareOption{final}{\setlength\overfullrule{0pt}}
\DeclareOption{openany}{\@openrightfalse}
\DeclareOption{openright}{\@openrighttrue}
\DeclareOption{onecolumn}{\@twocolumnfalse}
\DeclareOption{twocolumn}{\@twocolumntrue}
%
% Special openbib option
%
\DeclareOption{openbib}{%
  \AtEndOfPackage{%
    \renewcommand\@openbib@code{%
      \advance\leftmargin\bibindent
      \itemindent -\bibindent
      \listparindent \itemindent
      \parsep \z@
      }
    \renewcommand\newblock{\par}
  }%
}
%
% \setyear{year} command defines \theyear
%
\newcommand*{\setyear}[1]{\gdef\theyear{#1}}
\newcommand\theyear{\number\year}
%
% Subclass selection options
%
\DeclareOption{article}{%
  \def\NCC@clsload{%
    \TitleBeforeAuthor
    \input{nccart.clo}%
    \newcommand*{\setseries}[1]{\gdef\theseries{##1}}%
    \newcommand*{\setvolume}[1]{\gdef\thevolume{##1}}%
    \newcommand*{\setissue}[1]{\gdef\theissue{##1}}%
    \setseries{}\setvolume{}\setissue{}%
    \AtEndDocument{%
      \clearpage
      \if@filesw \advance\c@page\m@ne
        \immediate\write\@mainaux{\string\newlabel
          {NCC@lastpage}{{}{\thepage}}}%
        \advance\c@page\@ne
      \fi
      \openrightorany
    }%
    \pagestyle{myheadings}%
    \countstyle{}%
    \InputIfFileExists{nccadd.sty}{}{}%
  }%
  \let\chapter\relax
  \let\thechapter\relax
}
\DeclareOption{preprint}{%
  \def\NCC@clsload{%
    \AuthorBeforeTitle
    \input{nccart.clo}%
    \RequirePackage{ncctitle}%
    \RequirePackage{afterpackage}
    \newcommand\preprintname{Preprint}
    \AfterPackage{babel}{%
      \addto\captionsrussian{%
        \def\preprintname{%
          {\cyr\CYRP\cyrr\cyre\cyrp\cyrr\cyri\cyrn\cyrt}}%
      }
    }
    \newcommand*{\preprint}[1]{%
      \def\thepreprint{##1}%
      \ifx\thepreprint\@empty
        \titlecomment{}%
      \else
        \titlecomment{\bfseries \preprintname\\[1.5ex]\thepreprint}%
      \fi
    }%
    \preprint{}%
    \pagestyle{headings}%
    \countstyle{}%
  }%
  \let\chapter\relax
  \let\thechapter\relax
}
\DeclareOption{book}{%
  \def\NCC@clsload{%
    \AuthorBeforeTitle
    \input{nccbook.clo}%
    \RequirePackage{ncctitle}%
    \let\bookeditor\titlecomment
    \pagestyle{headings}%
    \countstyle{chapter}%
  }%
  \let\chapter\@empty    % nccsect and russianb packages test an existence of
  \let\thechapter\@empty % \thechapter and \chapter to understand what class
}                        % was loaded
\DeclareOption{report}{\ExecuteOptions{book,oneside}}
%
% We set tbtags as the default tags positioning in split environment
%
\def\NCC@temp{\PassOptionsToPackage{tbtags}{nccmath}}
\DeclareOption{centertags}{\let\NCC@temp\relax}
%
% Process options and load size option file
%
\ExecuteOptions{a4paper,10pt,article,twoside,onecolumn,final,openany}
\ProcessOptions\relax
\NCC@temp \let\NCC@temp\relax
\input{ncc1\@ptsize.clo}
\@ifclasswith{ncc}{fittopage}{\input{nccfit.clo}}{}
%
% Center text on the page taking into account the header only,
% because default NCC-LaTeX style is headings or myheadings and
% marginal notes are useless. The top margin is bounded by 1.5in.
%
\RequirePackage{tocenter}
\ToCenter[h]{\textwidth}{\textheight}
\ifdim\topmargin >.5in \topmargin=.5in \fi
%
% Set list margins
%
\if@twocolumn
  \setlength\leftmargini  {2em}
  \setlength\leftmarginii {1.7em}
  \setlength\leftmarginiii{1.5em}
  \setlength\leftmarginiv {1.2em}
  \setlength\leftmarginv  {.5em}
  \setlength\leftmarginvi {.5em}
\else
  \setlength\leftmargini  {2.5em}
  \setlength\leftmarginii {2.2em}
  \setlength\leftmarginiii{1.87em}
  \setlength\leftmarginiv {1.7em}
  \setlength\leftmarginv  {1em}
  \setlength\leftmarginvi {1em}
\fi
\setlength\labelsep{.5em}
\leftmargin\leftmargini
\def\NCC@labelwidth{\labelwidth\leftmargin\advance\labelwidth-\labelsep}
\NCC@labelwidth
%
% Set enumeration styles
%
\renewcommand\theenumi{\@arabic\c@enumi}
\renewcommand\theenumii{\@alph\c@enumii}
\renewcommand\theenumiii{\@roman\c@enumiii}
\renewcommand\theenumiv{\@Alph\c@enumiv}
\renewcommand\p@enumii{\theenumi}
\renewcommand\p@enumiii{\theenumi(\theenumii)}
\renewcommand\p@enumiv{\p@enumiii\theenumiii}
\newcommand\labelenumi{\theenumi.}
\newcommand\labelenumii{(\theenumii)}
\newcommand\labelenumiii{\theenumiii.}
\newcommand\labelenumiv{\theenumiv.}
\newcommand\labelitemi{\textbullet}
\newcommand\labelitemii{\normalfont\bfseries \textendash}
\newcommand\labelitemiii{\textasteriskcentered}
\newcommand\labelitemiv{\textperiodcentered}
%
% Set other dimensions, skips, and penalties
%
\if@twocolumn \setlength\parindent{1em}
\else         \setlength\parindent{1.5em}
\fi
\setlength\smallskipamount{3\p@ \@plus \p@ \@minus \p@}
\setlength\medskipamount{6\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\bigskipamount{12\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\maxdepth{.5\topskip}
\setlength\lineskip{\p@}
\setlength\normallineskip{\p@}
\renewcommand\baselinestretch{}
\setlength\columnseprule{0\p@}
\setlength\parskip{\z@ \@plus \p@}
\@lowpenalty   51
\@medpenalty  151
\@highpenalty 301
\@beginparpenalty -\@lowpenalty
\@endparpenalty   -\@lowpenalty
\@itempenalty     -\@lowpenalty
\setcounter{topnumber}{4}
\renewcommand\topfraction{.8}
\setcounter{bottomnumber}{2}
\renewcommand\bottomfraction{.6}
\setcounter{totalnumber}{6}
\renewcommand\textfraction{.2}
\renewcommand\floatpagefraction{.5}
\setcounter{dbltopnumber}{4}
\renewcommand\dbltopfraction{.8}
\renewcommand\dblfloatpagefraction{.5}
\setlength\arraycolsep{5\p@}
\setlength\tabcolsep{6\p@}
\setlength\arrayrulewidth{.4\p@}
\setlength\doublerulesep{2\p@}
\setlength\tabbingsep{\labelsep}
\skip\@mpfootins = \skip\footins
\setlength\fboxsep{3\p@}
\setlength\fboxrule{.4\p@}
\def\@dotsep{4.5}
%
% Declare old font selection commands
%
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
\DeclareRobustCommand*\cal{\@fontswitch\relax\mathcal}
\DeclareRobustCommand*\mit{\@fontswitch\relax\mathnormal}
%
% Create section counters. We use \countstyle command from dcounter package.
%
\RequirePackage{dcounter}
\newcounter{part}
\renewcommand\thepart{\@Roman\c@part}
\@ifundefined{chapter}{
  \countstyle[section]{}
}{
  \countstyle[chapter]{}
  \countstyle[section]{chapter}
}
\countstyle[subsection]{section}
\countstyle[subsubsection]{subsection}
\countstyle[paragraph]{subsubsection}
\countstyle[subparagraph]{paragraph}
%
% Declare floats
%
\DeclareDynamicCounter{figure}
\def\fps@figure{tbp}
\def\ftype@figure{1}
\def\ext@figure{lof}
\def\fnum@figure{\figurename\nobreakspace\thefigure}
\newenvironment{figure}{\@float{figure}}{\end@float}
\newenvironment{figure*}{\@dblfloat{figure}}{\end@dblfloat}
\DeclareDynamicCounter{table}
\def\fps@table{tbp}
\def\ftype@table{2}
\def\ext@table{lot}
\def\fnum@table{\tablename\nobreakspace\thetable}
\newenvironment{table}{\@float{table}}{\end@float}
\newenvironment{table*}{\@dblfloat{table}}{\end@dblfloat}
%
% Names of standard english captions
%
\newcommand\prefacename{Preface}
\newcommand\contentsname{Contents}
\newcommand\listfigurename{List of Figures}
\newcommand\listtablename{List of Tables}
\newcommand\refname{References}
\newcommand\bibname{Bibliography}
\newcommand\indexname{Index}
\newcommand\glossaryname{Glossary}
\newcommand\figurename{Figure}
\newcommand\tablename{Table}
\newcommand\partname{Part}
\newcommand\chaptername{Chapter}
\newcommand\appendixname{Appendix}
\newcommand\abstractname{Abstract}
%
% English version of \today
%
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
%
% Prepare commands for making indices
%
\RequirePackage{makeidx}
\newcommand\printglossary{\@input@{\jobname.gls}}
%
% Load remaining packages
%
\RequirePackage{ncclatex}
\RequirePackage{topsection}
\RequirePackage{watermark}
\RequirePackage{ncctitlepage}
\RequirePackage{nccheadings}
\RequirePackage{nccold}
%
% Define the bibliography
%
\newdimen\bibindent
\setlength\bibindent{1.5em}
\let\@openbib@code\@empty
\newcommand\newblock{\hskip .11em\@plus .33em\@minus .07em}
\RequirePackage{nccbiblist}
\def\NCC@biblisthook{\itemsep\parsep}
%
% noeqbreak supresses page breaks before display equations
% alloweqbreak[number] allows page breaks before display equations
% (default is alloweqbreak[4])
%
\newenvironment{noeqbreak}{\predisplaypenalty\@M
  \ignorespaces
}{\ignorespacesafterend}
\newenvironment*{alloweqbreak}[1][4]{%
  \predisplaypenalty 
  \ifcase #1\@highpenalty
    \or \@lowpenalty
    \or \z@
    \or \@beginparpenalty
    \else \@secpenalty
  \fi
  \ignorespaces
}{\ignorespacesafterend}
\alloweqbreak                 % Break before display formulas is allowed
\allowdisplaybreaks           % Breaks in display formulas are allowed
%
% Verse, quotation, quote. The description is already defined in ncclatex
%
\newenvironment{verse}{%
  \let\\\centercr
  \list{}{\itemsep \z@ \itemindent -1.5em \listparindent\itemindent
          \rightmargin \leftmargin \advance\leftmargin 1.5em}%
  \item\relax
}{\endlist}
\newenvironment{quotation}{%
  \list{}{\listparindent 1.5em \itemindent \listparindent
          \rightmargin \leftmargin \parsep \z@ \@plus \p@}%
  \item\relax
}{\endlist}
\newenvironment{quote}{%
  \list{}{\rightmargin\leftmargin}\item\relax
}{\endlist}
%
% Footnote making commands
%
\renewcommand{\footnoterule}{%
  \kern-3\p@ \hrule\@width .4\columnwidth \kern2.6\p@
}
\newcommand{\@makefntext}[1]{%
  \parindent 1em \noindent
  \hb@xt@ 1.8em{\hss\@makefnmark}#1}
%
% \tableofcontents, \listoffigures, \listoftables
%
\newcommand{\tableofcontents}{\NCC@toc\contentsname{toc}}
\newcommand{\listoffigures}{\NCC@toc\listfigurename{lof}}
\newcommand{\listoftables}{\NCC@toc\listtablename{lot}}
\def\NCC@toc#1{\skipwritingtoaux\topsection{#1}\@starttoc}
%
% theindex and theglossary
%
\newenvironment{theindex}{\NCC@index\indexname}{\endNCC@index}
\newenvironment{theglossary}{\NCC@index\glossaryname}{\endNCC@index}
\newenvironment*{NCC@index}[1]{%
  \if@twocolumn \@restonecolfalse \else \@restonecoltrue \fi
  \columnseprule \z@ \columnsep 35\p@
  \@iftopchapter{\twocolumn \topsection{#1}}%
                {\twocolumn[\topsection{#1}]\thispageheading{}}%
  \parindent\z@ \parskip\z@ \@plus .3\p@
  \let\item\@idxitem \small
}{\if@restonecol\onecolumn \else \clearpage\fi}
\newcommand\@idxitem{\par\hangindent 5em}
\newcommand\subitem{\@idxitem \hspace*{2em}}
\newcommand\subsubitem{\@idxitem \hspace*{4em}}
\newcommand\indexspace{\par \addvspace{4ex \@plus 1ex \@minus .5ex}}
%
% Final actions
%
\pagenumbering{arabic}
\NCC@clsload % load specified subclass
\let\NCC@clsload\relax
\if@twocolumn
  \twocolumn \sloppy \flushbottom
\else
  \onecolumn
  \if@twoside \flushbottom \else \raggedbottom \fi
\fi
\endinput