-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcekcommon.sty
542 lines (471 loc) · 18.1 KB
/
cekcommon.sty
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
%% Filename : cekcommon.cls
%% Description : Common code for cekarticle2.cls and cekmanual.cls
%% Author(s) : Michael Hucka <mhucka@@caltech.edu>
%% Organization: CDS, California Institute of Technology
%% Created : 2002-03-01
%% Revision : $Id$
%% $Source$
%%
%% Copyright 2001 California Institute of Technology and
%% Japan Science and Technology Corporation.
%%
%% This file is free software; you can redistribute it and/or modify it
%% under the terms of the GNU Lesser General Public License as published
%% by the Free Software Foundation; either version 2.1 of the License, or
%% any later version.
%%
%% This library is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
%% MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
%% documentation provided hereunder is on an "as is" basis, and the
%% California Institute of Technology and Japan Science and Technology
%% Corporation have no obligations to provide maintenance, support,
%% updates, enhancements or modifications. In no event shall the
%% California Institute of Technology or the Japan Science and Technology
%% Corporation be liable to any party for direct, indirect, special,
%% incidental or consequential damages, including lost profits, arising
%% out of the use of this software and its documentation, even if the
%% California Institute of Technology and/or Japan Science and Technology
%% Corporation have been advised of the possibility of such damage. See
%% the GNU Lesser General Public License for more details.
%%
%% You should have received a copy of the GNU Lesser General Public License
%% along with this library; if not, write to the Free Software Foundation,
%% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
%% ----------------------------------------------------------------------------
%% Package imports.
%% ----------------------------------------------------------------------------
%% Important: hyperref needs to be the last package loaded, followed by
%% color and colortbl.
% 2002-01-15 <[email protected]> Decided to revert to the default tex font.
% If you use Charter (or just about anything else), then the default
% typewriter font is too hard to distinguish visually. So then you end up
% trying to find an alternative, like Courier Bold, and the result is way
% too dark on the page. So until we can get ourselves a professional font
% alternative (e.g., maybe the Y&Y Modern font used in the LaTeX Web
% Companion), I think it's best to use the CM fonts.
%
% Use Charter as the body font.
% \RequirePackage{charter}
% 2002-01-15 <[email protected]>
% This provides a look similar to the Harbison & Steele book on C,
% but I think it's just too heavy when combined with the body
% font we're using here. Books like those from O'Reilly
% use a non-bold Courier, and it looks a bit more professional
% (at least for the body font we're using).
% \RequirePackage{courier}
% \renewcommand{\ttdefault}{pcr}
% There seems to be no bold version of the Computer Modern Sans font.
% The following sets things up so that it uses the bold extended, which
% (curiously) *does* exist. See p. 181 of The LaTeX Companion, 1994.
\def\bfdefault{bx}
% Define a bold typewriter font using the (optional) cmtt.
% You have to download the cmtt metafont files from CTAN.
%
% 2003-06-11 <[email protected]>
% This doesn't look all that good, and it causes problems if someone
% doesn't set up their MF inputs path to look in this directory.
% Let's take it out for now.
%
%\DeclareFontShape{OT1}{cmtt}{bx}{n}
%{<5><6><7><8>cmbtt8%
% <9>cmbtt9%
% <10><10.95>cmbtt10%
% <12><14.4><17.28><20.74><24.88>cmbtt10}{}
% The standard latex installation does not have a version of CMS bold
% extended slanted (cmss/bx/sl). There seems to be at least one
% implementation of this font available on the net, but it's in Type1
% format and would require work to get running on each developer's
% machine. So, let's just skip it and set up a substitution.
\DeclareFontShape{OT1}{cmss}{bx}{sl}{<->sub*cmss/bx/n}{}
% Define the reference style.
\RequirePackage[round]{natbib}
% Load up some basic packages we depend on.
\RequirePackage[american]{varioref}
\RequirePackage{ifthen}
\RequirePackage{float}
\RequirePackage{wrapfig}
\RequirePackage{array}
\RequirePackage{alltt}
\RequirePackage{booktabs}
\RequirePackage{psfrag}
\RequirePackage{html}
\RequirePackage{listings}
% Preload the languages we use.
% Important: do not load "C"; it causes the package to crash on first use.
\lstloadlanguages{Java,[Visual]C++,csh,Delphi,Matlab,make,Perl,Python}
% Switch on whether pdflatex is being used or not, so that we can
% set the proper switches.
\@ifundefined{pdfoutput}{%
\RequirePackage{graphicx}
% Test whether we're being run from latex or latex2html
\latexhtml{
% For latex.
\RequirePackage[breaklinks]{hyperref}
}{
% For latex2html.
\RequirePackage[latex2html,breaklinks]{hyperref}
}
\if@xdvi
\RequirePackage[xdvi,usenames]{color}
\else
\RequirePackage[dvips,usenames]{color}
\fi
}{%
\RequirePackage[pdftex]{graphicx}
% 2001-05-25 <[email protected]> Note about hyperref: I have spent hours
% trying to make colorlinks=true work, but failed. The problem is that there
% is some interaction between the latex2e color package and dvips, such that
% if color is used, regular text on the page seems to be printed not as black
% but as a combination of all RGB colors at 100% density. The result is
% not-quite-black text that is fuzzy and ugly. I'm giving up and resorting
% to the default hyperref boxed link style instead of using colored links.
% I find boxed links more intrusive in the text, but I can't spend any more
% time debugging this problem. (Simply avoiding the color package is not
% an option here because attempting to use colored links requires it.)
% \RequirePackage[pdftex,breaklinks=true,
% bookmarks=true,bookmarksopen=true,bookmarksopenlevel=2,
% pdfhighlight=/O,urlbordercolor={0.8 0.8 1},citebordercolor={0.8 0.8 1},
% linkbordercolor={0.8 0.8 1},pagebordercolor={0.8 0.8 1}]{hyperref}
% 2001-10-22 <[email protected]> Discovered that the problem appears to
% be only on our NEC SuperScript 4650N printer. Grr. So going back to
% using colorlinks=true.
\RequirePackage[pdftex,breaklinks=true,colorlinks=true,
bookmarks=true,bookmarksopen=true,bookmarksopenlevel=2,
pdfhighlight=/O,linkcolor={blue},citecolor={blue},
pagecolor={blue},urlcolor={blue}]{hyperref}
\RequirePackage[pdftex,usenames]{color}
\definecolor{MidnightBlue}{cmyk}{0.98,0.13,0,0.43}
\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
\definecolor{BrickRed}{cmyk}{0,0.89,0.94,0.28}
}
\RequirePackage{colortbl}
%% ----------------------------------------------------------------------------
%% Main code.
%% ----------------------------------------------------------------------------
\raggedbottom
% The default inter-line spacing with 10pt font seems a bit too big. This
% tightens it ever so slightly.
\renewcommand{\baselinestretch}{0.98}
% Margin adjustments. I've tried using vmargin.sty, but it interacts badly
% with page numbers at the bottom of the page, so I've resorted to hardcoding
% the dimensions like this.
% I don't understand why the value of the left margin is actually 1 inch +
% \hoffset. Why bother with the 1 inch, when there are the additional
% parameters \oddsidemargin and \evensidemargin? Anyway, I'm resetting
% \hoffset to negate the 1 inch so that we start from a clean slate.
\setlength{\hoffset}{-1.0 in}
\setlength{\oddsidemargin}{1.4 in}
\setlength{\evensidemargin}{1.4 in}
\setlength{\textwidth}{5.7 in}
\setlength{\textheight}{9 in}
\setlength{\marginparsep}{9 pt}
\setlength{\marginparwidth}{0.75 in}
\ifx\pdfoutput\undefined
\setlength{\topmargin}{1 ex}
\else
\setlength{\topmargin}{-8 ex}
\fi
\setlength{\voffset}{0 in}
% Definition of the paragraph style.
\setlength{\parindent}{0 pt} % Unindented paragraphs, separated ...
\setlength{\parskip}{1.3 ex} % ... by roughly one blank line.
\setlength{\partopsep}{-1 ex}
% Fix placement of figures & tables. This keeps latex from shoving big
% floats to the end of a document when they are somewhat big, which it will
% do even if you put [htb] as the argument.
\setcounter{topnumber}{2}
\renewcommand\topfraction{1.0}
\setcounter{bottomnumber}{2}
\renewcommand\bottomfraction{1.0}
\renewcommand\textfraction{0.0}
\renewcommand\floatpagefraction{0.9}
\newcommand{\grayrow}{\rowcolor[gray]{0.91}}
\newcommand{\greyrow}{\grayrow}
% Adjustments to package 'booktabs'.
\setlength{\cmidrulewidth}{0.3 pt}
\setlength{\lightrulewidth}{0.3 pt}
\setlength{\heavyrulewidth}{0.9 pt}
% Title style. This is severely hacked from the orginal article.cls code.
\def\address#1{\gdef\@address{#1}}
\def\@address{\@latex@warning@no@line{No \noexpand\address given}}
\def\authoremail#1{\gdef\@authoremail{#1}}
\def\@authoremail{}
\def\acknowledge#1{\gdef\@acknowledge{#1}}
\def\@acknowledge{}
\newlength{\bottomgraphicwidth}
\setlength{\bottomgraphicwidth}{\textwidth}
\addtolength{\bottomgraphicwidth}{-26pt}
\def\@puttoc{%
\if@notoc
\else
\begingroup
\setcounter{tocdepth}{2}%
\addtolength{\parskip}{-1.5 ex}%
\tableofcontents%
\addtolength{\parskip}{1.5 ex}%
\endgroup
\fi}
\def\ps@myheadings{%
\let\@oddfoot\@empty\let\@evenfoot\@empty
\def\@evenhead{\thepage\hfil\slshape\leftmark}%
\def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
\let\@mkboth\@gobbletwo
\let\sectionmark\@gobble
\let\subsectionmark\@gobble
}
% Need redefine \tableofcontents to counter effects of hacking \section below.
\renewcommand\tableofcontents{%
\@startsection{section}{0}{0pt}{0ex \@plus -2ex \@minus -1ex}%
{0.8ex}{\normalfont\Large\bfseries\sffamily} *% The star fakes a \section*
\contentsname%
\@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
\@starttoc{toc}%
}
\renewcommand\maketitle{\par
\begingroup
\renewcommand\thefootnote{\@fnsymbol\c@footnote}%
\def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
\long\def\@makefntext##1{\parindent 1em\noindent
\hb@[email protected]{%
\hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
\if@twocolumn
\ifnum \col@number=\@ne
\@maketitle
\else
\twocolumn[\@maketitle]%
\fi
\else
\global\@topnum\z@ % Prevents figures from going at top of page.
\@maketitle
\fi
\thispagestyle{empty}\@thanks
\endgroup
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\@maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\@authoremail\@empty
\global\let\@address\@empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
}
\def\@maketitle{%
\newpage
\null
\begin{center}%
\let \footnote \thanks
\@puttitle
\vskip 2em%
{\lineskip .5em%
\@putauthorandaddress
}%
\vskip 1em%
{\large \@date}%
\end{center}%
\par%
\vskip 1.5em%
\ifx\pdfoutput\undefined
\else
\hypersetup{pdftitle={\@title},pdfauthor={\@author}}
\fi%
}
% The following is a modified version of the macro from article.cls.
% It adjusts the vertical spacing in TOC for section lines.
\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\z@
\addpenalty\@secpenalty
\addvspace{0.2ex \@plus\p@}%
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries\sffamily
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\endgroup
\fi}
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{\sffamily #4}\nobreak
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont\sffamily #5}%
\par}%
\fi}
% The following was ripped out of caption.sty, version 1.4b.
% Copyright (C) 1994-95 Harald Axel Sommerfeldt
% The first few lines set up the parameters for the layout created
% by this style file.
\newcommand{\captionsize}{\small}
\newcommand{\captionfont}{\captionsize\sffamily}
\newcommand{\captionlabelfont}{\captionsize\bfseries}
\newlength{\captionmargin}
\newsavebox{\as@captionbox}
\newlength{\as@captionwidth}
\newcommand{\as@normalcaption}[2]{%
#1 #2\par}
\let\as@caption\as@normalcaption
\newcommand{\as@centercaption}[2]{%
\parbox[t]{\as@captionwidth}{{\centering#1 #2\par}}}
\let\as@shortcaption\as@centercaption
\newcommand{\as@makecaption}[2]{%
\setlength{\leftskip}{\captionmargin}%
\setlength{\rightskip}{\captionmargin}%
\addtolength{\as@captionwidth}{-2\captionmargin}%
\captionfont%
\sbox{\as@captionbox}{{\captionlabelfont #1:} #2}%
\ifdim \wd\as@captionbox >\as@captionwidth
\as@caption{{\captionlabelfont #1:}}{#2}%
\else%
\as@shortcaption{{\captionlabelfont #1:}}{#2}%
\fi}
\renewcommand{\@makecaption}[2]{%
\vskip\abovecaptionskip%
\setlength{\as@captionwidth}{\linewidth}%
\as@makecaption{#1}{#2}%
\vskip\belowcaptionskip}
\ifx\@makerotcaption\undefined
\else
\typeout{\space\space\space\space\space\space\space\space\space
`rotating' package detected}
\renewcommand{\@makerotcaption}[2]{%
\captionfont%
\sbox{\as@captionbox}{{\captionlabelfont #1:} #2}%
\ifdim \wd\as@captionbox > .8\vsize
\rotatebox{90}{%
\setlength{\as@captionwidth}{.8\textheight}%
\begin{minipage}{\as@captionwidth}%
\as@caption{{\captionlabelfont #1:}}{#2}%
\end{minipage}}\par
\else%
\rotatebox{90}{\usebox{\as@captionbox}}%
\fi
\hspace{12pt}}
\fi
\ifx\floatc@plain\undefined
\else
\typeout{\space\space\space\space\space\space\space\space\space
`float' package detected}
\renewcommand\floatc@plain[2]{%
\setlength{\as@captionwidth}{\linewidth}%
\as@makecaption{#1}{#2}}
\ifx\as@ruled\undefined
\else
\renewcommand\floatc@ruled[2]{%
\setlength{\as@captionwidth}{\linewidth}%
\captionfont%
\as@caption{{\captionlabelfont #1:}}{#2}}
\fi
\fi
% Additional new commands.
\newcommand{\class}[1]{\texttt{#1}}
\newcommand{\attrib}[1]{\texttt{#1}}
\newcommand{\attribtype}[1]{\texttt{#1}}
\newcommand{\attribvalue}[1]{\texttt{#1}}
\newcommand{\method}[1]{\texttt{#1}}
\newcommand{\variable}[1]{\texttt{#1}}
% New figure environment for code examples with line numbers.
\newcommand{\tightspacing}{\renewcommand{\baselinestretch}{0.85}}
\newcommand{\regularspacing}{\renewcommand{\baselinestretch}{1.0}}
\newcommand{\examplespacing}{\renewcommand{\baselinestretch}{0.9}}
\newlength{\codeverbatimwidth}
\setlength{\codeverbatimwidth}{\textwidth}
\addtolength{\codeverbatimwidth}{-2ex}
% The first optional argument must be a language: Java, C, C++, Delphi, etc.
% If any additional arguments needed to be passed to the environment,
% put them after the language name separated by a comma. Here's an example:
%
% \begin{exampleFigure}
% \begin{codeVerbatim}[Java,first=20]
\lstnewenvironment{codeVerbatim}[1][Java]{%
\lstset{escapechar=|,%
language=#1,%
basicstyle=\small\ttfamily,%
labelstep=1,%
labelsep=9pt,%
labelstyle=\footnotesize,%
stringtest=false,%
belowskip=5pt,%
frame=tlrb,%
frametextsep=4pt,%
framerulewidth=0.5pt,%
commentstyle=\footnotesize\itshape,%
stringspaces=false,%
tabsize=2,%x
keywordstyle=\ttfamily,%
framerulecolor=MidnightBlue}%
\examplespacing \csname lst@SetFirstLabel\endcsname}
{\regularspacing \csname lst@SaveFirstLabel\endcsname}
\newcommand{\codenote}[1]{\marginpar{\footnotesize\textcolor{MidnightBlue}{\emph{#1}}}}
\lstnewenvironment{example}[1][Java]{%
\lstset{escapechar=|,%
language=#1,%
basicstyle=\small\ttfamily,%
aboveskip=0.75\baselineskip,%
belowskip=0.4\baselineskip,%
stringtest=false,%
indent=4ex,%
commentstyle=\footnotesize\itshape,%
stringspaces=false,%
tabsize=2,%x
keywordstyle=\ttfamily}
\examplespacing \csname lst@SetFirstLabel\endcsname}
{\regularspacing \csname lst@SaveFirstLabel\endcsname}
\lstnewenvironment{exampleTight}[1][Java]{%
\lstset{escapechar=|,%
language=#1,%
basicstyle=\small\ttfamily,%
aboveskip=0.75\baselineskip,%
belowskip=0.4\baselineskip,%
stringtest=false,%
indent=4ex,%
commentstyle=\footnotesize\itshape,%
stringspaces=false,%
tabsize=2,%x
keywordstyle=\ttfamily}
\tightspacing \csname lst@SetFirstLabel\endcsname}
{\regularspacing \csname lst@SaveFirstLabel\endcsname}
% Macros for use with psfrag.
% The following is for the simplest cases, where we're just interested in
% remapping the font.
\newcommand{\psf}[1]{\psfrag{#1}[Bc][Bc]{\small{#1}}}
\newcommand{\psfsm}[1]{\psfrag{#1}[Bc][Bc]{\footnotesize{#1}}}
% This is for regular cases, with alignment to the center & along the bottom.
\newcommand{\psfmath}[2]{\psfrag{#1}[Bc][Bc]{\small{$#2$}}}
\newcommand{\psfmathsm}[2]{\psfrag{#1}[Bc][Bc]{\footnotesize{$#2$}}}
% Commands for including images.
%begin{latexonly}
\ifx\pdfoutput\undefined
%end{latexonly}
\newcommand{\incfig}[2][]{\includegraphics[width=#1]{#2.eps}}
\newcommand{\incfigboxed}[2][]{\def\fboxsep{0pt}\fbox{\includegraphics[width=#1]{#2.eps}}}
\newcommand{\incimage}[2][]{\includegraphics[width=#1]{#2.eps}}
\newcommand{\incimageboxed}[2][]{\def\fboxsep{0pt}\fbox{\includegraphics[width=#1]{#2.eps}}}
%begin{latexonly}
\else
\newcommand{\incfig}[2][]{\includegraphics[width=#1]{#2.pdf}}
\newcommand{\incfigboxed}[2][]{\def\fboxsep{0pt}\fbox{\includegraphics[width=#1]{#2.pdf}}}
\newcommand{\incimage}[2][]{\pdfimage width #1 {#2.png}}
\newcommand{\incimageboxed}[2][]{\def\fboxsep{0pt}\fbox{\pdfimage width #1 {#2.png}}}
\fi
%end{latexonly}
%% -----------------------------------------------------------------------------
%% End of file `cekarticle.cls'.
%% -----------------------------------------------------------------------------