2 % wrapfig: for 2 figs in a row, both need to be in same wrapfig
3 % wrapfig doesn't work in a theorem environment, so can't implement dqs and egs as thms
4 % do wrapfig just before first line of a para
5 % I thought it was messing up (positioning too far down) if I used it near a sectioning
6 % command, but that doesn't seem to be the case. Sometimes works if you put it right
7 % above the sectioning command. Other times when I thought it was a problem with the
8 % sectioning command, changing the sectioning command to a styling command didn't help.
10 % example of how to do explanatory text in square brackets to the right of an equation:
12 % v_t = \omega r \qquad . \hfill
13 % \shoveright{\text{[tangential velocity of a point at a}}\\
14 % \text{distance $r$ from the axis of rotation]}
17 % Summary of my sectioning:
18 % \mychapter{}, all words with initial caps in title
19 % \mysection{}, all words with initial caps in title; first section in a chapter needs \mysection[0]{}
20 % \mysubsection[x]{}, only first word in title capitalized
21 % \subsubsection{}, only first in title word capitalized
24 % Subsections and subsubsections are not numbered.
25 % Only capitalize first word of example titles, subsections.
26 % Panels within figures are numbered 1, 2, etc, in 9-point sans.
27 % Figures are numbered within sections. (This could result in high letters,
28 % but doing subsections leads to incongruous starting over from "a.")
29 % All figures have to have captions, since otherwise "c/" looks bare.
30 % Where L&M had a series of panels (a), (b), ..., SN has
31 % a single letter, but a series of panels 1, 2, etc.
32 % Refer to panels as a/1, etc. Panels without captions have (1), ... inside the figure.
33 % Text within figures is 10-point Helvetica, except labels 1, 2, etc. All text within figures
34 % is upright, even math variables.
35 % Punctuation after displayed equations: \qquad in between.
36 % Subscripts are italic, since this is what LaTeX makes it easy for me to do.
37 % Equation numbers, when used, go on the left, to allow room for notes on the
38 % right. Equation numbers are in square brackets,
39 % numbered within sections.
40 % Problem with equation numbers in examples: not indented, and not in sans.
42 % mysection makes a pagebreak by default, but can give it an optional parameter
43 % to make it less likely to happen.
44 % subsection environment makes a pagebreak[3] by default, which usually doesn't result
45 % in a pagebreak, but can use optional argument 4 to force it
46 % Introducing page breaks always seems to make equations get spaced out a whole
47 % bunch, which looks stupid. This seems to happen even if I sprinkle
48 % \myeqnspacing all over the place. The solution is to precede the page
49 % break with a \vfill.
50 % Differentials and vectors are upright. Can do bold vectors with \boldmath outside of math mode,
51 % or \mathbf or \boldsymbol in math mode.
52 % In example title, first letter of first word is capitalized.
53 % When an example has more than one part, number them (1), (2),...
55 % Figures mostly in Adobe Illustrator 6 EPS. In some cases, I've saved them as
56 % Illustrator 1 EPS to save space; however, it isn't possible to do this with
57 % figures that have text in them, because, at least on my MacOS 9/X system,
58 % Illustrator gets confused about the fonts. (Also, named colors are lost
59 % in Illustrator 1 EPS.)
61 % I've activated pdflatex's margin kerning feature. For the fonts used in this
62 % book, I decided that the margins appeared straightest when I modified
63 % protcode.tex to use half the amount of margin kerning that was supplied by
64 % default. (One expects this to be completely dependent on the font and size.)
66 \pdfminorversion=
4 % force pdf 1.4 output; http://tex.stackexchange.com/questions/95973/is-pdftex-1-40-13-outputting-malformed-pdfs
68 \NeedsTeXFormat{LaTeX2e
}
69 \ProvidesClass{simple
}
71 \LoadClass[11pt
]{book
}
72 % Note that 11 pt does work with pdflatex, even though 11 pt is not one of the sizes
73 % of CM. I don't know whether it scales up 10 pt or scales down 12 pt, but anyway, it
76 \usepackage[french,english
]{babel
}
78 \RequirePackage{makeidx,wrapfig,fancyhdr,calc,titlesec,titletoc,amssymb,moreverb,ifthen,framed,alphalph,cancel,learn-cmd-syntax,url,xstring,comment,navigator
}
79 \RequirePackage{color}%see pdftex mailing list, 2004 May 22-23
80 %====================== counters =====================================================
81 \newcounter{dqctr
}[subsection
]
82 \newcounter{egctr
}[chapter
]
83 \newcounter{scctr
}[chapter
]
84 \newcounter{hwctr
}[chapter
]
86 \StartSaveCommands % for learn-cmd-syntax
88 \RequirePackage{lmlanguage,lmlayout,lmfigs,lmenvironments,lmmath
}
91 \renewcommand{\sfdefault}{phv
}
92 % ... helvetica for sans serif; this has to come before sansmath.sty
93 \RequirePackage[EULERGREEK
]{sansmath
}
94 % ... sansmath.sty by Donald Arseneau, to be released ca. 3/2002.
95 % The EULERGREEK option is necessary with Helvetica, because otherwise
96 % there is no uppercase Greek. He actually doesn't recommend using sansmath.sty
97 % with Helvetica, since some of the symbols match the letters poorly, but
98 % I had hundreds of preexisting figures with Helvetica in them.
99 \RequirePackage[leqno
]{amsmath
}
100 \RequirePackage[absolute
]{textpos
}% ---- http://nxg.me.uk/dist/textpos/
101 % The following line is for margin kerning. There is more stuff
102 % relating to margin kerning after the begin{document}, and that's
103 % where to go if I want to turn it off.
104 \newboolean{wantmarginkerning
}
105 \setboolean{wantmarginkerning
}{true
}
106 \newcommand{\inputprotcode}{\ifthenelse{\boolean{wantmarginkerning
}}{\input protcode.tex
}{}}
108 \definecolor{shadecolor
}{gray
}{.85} % for framed.sty
110 %=====================================================================================
111 % In DP, we use italics for figref, but in LM that would look too much like an algebra
112 % symbol, so no italics.
113 \newcommand{\formatfigref}[1]{#1}
116 %========================= sans serif math stuff =========================
117 % sansmath.sty takes care of it. The following is just to get back to normal
119 \newcommand{\lmserifmath}{\mathversion{normal
}\everymath{}\everydisplay{}}
120 %========================= design =========================
121 \definecolor{subsecnumgray
}{gray
}{.55}
122 \newcommand{\showsubsecnum}[1]{\color{subsecnumgray
}#1} % <----------- caused mysterious errors in Acrobat, starting April 2004 -- why????
125 \titleformat{\part}[display
]
126 {\normalfont\huge\bfseries\sffamily}{Part
\thepart}{0mm
}{\Huge}
127 \titleformat{\chapter}[display
]
128 {\normalfont\huge\bfseries\sffamily}{Chapter
\thechapter}{0mm
}{\Huge}
129 \titleformat{\section}
130 {\normalfont\Large\bfseries\sffamily}{\showsubsecnum{\thesection}}{0.6em
}{}
131 \titleformat{\subsection}
132 {\normalfont\normalsize\bfseries\sffamily}{\showsubsecnum{\thesubsection}}{0.6em
}{}
133 \titleformat{\subsubsection}
134 {\normalfont\normalsize\slshape}{\thesubsubsection}{1em
}{}
136 \titlespacing*
{\chapter}{0mm
}{4mm
}{6mm
}
137 \titlespacing*
{\chapter}{0mm
}{4mm
}{6mm
}
138 \titlespacing*
{\section}{0mm
}{4mm
}{0mm
}
139 \titlespacing{\subsection}{0mm
}{1mm
}{-
0.5mm
}
140 \titlespacing{\subsubsection}{0mm
}{1mm
}{-
0.5mm
}
142 \newcommand{\formatlikechapter}[1]{\huge{\bfseries{\sffamily{#1}}}\normalsize\normalfont}
143 \newcommand{\formatlikesection}[1]{\Large{\bfseries{\sffamily{#1}}}\normalsize\normalfont}
144 \newcommand{\formatlikesubsection}[1]{\bfseries{\sffamily{#1}}\normalsize\normalfont}
145 \newcommand{\formatlikesubsubsection}[1]{\textsl{#1}\normalsize\normalfont}
148 \newcommand{\summarych}[2]{\noindent\formatlikesection{Chapter
\ref{#1},
#2, page
\pageref{#1}}\label{summary
#1}\\
}
149 \newcommand{\sumem}[1]{\emph{#1}}
152 \newcommand{\hwanshdr}[1]{\noindent\textbf{Page
\pageref{hw:
#1}, problem
\ref{hw:
#1}:
}\
}
153 \newcommand{\hwsolnhdr}[1]{\noindent\textbf{Page
\pageref{hw:
#1}, problem
\ref{hw:
#1}:
}\label{soln:
#1}\
}
154 \newcommand{\scanshdr}[1]{\noindent\textbf{Page
\pageref{sc:
#1}:
}\
\label{scans:
#1}}
156 %-------------------- fancyhdr -------------------
157 \newcommand{\yesiwantarabic}{\renewcommand{\thepage}{\arabic{page
}}}
158 \renewcommand{\headrulewidth}{0mm
}
159 \renewcommand{\footrulewidth}{0mm
}
160 %\setlength{\headrulewidth}{0mm}
161 \newcommand{\printthesection}{Section\
\thesection} % for titlesec, hw environment
162 % LaTeX companion, p. 96
163 % Force headings outward, so they're not confined to text column:
164 \setlength{\headwidth}{\textwidth}
165 \addtolength{\headwidth}{\marginfigoverhang}
166 \newlength{\myfooterspace}
167 \setlength{\myfooterspace}{5mm
}
168 \newlength{\myfooterspacep}
169 \setlength{\myfooterspacep}{19mm
}
171 \renewcommand{\chaptermark}[1]%
172 {\markboth{\textsf{Chapter\
\thechapter\hspace{\myfooterspace}#1}}{}}
173 \renewcommand{\sectionmark}[1]%
174 {\markright{\textsf{\printthesection\hspace{\myfooterspace}#1}}{}}
175 %\newcommand{\myheadertext}{\textsf{PRELIMINARY VERSION}}
176 \newcommand{\myheadertext}{}
177 \lhead[\myheadertext]{}
179 \rhead[]{\myheadertext}
180 \lfoot[\textbf{\textsf{\thepage}} \hspace{\myfooterspacep} \nouppercase{\textsf{\leftmark}}]{}
182 \rfoot[]{\nouppercase{\textsf{\rightmark}} \hspace{\myfooterspacep} \textbf{\textsf{\thepage}}}
183 \fancypagestyle{plain
}{%
185 %\fancyfoot[R]{\textbf{\textsf{\thepage}}}%
187 %-------------------- epigraph commands -------------------
188 \newcommand{\epigraphlong}[2]{
190 \noindent{}\myindented{10mm
}{\textit{#2}}
193 \newcommand{\epigraph}[2]{
194 #1 \hspace*
{\fill}\nolinebreak[1]\hspace*
{\fill}\textit{#2}
196 %...based on an example on p. 443 of LaTeX Companion
197 \newcommand{\mysection}[2][4]{\pagebreak[#1]\zapcounters\section{#2}\myeqnspacing\normalcaptions}
198 \newcommand{\myoptionalsection}[2][4]{\pagebreak[#1]\section{$
\star$
#2}\myeqnspacing}
199 \newcommand{\mysubsection}[2][4]{\pagebreak[#1]\subsection{#2}}
200 \newcommand{\myoptionalsubsection}[2][3]{\pagebreak[#1]\subsection{$
\star$
#2}}
201 %-------------------- homework remark -------------------
202 \newcommand{\hwremark}[1]{\par\noindent\footnotesize{\textit{Remark:\/
} #1}}
203 %-------------------- photo credit command -------------------
204 \newcommand{\photocredit}[1]{\footnotesize{(
\textit{#1})
}}
205 %-------------------- theorem header -------------------
206 \newcommand{\mythmhdr}[1]{\noindent\textbf{#1:
}}
208 %-------------------- counters -------------------
209 \newcounter{figctr
}[section
] % for my roll-your-own captions
210 \newcounter{appendixctr
}
211 \renewcommand{\thefigctr}{\alphalph{\value{figctr
}}}
212 %-------------------- equation numbering -------------------
213 \numberwithin{equation
}{section
}
214 % Equation numbers have square brackets:
215 % Original code from amsmath.sty:
216 % \def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
217 % Change it as follows:
218 \renewcommand{\tagform@
}[1]{\maketag@@@
{[\ignorespaces#1\unskip\@@italiccorr
]}}
219 % Use \eqref to refer to an equation.
220 %\renewcommand{\theequation}{\ensuremath{\fnsymbol{equation}}} % used to use symbols...
221 \renewcommand{\theequation}{\ensuremath{\arabic{equation
}}} % ... now using numbers
222 %-------------------- end-of-chapter boilerplate -------------------
223 \newcommand{\backofchapterboilerplate}[1]{%
224 \par\noindent\emph{This chapter is summarized on page
\pageref{summarych:
#1}. Notation and
225 terminology are tabulated on pages
\pageref{notationcompared
}-
\pageref{notationtable
}.
}\par
227 %---------------- dqs
228 \newcommand{\dqheaderformat}[1]{\pagebreak[1]\noindent\formatlikesubsection{#1}\nopagebreak\par}
229 \newcommand{\startdq}{\dqheaderformat{Discussion Question
}}
230 \newcommand{\startdqs}{\dqheaderformat{Discussion Questions
}}
231 \newcommand{\startdqswithintro}[1]%
232 {\pagebreak[1]\noindent\formatlikesubsection{Discussion Questions
}\nopagebreak\noindent{\small\sffamily\nopagebreak\\*
\noindent #1}}
233 \newenvironment{dq
}{%
234 \refstepcounter{dqctr
}\noindent\small\sffamily\textbf{\thedqctr}\myeqnspacing\protect\sansmath%
235 \setlength{\parindent}{0mm
}%undone by normalparafmt
239 \lmserifmath\par\myeqnspacing
241 \renewcommand{\thedqctr}{\Alph{dqctr
}}
242 %-------------------- hw section & hw problem environments-------------------
243 \newcommand{\hwdifficulty}{0}
244 % ... This needs to be a global variable because I only display the symbol in \end{hw},
245 % which doesn't have access to #1.
246 \newsavebox{\hwtrailingstuff}
247 % There is also a boolean register, hwhavetrailing, defined under AtBeginDocument.
249 \newenvironment{hwsection
}[1][Problems
]{\newpage
250 \setcounter{secnumdepth
}{0}%
251 \renewcommand{\printthesection}{}%
252 \setcounter{figure
}{0}%
254 \renewcommand{\addcontentsline}[3]{}% temporarily disable \addcontentsline
258 The symbols
\hwcheckmark,
\displayhwdifficulty{1}, etc.
259 are explained on page
\pageref{hwsymbols
\chapdir}.
}
260 {\noindent \vfill\noindent\emph{Key to symbols:
}\label{hwsymbols
\chapdir} \\
261 \displayhwdifficulty{0} easy
\quad
262 \displayhwdifficulty{1} typical
\quad
263 \displayhwdifficulty{2} challenging
\quad
264 \displayhwdifficulty{3} difficult
\quad
265 \displayhwdifficulty{4} very difficult \\
266 \hwcheckmark \quad An answer check is available at www.lightandmatter.com.
268 \setcounter{secnumdepth
}{2}%
270 % ... The \setcounter{secnumdepth} stuff is the way the author of titlesec suggests doing
271 % this. Using section* messes up footers & toc.
273 \newcommand{\currenthwlabel}{}
274 \newcommand{\calccrud}{}
275 \newenvironment{homework
}[3]
276 {\refstepcounter{hwctr
}\label{hw:
#1}\noindent\textbf{\thehwctr}%
277 \renewcommand{\hwdifficulty}{#2}%
278 \hwcleartrailingstuff
279 \renewcommand{\currenthwlabel}{#1}
281 \renewcommand{\calccrud}{}
282 \ifthenelse{\equal{#3}{1}}{\renewcommand{\calccrud}{\hwaddtrailingstuff{$
\int$
}}}{}
286 \hwaddtrailingstuff{%
287 \displayhwdifficulty{\hwdifficulty}
289 \hwflushtrailingstuff\par%
291 \newenvironment{homeworkforcelabel
}[4]
292 {\renewcommand{\@currentlabel
}{#4}\label{hw:
#1}\noindent\textbf{#4}%
293 \renewcommand{\hwdifficulty}{#2}%
294 \hwcleartrailingstuff
295 \renewcommand{\currenthwlabel}{#1}
297 \renewcommand{\calccrud}{}
298 \ifthenelse{\equal{#3}{1}}{\renewcommand{\calccrud}{\hwaddtrailingstuff{$
\int$
}}}{}
302 \hwaddtrailingstuff{%
303 \displayhwdifficulty{\hwdifficulty}
305 \hwflushtrailingstuff\par%
308 \newcommand{\hwendpart}[1][3]{\hwflushtrailingstuff[#1]\\
}
309 % The optional argument ends up being passed to \nolinebreak. It defaults to 3, but
310 % you can make it 2 or 4 if it seems to be making the wrong decision.
311 % If there is only one part to the problem, or if you're fiddling with the very last
312 % part of a multipart problem, I think you can add a gratuitous \hwendpart, but
313 % except in this situation, don't do \hwendpart after the last part, because sometimes
314 % it causes extra blank lines to appear.
316 \newcommand{\hwhint}[1]{\hwaddtrailingstuff{\hwtriangle\ Hint, p.
\pageref{#1}}}
317 \newcommand{\hwans}[1]{\hwaddtrailingstuff{\hwtriangle\ Answer, p.
\pageref{#1}}}
318 \newcommand{\hwsoln}{\hwaddtrailingstuff{\hwtriangle\ Solution, p.
\pageref{soln:
\currenthwlabel}}}
319 \newcommand{\answercheck}{\hwaddtrailingstuff{\hwcheckmark}}
320 \newcommand{\displayhwdifficulty}[1]{\includegraphics{resources/difficulty
#1}}
322 \newcommand{\hwtriangle}{$
\triangleright$
}
323 \newcommand{\hwcheckmark}{\scriptsize\raisebox{1mm
}{$
\surd$
}\normalsize}
325 \newcommand{\hwflushtrailingstuff}[1][3]{\ifthenelse{\boolean{hwhavetrailing
}}{\hwfill{#1}\usebox{\hwtrailingstuff}\hwcleartrailingstuff}{}}
327 \newcommand{\hwcleartrailingstuff}{\sbox{\hwtrailingstuff}{}\setboolean{hwhavetrailing
}{false
}}
329 \newcommand{\hwaddtrailingstuff}[1]{\sbox{\hwtrailingstuff}{\usebox{\hwtrailingstuff}\quad{}#1}%
330 \setboolean{hwhavetrailing
}{true
}}
332 \newcommand{\hwfill}[1]{\hspace*
{\fill}\nolinebreak[#1]\nopagebreak[1]\hspace*
{\fill}}
333 % ... cf LaTeX Companion, p. 443
336 \newcommand{\scans}[1]{$
\triangleright$\ Answer, p.
\pageref{scans:
#1}}
337 %=========================
339 % used for exercises in SN, based on hw section
340 % There is something similar called handson in LM.
342 \newenvironment{exsection
}{
343 \setcounter{secnumdepth
}{0} % Don't number this section.
344 \renewcommand{\printthesection}{} % Footers should read ``Exercises,'' not ``Section X.Y Exercises''
345 \hwcaptions % figures in ex section don't have a, b, c, labels
346 \setcounter{figure
}{0} %
348 \onecolumn % I don't understand why this is necessary, but it is. If I don't do it, no change in format occurs.
349 \setlength{\parindent}{0mm
} % undone by normalparafmt
350 \mysection{Exercises
} % Has the side-effect of generating a page break.
351 \setcounter{secnumdepth
}{2} % Start numbering sections again.
352 % The \setcounter{secnumdepth} stuff is the way the author of titlesec suggests doing
353 % this. Using section* messes up footers & toc.
356 \vfill\normallayout\normalparafmt %
357 \onecolumn % See above.
359 \newcommand{\extitle}[2]{%
360 \noindent\formatlikesubsection{Exercise
\thechapter{}#1:
#2}
363 %=========================
364 \newcommand{\mynormaltype}{\normalsize\normalfont\myeqnspacing}
365 \newcommand{\myeqnspacing}{
366 \setlength{\abovedisplayskip}{4mm plus
1mm minus
3mm
}
367 \setlength{\belowdisplayskip}{4mm plus
1mm minus
3mm
}
368 \setlength{\abovedisplayshortskip}{0mm plus
1mm
}
369 \setlength{\belowdisplayshortskip}{2mm plus
1mm minus
1mm
}
371 %==============================toc==================================
372 \newcommand{\link}[2]{\protect\jumplink{anchor-
#1}{\textcolor{blue
}{#2}}} % navigator package
373 \newcommand{\brieftocentry}[3][\quad]% #1=\hfill (LM and Me.) or \quad (other books), #2=label, #3=title,
374 {\ref{#2} &
#3 #1 \pageref{#2}}
375 \newcommand{\brieftocentrywithlink}[3][\quad]% #1=\hfill (LM and Me.) or \quad (other books), #2=label, #3=title,
376 {\link{#2}{\ref{#2}} &
\link{#2}{#3} #1 \link{#2}{\pageref{#2}}}
377 \newcommand{\toclinewithlink}[4]% #1=subsection, etc., #2=label, #3=title, #4=\thesubsection, etc.
379 \addcontentsline{toc
}{#1}{\protect\numberline{#4}\link{#2}{#3}}%
381 \newcommand{\toclinewithoutlink}[4]% #1=subsection, etc., #2=label, #3=title, #4=\thesubsection, etc.
383 \addcontentsline{toc
}{#1}{\protect\numberline{#4}#3}%
385 \newcommand{\formatchtoc}[3]{%
386 \titlecontents{chapter
}[0mm
]{\addvspace{#3}\sffamily}%
387 {\contentsmargin{0mm
}#1\thecontentslabel\enspace#1}%
388 {\contentsmargin{0mm
}#1}{#2}[]%
391 \titlecontents{part
}[0mm
]{\addvspace{5mm
}\sffamily\bfseries}
392 {\contentsmargin{0mm
}\bfseries\Large{}\thecontentslabel\enspace\Large}
393 {\contentsmargin{0mm
}\Large}{}[\addvspace{2mm
}]
394 \titlecontents{section
}[0mm
]{\sffamily}
395 {\contentsmargin{0mm
}\thecontentslabel\enspace}
396 {}{\titlerule*
[4mm
]{.
}\contentspage}
397 % In the following, titlecontents* is titletoc's way of saying I want subsections listed in a single paragraph.
398 \titlecontents*
{subsection
}[1.5em
]{\small}{}%
399 {}{,
\thecontentspage}[.---
][.
]
400 \titlecontents{subsubsection
}[]{}{}{}{}[]
401 %========================= graphicx package=========================
402 \usepackage{graphicx}
403 %========================= AtBeginDocument stuff=========================
405 \newboolean{hwhavetrailing
}
406 \DeclareGraphicsExtensions{.pdf,.jpg,.png
}
407 \newcommand{\chapdir}{glub
}
409 % This gets reset any time I do normalsize, so have to do it after preamble,
410 % and have to use \mynormaltype rather than \normalsize
413 \StopSaveCommands % for learn-cmd-syntax
414 \WriteSaveCommands % for learn-cmd-syntax