misc fixes to LM
[light-and-matter.git] / lmseries.cls
blob69ae8767c746758c30813d986ef632daf2a5a7d6
1 % lmseries.cls
2 % This is meant to contain all code used by Light and Matter that
3 % isn't shared with Discover Physics and Simple Nature.
5 \pdfminorversion=4 % force pdf 1.4 output; http://tex.stackexchange.com/questions/95973/is-pdftex-1-40-13-outputting-malformed-pdfs
7 \NeedsTeXFormat{LaTeX2e}
8 \ProvidesClass{lmseries}
10 \LoadClass[11pt]{book}
11 % Note that 11 pt does work with pdflatex, even though 11 pt is not one of the sizes
12 % of CM. I don't know whether it scales up 10 pt or scales down 12 pt, but anyway, it
13 % works.
14 %====================== counters =====================================================
15 \newcounter{dqctr}[subsection]
16 \newcounter{egctr}[chapter]
17 \newcounter{scctr}[chapter]
18 \newcounter{hwctr}[chapter]
20 \RequirePackage{learn-cmd-syntax,url}
21 \StartSaveCommands % for learn-cmd-syntax
22 % \RequirePackage[hidelinks]{hyperref} % doesn't work correctly, see meki, latex notes
23 \RequirePackage{lmlayout,lmcommon,lmfigs,lmenvironments}
25 %=====================================================================================
26 % In DP, we use italics for figref, but in LM that would look too much like an algebra
27 % symbol, so no italics.
28 \newcommand{\formatfigref}[1]{#1}
30 %========================= title page, and the next few pages =========================
31 \newenvironment{titlepages}[1][1]{%
32 \normalsize\normalfont\pagebreak\thispagestyle{empty}%
33 \ifthenelse{\equal{#1}{2}}{\cleardoublepage\thispagestyle{empty}}{}%
34 }{%
35 \normalsize\normalfont%
38 \newcommand{\titlepagestuff}[9]{%
39 \zerosizebox{#1}{#2}{#3}%
40 \zerosizebox{#4}{#5}{#6}%
41 \zerosizebox{#7}{#8}{#9}%
43 \newcommand{\brieftitle}[1][60mm]{\zerosizebox{#1}{60mm}{\includegraphics{\figprefix\chapdir/figs/title-pretty-big}}}
44 %... 30 pt Helvetica, or 40 pt bitstream vera sans roman
45 \newcommand{\fulltitle}[3]{%
46 \sffamily
47 \zerosizebox{-13mm}{197mm}{\includegraphics{\figprefix\chapdir/figs/title-page-logo-strip}}\par
48 \zerosizebox{-1mm}{#1}{\includegraphics{\figprefix\chapdir/figs/title-pretty-big}}\par% 30 pt Helvetica
49 \zerosizebox{0mm}{#2}{\huge{Benjamin Crowell}}\par
50 \zerosizebox{0mm}{#3}{\huge{www.lightandmatter.com}}\vfill
52 \newcommand{\copyrightpage}[1]{%
53 \zerosizebox{-10mm}{110mm}{
54 \noindent\includegraphics[width=28.3mm]{\figprefix\chapdir/figs/logo}\\
55 Fullerton, California\\
56 www.lightandmatter.com\vspace{10mm}
59 \zerosizebox{-10mm}{140mm}{
60 \noindent{}copyright #1 Benjamin Crowell\vspace{10mm}
63 \zerosizebox{-10mm}{159mm}{
64 rev. \today\vspace{10mm}
67 \zerosizebox{-10mm}{213mm}{
68 \noindent{}\begin{minipage}{100mm}
69 \noindent{}\begin{tabular}{p{9mm}p{95mm}}
70 \zerosizebox{0mm}{14mm}{\anonymousinlinefig{cc-by-sa}} &
71 This book is licensed under the Creative Commons
72 Attribution-ShareAlike license, version 3.0,
73 http://creativecommons.org/licenses/by-sa/3.0/,
74 except for those photographs and
75 drawings of which I am not the author, as listed in the photo credits.
76 If you agree to the license, it grants you certain privileges that
77 you would not otherwise have, such as the right to copy the book,
78 or download the digital version free of charge from
79 www.lightandmatter.com.
80 \end{tabular}
81 \end{minipage}
84 \vfill
86 % titlesec stuff:
87 \titleformat{\part}[display]
88 {\normalfont\Huge\bfseries\sffamily\raggedright}{}{0mm}
89 {\Huge}
90 \titleformat{\chapter}[display]
91 {\normalfont\huge\bfseries\sffamily\raggedright}{Chapter \thechapter}{0mm}
92 {\Huge}
93 \newcommand{\normalsectiontitleformat}{
94 \titleformat{\section}
95 {\normalfont\Large\bfseries\sffamily\raggedright}{\showsecnum{\thesection}}{0.6em}{}
97 \newcommand{\labsectiontitleformat}{
98 \titleformat{\section}
99 {\normalfont\Huge\bfseries\sffamily\raggedright}{\showsecnum{\thesection}}{0.6em}{}
101 \normalsectiontitleformat
102 \titleformat{\subsection}
103 {\normalfont\normalsize\bfseries\sffamily\raggedright\protect\sansmath}{\lmserifmath}{0em}{}
104 %\titleformat{\subsubsection}
105 % {\normalfont\normalsize\textsl}{\thesubsubsection}{1em}{}
106 \titleformat{\subsubsection}
107 {\normalfont\normalsize\slshape\raggedright}{\thesubsubsection}{1em}{}
108 %-------------------- sections and subsections -------------------------
109 % (chapter stuff is in lmfigs.cls, since it contains a lot of stuff for figures)
110 \newcommand{\mysection}[2][4]{\pagebreak[#1]%
111 \section{#2}\myeqnspacing%
112 \setcounter{dqctr}{0}% gets done automatically for subsections, but I need to do it explicitly for sections that have no subsections
114 \newcommand{\mycalcsection}[2][4]{\pagebreak[#1]%
115 \section{$\int$ #2}\myeqnspacing}
116 \newcommand{\myoptionalsection}[2][4]{\pagebreak[#1]%
117 \section{$\star$ #2}\myeqnspacing}
118 \newcommand{\myoptionalcalcsection}[2][4]{\pagebreak[#1]%
119 \section{$\int\star$ #2}\myeqnspacing}
120 \newcommand{\mysubsection}[2][3]{\pagebreak[#1]\subsection{#2}}
121 \newcommand{\myoptionalsubsection}[2][3]{\pagebreak[#1]\subsection{$\star$ #2}}
122 \newcommand{\mysubsectionnotoc}[2][3]{\pagebreak[#1]\subsection*{#2}}
123 \newcommand{\myssssection}[2][3]{\pagebreak[#1]\noindent\ensuremath{\triangleright}\ #2}
124 %-------------------- data table -------------------------
125 \newcommand{\formatdatatabletitle}[1]{\huge{\bfseries{\sffamily{#1}}}\normalsize\normalfont}
126 \newcommand{\formatdatatableheader}[1]{\LARGE{\bfseries{\sffamily{#1}}}\normalsize\normalfont}
127 \newcommand{\twoblankpages}{\hbox{}\newpage\hbox{}\newpage}% assumes one-column layout
128 \newenvironment{datatablepage}{%
129 \onecolumn\clearpage\lmserifmath
130 % header
131 \twocolumn[\begin{center}\formatdatatabletitle{Useful Data}\end{center}]\vspace{8mm}\footnotesize
133 \normalsize
135 \newcommand{\datatableheader}[1]{%
136 \begin{shaded}\begin{center}\formatdatatableheader{#1}\end{center}\end{shaded}%
138 \newenvironment{datatable}[1]{%
139 \datatableheader{#1}
141 \newcommand{\datatablenote}[1]{{\scriptsize #1}}
142 \newcommand{\datatablecolhdr}[1]{\textbf{#1}}
143 %------------------------------------------------------------------------------------------
145 \StopSaveCommands % for learn-cmd-syntax
146 \WriteSaveCommands % for learn-cmd-syntax