-
Notifications
You must be signed in to change notification settings - Fork 0
/
nmd-common.sty
117 lines (93 loc) · 3.48 KB
/
nmd-common.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
%% Miscellaneous macros, loaded at the start of each class.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{nmd/nmd-common}[2014/08/31 - Semester start edition]
%%% Switch to turn on Nathan's features if his custom option file exists
\newif\ifnmd
\IfFileExists{user-is-nathan-dunfield}{\nmdtrue}{\nmdfalse}
%%% Trying to make the final code somewhat readable
\RequirePackage{ifthen}
\newcommand{\ifthen}[2]{\ifthenelse{#1}{#2}{\relax}}
\newcommand{\ifnotthen}[2]{\ifthenelse{#1}{\relax}{#2}}
\newcommand{\PassDownOptionToPackage}[2]{\DeclareOption{#1}{\PassOptionsToPackage{#1}{#2}}}
\newcommand{\PassDownOptionToClass}[2]{\DeclareOption{#1}{\PassOptionsToClass{#1}{#2}}}
%%% Macros for PDF formating:
% Strip off the margins for onscreen viewing
\let\trimpdfpages\undefined
\newcommand{\trimpdfpages}[1]{%
\let\remnantmargin\undefined
\newcommand{\remnantmargin}{#1}
% First move the PDF origin to the upper-left
% corner of the text
\setlength{\pdfhorigin}{-\oddsidemargin}
\addtolength{\pdfhorigin}{-\hoffset}
\setlength{\pdfvorigin}{-\topmargin}
\addtolength{\pdfvorigin}{-\voffset}
% Now trim to the minimal page size
\setlength{\pdfpagewidth}{\textwidth}
\setlength{\pdfpageheight}{\textheight}
\addtolength{\pdfpageheight}{\headsep}
\addtolength{\pdfpageheight}{\headheight}
\addtolength{\pdfpageheight}{\footskip}
% Now pad out to the desired margins
\addtolength{\pdfhorigin}{\remnantmargin}
\addtolength{\pdfpagewidth}{\remnantmargin}
\addtolength{\pdfpagewidth}{\remnantmargin}
\addtolength{\pdfvorigin}{\remnantmargin}
\addtolength{\pdfpageheight}{\remnantmargin}
\addtolength{\pdfpageheight}{\remnantmargin}
}
\newcommand{\trimpages}[1]{%
% This test is for compatibility with TikZ's picture
% caching ("externalization") system.
\ifthen{\isundefined{\tikzexternalrealjob}}{%
\AtBeginDocument{\trimpdfpages{#1}}
}
}
% Format for printing on US Letter pages
\newcommand{\printing}[1]{%
\setlength{\textwidth}{#1\textwidth}
\setlength{\textheight}{1.5\textwidth}
\trimpages{0.3cm}
}
\newcommand{\laptop}{%
\setlength{\textheight}{1.2\textwidth}
\trimpages{0.5cm}
}
\newcommand{\bigmonitor}{%
\setlength{\textheight}{1.7\textwidth}
\trimpages{0.5cm}
}
%%% Change float params as per TeX FAQ to make things more flexible.
%%% Once it becomes commonly available, this code could be replaced
%%% with https://ctan.org/pkg/fewerfloatpages but this requires a 2020
%%% or newer version of TeXLive.
\newcommand{\nmd@freefloats}{%
\renewcommand{\topfraction}{.85}
\renewcommand{\bottomfraction}{.7}
\renewcommand{\textfraction}{.15}
\renewcommand{\floatpagefraction}{.66}
\renewcommand{\dbltopfraction}{.66}
\renewcommand{\dblfloatpagefraction}{.66}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}
}
%%% Showing current font sizes, see
\newcommand\nmd@thefontsizeline[2]{#1 #2 & #1 \f@size pt & #1 \f@baselineskip \\}
\newcommand{\showallfontsizes}{%
Here are the current font sizes in \TeX points, i.e. 72.27 pts/inch
\begin{tabular}{ccc}
name & size & baselineskip \\
\nmd@thefontsizeline{\tiny}{tiny}
\nmd@thefontsizeline{\scriptsize}{scriptsize}
\nmd@thefontsizeline{\footnotesize}{footnotesize}
\nmd@thefontsizeline{\small}{small}
\nmd@thefontsizeline{\normalsize}{normalsize}
\nmd@thefontsizeline{\large}{large}
\nmd@thefontsizeline{\Large}{Large}
\nmd@thefontsizeline{\LARGE}{LARGE}
\nmd@thefontsizeline{\huge}{huge}
\nmd@thefontsizeline{\Huge}{Huge}
\end{tabular}
}