pkuthss/tex/pkuthss-extra.sty

183 lines
6.6 KiB
TeX

% vim:ft=tex:ts=2:sw=2
%
% Peking University dissertation document class
%
% Copyright (c) 2008-2009 solvethis
% Copyright (c) 2010-2015 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
% pkulogo.eps
% pkuword.eps
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{pkuthss-extra}
[2015/06/30 v1.6.3 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 modify footnote format.
\pkuthssextra@int@boolopt{footfmt}{true}
% Whethet to modify spacing according to school regulation.
\pkuthssextra@int@boolopt{pkuspace}{true}
% Whethet to use some common settings for adjusting spacing.
\pkuthssextra@int@boolopt{spacing}{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 up 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@footfmt
% Handle the `Unparsed material' issue with latex/dvipdfmx compilation.
\unless\ifxetex\unless\ifpdf
\newcommand*\pgfsysdriver{pgfsys-dvipdfm.def}
\fi\fi
% Circled text, cf. <https://tex.stackexchange.com/questions/7032/>.
\RequirePackage{tikz}
\newcommand*\pkuthssextra@int@circled[1]{%
\scalebox{0.8}{\tikz[baseline = (char.base)]{
\node[
shape = circle, draw = black, minimum size = 1.25em, inner sep = 0pt
] (char) {#1};
}}%
}
% Use circled numbers as footnote symbols. Does not affect title page, but
% footnote is rarely used in dissertation covers ;)
\renewcommand\thefootnote%
{\protect\pkuthssextra@int@circled{\arabic{footnote}}}
% Provides utility to modify footnote spacing.
% Option used to make sure it does not render interleaf pages totally blank.
\RequirePackage[cleardoublepage = current]{scrextend}
% Set up footnote spacing: symbol indent 2 ccwd, paragraph indent 3.5 ccwd,
% 0.75 ccwd between symbol and paragraph.
\deffootnote{2\ccwd}{3.5\ccwd}{\thefootnotemark\hspace{0.75\ccwd}}
\fi
\ifpkuthssextra@opt@pkuspace
% lineskip / baselineskip = 20 bp / (12 bp * (6 / 5)).
\linespread{1.39}\selectfont
% Quite harmless and frequently used package. Loaded together with `tocloft'
% plus a compatibility option to avoid package clash.
\RequirePackage{subfig}
% Provides utilities for setting TOC format; `titles' applied to avoid
% interfering with LaTeX's own title mechanism.
\RequirePackage[subfigure, titles]{tocloft}
\setlength{\cftbeforechapskip}{6bp plus 1bp}
\setlength{\cftsecindent}{\ccwd}
\setlength{\cftsubsecindent}{2\ccwd}
% Modify font size and separator of captions.
\RequirePackage{caption}
\DeclareCaptionFont{cfive}{\zihao{5}}
\DeclareCaptionLabelSeparator{quad}{\quad}
\captionsetup{font = cfive, labelsep = quad}
\fi
\ifpkuthssextra@opt@spacing
% Automatically ignore spaces between CJK characters, or otherwise preserve
% spaces. 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}
% 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.
\RequirePackage{enumitem}
\setlist{nolistsep}
\fi
\ifpkuthssextra@opt@pdftoc
% Add PDF bookmark for table of contents.
\let\pkuthssextra@tmp@tableofcontents\tableofcontents
\renewcommand{\tableofcontents}{%
\pkuthss@int@pdfmark{\contentsname}{contents}
\pkuthssextra@tmp@tableofcontents%
}
\fi
\ifpkuthssextra@opt@spechap
% This command is used to start a chapter without numbering, and correctly set
% up the headers and footers in the chapter.
\newcommand\specialchap[1]{%
\chapter*{#1}\addcontentsline{toc}{chapter}{#1}
\markboth{#1}{}\phantomsection%
}
\fi
\AtBeginDocument{
\ifpkuthssextra@opt@pkuspace
% Kludge for `tocloft' used with `ctex'.
% <http://bbs.ctex.org/forum.php?mod=redirect&goto=findpost&ptid=43535&pid=310238>.
\renewcommand{\numberline}[1]{%
\settowidth\@tempdimb{#1\hspace{0.5em}}%
\ifdim\@tempdima<\@tempdimb%
\@tempdima=\@tempdimb%
\fi%
\hb@xt@\@tempdima{\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb%
}%
\fi
\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 up 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}
\fi
}
\endinput