summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pkuthss/pkuthss-extra.sty
blob: af883b6a544d67908650628edc65940fa7dc88cb (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
% vim:ft=tex:ts=2:sw=2
%
% Peking University dissertation document class
%
% Copyright (c) 2008-2009 solvethis
% Copyright (c) 2010-2013 Casper Ti. Vector
%
% This work may be distributed and/or modified under the conditions of the
% LaTeX Project Public License, either version 1.3 of this license or (at
% your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX version
% 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% The current maintainer of this work is Casper Ti. Vector.
%
% This work consists of the following files:
%   pkuthss.cls
%   pkuthss-gbk.def
%   pkuthss-utf8.def
%   pkuthss-extra.sty

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{pkuthss-extra}
	[2014/04/12 v1.5.0 Common extra settings for the pkuthss document class]

% Check the dependency of pkuthss.
\@ifclassloaded{pkuthss}{}{
	\PackageError{pkuthss-extra}%
		{The pkuthss document class is not loaded}%
		{The pkuthss-extra package depends on the pkuthss document class.}
}

% eg. `\pkuthssextra@int@boolopt{spacing}{true}' will expand to:
%   \newif\ifpkuthssextra@opt@spacing \pkuthssextra@opt@spacingtrue
%   \DeclareOption{spacing}{\pkuthssextra@opt@spacingtrue}
%   \DeclareOption{nospacing}{\pkuthssextra@opt@spacingfalse}
\def\pkuthssextra@int@boolopt#1#2{
	\expandafter\newif\csname ifpkuthssextra@opt@#1\endcsname
	\@nameuse{pkuthssextra@opt@#1#2}
	\DeclareOption{#1}{\@nameuse{pkuthssextra@opt@#1true}}
	\DeclareOption{no#1}{\@nameuse{pkuthssextra@opt@#1false}}
}
% Whethet to use some common settings for adjusting spacing.
\pkuthssextra@int@boolopt{spacing}{true}
% Whether to use list environments that are tighter than LaTeX defaults.
\pkuthssextra@int@boolopt{tightlist}{true}
% Whether to let captions use a different font from the main text.
\pkuthssextra@int@boolopt{caption}{true}
% Add PDF bookmark for table of contents.
\pkuthssextra@int@boolopt{pdftoc}{true}
% Whether to enable the `\spacialchap' command.
\pkuthssextra@int@boolopt{spechap}{true}
% Whether to automatically set properties for generated PDF from user defined
% document information (author, title, etc.).
\pkuthssextra@int@boolopt{pdfprop}{true}
% Whether to use coloured hyperlinks in generated PDF.
\pkuthssextra@int@boolopt{colorlinks}{true}
% Process all class options now.
\ProcessOptions\relax

\ifpkuthssextra@opt@spacing
	% Automatically ignore spaces between CJK characters and preserve spaces in other
	% situations. XeCJK itself will handle this issue, therefore we do not use
	% `CJKspace' when using XeLaTeX.
	\unless\ifxetex\RequirePackage{CJKspace}\fi
	% Make spacing nicer in some situations (eg. footnotes and verbatims).
	\RequirePackage{setspace}
	% Make the text area centered in the page.
	\geometry{centering}
	% Set line skip.
	\linespread{1.41}\selectfont
	% Automatically insert a space between the label and the text in footnotes.
	\RequirePackage{footmisc}
	\renewcommand{\footnotelayout}{\ }
\fi

\ifpkuthssextra@opt@tightlist
	% Lists often appear to be too sparse when items are just one or two lines long.
	% Here we cancel the extra vertical spacing between list items.
	% Biblatex uses `\itemsep' as default `\bibitemsep', no need to change it.
	\RequirePackage{enumitem}
	\setlist{nolistsep}
\fi

\ifpkuthssextra@opt@caption
	% According to common aesthetics of typography, it is nice to make the font of
	% captions lighter than main text, and tables lighter than captions.
	\RequirePackage[font = it]{caption}
\fi

\ifpkuthssextra@opt@pdftoc
	% Add PDF bookmark for table of contents.
	\let\pkuthssextra@tmp@tableofcontents\tableofcontents
	\renewcommand{\tableofcontents}{
		% Make the `Contents' bookmark point correctly to the title of the table of
		% contents.
		\cleardoublepage
		% Actually add the PDF bookmark.
		\pdfbookmark[1]{\contentsname}{contents}
		\pkuthssextra@tmp@tableofcontents
	}
\fi

\ifpkuthssextra@opt@spechap
	% This command is used to start a chapter without numbering, and correctly set
	% the headers and footers in the chapter.
	\newcommand\specialchap[1]{
		\chapter*{#1}\addcontentsline{toc}{chapter}{#1}
		\markboth{#1}{}\phantomsection
	}
\fi

\AtBeginDocument{
	\ifpkuthssextra@opt@pdfprop
		% Automatically generate properties for generated PDF.
		% Use English properties to avoid problems with character encodings.
		\newcommand{\setpdfproperties}{
			\hypersetup{
				pdfauthor = {\@eauthor}, pdftitle = {\@etitle},
				pdfsubject = {\euniversity\ \ethesisname}, pdfkeywords = {\@ekeywords}
			}
		}
		% Set the properties when generating the title page because the document
		% information should have been all defined before this.
		\let\pkuthssextra@tmp@maketitle\maketitle
		% NOTE: `\hypersetup' must appear before `\maketitle', otherwise it might not
		% act as wished.
		\renewcommand\maketitle{\setpdfproperties\pkuthssextra@tmp@maketitle}
	\fi

	\ifpkuthssextra@opt@colorlinks
		% Use coloured hyperlinks in generated PDF.
		\hypersetup{colorlinks = true, allcolors = blue}
	\else
		% Set hyperlink colour to black in order to prevent hyperlinks from being too
		% hard-to-recognise in printed thesis.
		\hypersetup{hidelinks = true}
	\fi
}

\endinput