misc fixes to LM
[light-and-matter.git] / lmcommon.sty
blob54a16c4e9d332954a24d8b5f2dd276164e626e81
1 % lmcommon.sty
2 % This is meant to contain code shared by all my books. Stuff that's not applicable to DP and SN
3 % goes in lmseries.cls. However, not all shared code is in here; some is in
4 % lmfigs.sty, ... I haven't actually made DP and SN use this yet, and I
5 % always tried to err on the side of putting too much in here, so there is
6 % undoubtedly some stuff in here that is actually not appropriate to share with
7 % SN and DP. In particular, I left a bunch of hw stuff in here (difficulty symbols,...)
8 % that is not right for SN. Rather then making SN and DP use this, what's turning out
9 % to be more practical is to take functionality out of this file and put it in small,
10 % maintainable chunks, which are then used by all the books.
12 % notes on wrapfig:
13 % wrapfig: for 2 figs in a row, both need to be in same wrapfig
14 % wrapfig doesn't work in a theorem environment, so can't implement dqs and egs as thms
15 % do wrapfig just before first line of a para
16 % I thought it was messing up (positioning too far down) if I used it near a sectioning
17 % command, but that doesn't seem to be the case. Sometimes works if you put it right
18 % above the sectioning command. Other times when I thought it was a problem with the
19 % sectioning command, changing the sectioning command to a styling command didn't help.
21 % example of how to do explanatory text in square brackets to the right of an equation:
22 % \begin{multline*}
23 % v_t = \omega r \qquad . \hfill
24 % \shoveright{\text{[tangential velocity of a point at a}}\\
25 % \text{distance $r$ from the axis of rotation]}
26 % \end{multline*}
27 % For really long notes, use longnoteafterequation environment.
29 % Summary of my sectioning:
30 % \mychapter{}, all words with initial caps in title
31 % \mysection{}, all words with initial caps in title; first section in a chapter needs \mysection[0]{}
32 % \begin{envsubsection}{} or \begin{envsubsection}[x]{}, only first word in title capitalized
33 % \subsubsection{}, only first in title word capitalized
35 % Notes about design:
36 % Subsections and subsubsections are not numbered.
37 % Only capitalize first word of example titles, subsections.
38 % Subfigures are numbered 1, 2, etc, in 9-point Helv, captions labeled like "1" or "1. blah"
39 % Figures are numbered within sections. (This could result in high letters,
40 % but doing subsections leads to incongruous starting over from "a.")
41 % All figures have to have captions, since otherwise "c/" looks bare.
42 % Where L&M had a series of panels (a), (b), ..., SN has
43 % a single letter, but a series of subfigures 1, 2, etc.
44 % Refer to subfigs as a/1, etc. Subfigs without captions have (1), ... inside the figure.
45 % Text within figures is 10-point Helvetica, except labels 1, 2, etc. All text within figures
46 % is upright, even math variables.
47 % Punctuation after displayed equations: \qquad in between.
48 % Subscripts are italic, since this is what LaTeX makes it easy for me to do.
49 % Equation numbers, when used, go on the left, to allow room for notes on the
50 % right. Equation numbers are in square brackets,
51 % numbered within sections.
52 % Problem with equation numbers in examples: not indented, and not in sans.
53 % page breaks:
54 % mysection makes a pagebreak by default, but can give it an optional parameter
55 % to make it less likely to happen.
56 % subsection environment makes a pagebreak[3] by default, which usually doesn't result
57 % in a pagebreak, but can use optional argument 4 to force it
58 % Introducing page breaks always seems to make equations get spaced out a whole
59 % bunch, which looks stupid. This seems to happen even if I sprinkle
60 % \myeqnspacing all over the place. The solution is to precede the page
61 % break with a \vfill.
62 % Differentials and vectors are upright. Can do bold vectors with \boldmath outside of math mode,
63 % or \mathbf or \boldsymbol in math mode.
64 % Paragraph indentation: Turning off paragraph indentation gives a cleaner look, because
65 % everything on the page is a nice rectangle. However, in the main text, turning it
66 % off makes the page look scarier: your eye doesn't see any landmarks. Also, if para
67 % indentation is turned off, your only cues for seeing para divisions is the extra space
68 % between them, and then equations look like paragraph breaks. Decision: leave 6 mm
69 % paragraph indentation in main text, but turn it off in most other places (examples,
70 % self-checks, homework problems, exercises).
71 % In example title, first letter of first word is capitalized.
72 % When an example has more than one part, number them (1), (2),...
74 % Figures mostly in Adobe Illustrator 6 EPS. In some cases, I've saved them as
75 % Illustrator 1 EPS to save space; however, it isn't possible to do this with
76 % figures that have text in them, because, at least on my MacOS 9/X system,
77 % Illustrator gets confused about the fonts. (Also, named colors are lost
78 % in Illustrator 1 EPS.)
80 % I've activated pdflatex's margin kerning feature. For the fonts used in this
81 % book, I decided that the margins appeared straightest when I modified
82 % protcode.tex to use half the amount of margin kerning that was supplied by
83 % default. (One expects this to be completely dependent on the font and size.)
85 \RequirePackage{mytocloft,titlesec,titletoc,multicol,makeidx,wrapfig,fancyhdr,calc,amssymb,moreverb,ifthen,lmmath,mathrsfs,framed,alphalph,cancel,tipa,xstring,comment,shaddap,navigator}
86 % used to include isolatin1, but now that causes error?
87 \RequirePackage{color}% ---- see pdftex mailing list, 2004 May 22-23
88 %------------------------------------------------
89 % Notes:
90 % tocloft -- Using this has the effect, which I want, of suppressing the mandatory clearpage before the table of contents.
91 \renewcommand{\sfdefault}{phv}
92 % ... helvetica for sans serif; this has to come before sansmath.sty
93 \RequirePackage[EULERGREEK]{sansmath}
94 % The EULERGREEK option is necessary with Helvetica, because otherwise
95 % there is no uppercase Greek. He actually doesn't recommend using sansmath.sty
96 % with Helvetica, since some of the symbols match the letters poorly, but
97 % I had hundreds of preexisting figures with Helvetica in them.
98 \RequirePackage[leqno]{amsmath}
99 \usepackage[french,english]{babel}
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}{.9} % for framed.sty
110 \newcommand{\degfunit}{\degunit\textup{F}}
112 % ----------------
113 \newcommand{\zerosizebox}[3]{
114 \makebox[0mm][l]{%
115 \hspace{#1}%
116 \raisebox{0mm}[0mm][0mm]{% used to have #2 as 1st arg, but it went the wrong direction!
117 \makebox[0mm][l]{%
118 \begin{minipage}{8.5in}
119 \vspace{#2}#3
120 \end{minipage}%
125 % ----------------
126 \newcommand{\widelayout}{\nomarginlayout\onecolumn\setlength{\parindent}{0mm}}
127 \newcommand{\getreadyforbackmatter}{\widelayout}
129 %-------------------- counters -------------------
130 \newcounter{figctr}[chapter] % for my roll-your-own captions
131 \newcounter{appendixctr}
132 \newcounter{labctr}[chapter]
133 \newcounter{labpartctr}[section]
134 \newcounter{prelabctr}[section]
136 \renewcommand{\thedqctr}{\Alph{dqctr}}
137 \renewcommand{\thefigctr}{\alphalph{\value{figctr}}}
138 \renewcommand{\thelabctr}{\alph{labctr}}
139 \renewcommand{\thelabpartctr}{\Alph{labpartctr}\quad}
141 %-------------------- numbered equations ----------------
142 \newenvironment{numberedequations}{\setcounter{equation}{0}}{}
144 \newcommand{\photocreditsboilerplate}{%
145 Except as specifically noted below or in a parenthetical credit in the
146 caption of a figure, all the illustrations in this book are
147 under my own copyright, and are copyleft licensed under the same license
148 as the rest of the book.
150 In some cases it's clear from the date that the
151 figure is public domain, but I don't know the name of the artist or photographer; I would
152 be grateful to anyone who could help me to give proper credit.
153 I have assumed that images
154 that come from U.S. government web pages are copyright-free, since products
155 of federal agencies fall into the public domain.
156 I've included some
157 public-domain paintings; photographic reproductions of them are not
158 copyrightable in the U.S. (Bridgeman Art Library, Ltd. v. Corel Corp.,
159 36 F. Supp. 2d 191, S.D.N.Y. 1999).
161 When ``PSSC Physics'' is given as a credit, it indicates that the figure
162 is from the first edition of the textbook entitled Physics, by the
163 Physical Science Study Committee.
164 The early editions of these books never had their copyrights renewed, and
165 are now therefore in the public domain. There is also
166 a blanket permission given in the later PSSC College Physics edition, which states
167 on the copyright page that ``The materials taken from the original and second
168 editions and the Advanced Topics of PSSC PHYSICS included in this text
169 will be available to all publishers for use in English after December 31, 1970,
170 and in translations after December 31, 1975.''
172 Credits to Millikan and Gale refer to the textbooks Practical Physics (1920) and
173 Elements of Physics (1927). Both are public domain. (The 1927 version did not have
174 its copyright renewed.) Since it is possible that some of the illustrations in
175 the 1927 version had their copyrights renewed and are still under copyright, I
176 have only used them when it was clear that they were originally taken from public
177 domain sources.
179 In a few cases, I have made use of images under the fair use doctrine. However,
180 I am not a lawyer, and the laws on fair use are vague, so you should not assume
181 that it's legal for you to use these images. In particular, fair use law may
182 give you less leeway than it gives me, because I'm using the images for
183 educational purposes, and giving the book away for free. Likewise, if the
184 photo credit says ``courtesy of ...,'' that means the copyright owner gave
185 me permission to use it, but that doesn't mean you have permission to use it.}
187 \newcommand{\dedication}[1]{\zerosizebox{0mm}{140mm}{#1}}
188 %========================= sans serif math stuff =========================
189 % sansmath.sty takes care of it. The following is just to get back to normal
190 % math mode:
191 \newcommand{\lmserifmath}{\mathversion{normal}\everymath{}\everydisplay{}}
192 %========================= design =========================
193 \definecolor{secnumgray}{gray}{.55}
194 \newcommand{\showsecnum}[1]{\color{secnumgray}#1}
196 \titlespacing*{\chapter}{0mm}{4mm}{6mm}
197 \titlespacing*{\section}{0mm}{4mm}{0mm}
198 \titlespacing{\subsection}{0mm}{1mm}{-0.5mm}
199 \titlespacing{\subsubsection}{0mm}{1mm}{-0.5mm}
201 \newcommand{\formatlikechapter}[1]{\huge{\bfseries{\sffamily{#1}}}\normalsize\normalfont}
202 \newcommand{\formatlikesection}[1]{\vspace{2.5mm}\Large{\bfseries{\sffamily{#1}}}\normalsize\normalfont}
203 \newcommand{\formatlikesubsection}[1]{\bfseries{\sffamily{#1}}\normalsize\normalfont}
204 \newcommand{\formatlikesubsubsection}[1]{\textsl{#1}\normalsize\normalfont}
206 \newcommand{\startscanswers}[1]{\pagebreak[4]\noindent\formatlikesection{\langscansch{} \ref{#1}}\nopagebreak\par}
207 \newcommand{\dqheaderformat}[1]{\pagebreak[1]\noindent\formatlikesubsection{#1}\nopagebreak\par}
208 \newcommand{\startdq}{\dqheaderformat{\langdq}}
209 \newcommand{\startdqs}{\dqheaderformat{\langdqs}}
210 \newcommand{\startdqswithintro}[1]%
211 {\pagebreak[1]\noindent\formatlikesubsection{\langdqs}\nopagebreak\noindent{\small\sffamily\nopagebreak\\*\noindent #1}}
212 \newenvironment{dq}{%
213 \refstepcounter{dqctr}\noindent\small\sffamily\textbf{\thedqctr}\myeqnspacing\protect\sansmath%
214 \setlength{\parindent}{0mm}%undone by normalparafmt
217 \normalparafmt
218 \lmserifmath\par\myeqnspacing
221 %Summary appendix:
222 \newcommand{\summarych}[2]{\noindent\formatlikesection{Chapter \ref{#1}, #2, page \pageref{#1}}\label{summary#1}\\}
223 \newcommand{\sumem}[1]{\emph{#1}}
225 \newcommand{\hwanssection}[1]{\vspace{4mm}\noindent\formatlikesection{#1}}
227 \newcommand{\beginsolutions}[1]{\pagebreak[3]\vspace{2mm}\noindent\formatlikesubsection{\langsolforch{} \ref{ch:#1}}\\*}%Solutions for Chapter
228 \newcommand{\beginanswers}[1]{\pagebreak[3]\vspace{2mm}\noindent\formatlikesubsection{Answers for chapter \ref{ch:#1}}\\*}%Answers for Chapter
229 \newcommand{\beginscanswers}[1]{\pagebreak[3]\vspace{2mm}\noindent\formatlikesubsection{\langscansch{} \ref{ch:#1}}\\*}%Answers to Self-Checks for Chapter
231 \newcommand{\kludgyblankfooter}{\thispagestyle{plain}}
232 \newcommand{\hwsolnhdr}[1]{\kludgyblankfooter\noindent\textbf{\langpage{} \pageref{hw:#1}, \langprob{} \ref{hw:#1}:}\ \label{soln:#1}}% Page xxx, problem yyy.
233 \newcommand{\hwanshdr}[1]{\kludgyblankfooter\noindent\textbf{\langpage{} \pageref{hw:#1}, \langprob{} \ref{hw:#1}:}\ \label{hwans:#1}}% Page xxx, problem yyy.
234 \newcommand{\scanshdr}[1]{\kludgyblankfooter\noindent\textbf{\langpage{} \pageref{sc:#1}, \langselfcheck{} \ref{sc:#1}:}\ \label{scans:#1}}%Page xxx, self check yyy.
235 \newcommand{\hinthdr}[1]{\hwanshdr{#1}\label{hwhint:#1}}
237 %-------------------- summary -------------------------
238 \newcommand{\summaryleaders}{\leaders\hbox to 0.7 em{\hss.\hss}\hfill}% TeXBook, p. 223
239 \newcommand{\summarysubsectionheader}[1]{\noindent\formatlikesubsection{#1}}
240 \newenvironment{summarysubsectiontab}[1]{\summarysubsectionheader{#1}\\*\begin{tabular}{p{30mm}p{77mm}}}{\end{tabular}}
241 % ...............................................................................If I change it so the sum isn't 30+77, have to change all
242 % ............................................................................... summarysectiontabw and vocabw macros, too.
243 \newenvironment{summarysubsectiontabw}[3]{\summarysubsectionheader{#1}\\*\begin{tabular}{p{#2}p{#3}}}{\end{tabular}}
244 % The summary section is supposed to be like any other section, but not numbered.
245 % addtocontents: see Lamport, p. 176
246 \newenvironment{summary}{
247 \vfill % in last section, on previous page
248 \setcounter{secnumdepth}{0} % Don't number this section.
249 \renewcommand{\printthesection}{} % Footers should read ``Summary,'' not ``Section X.Y Summary''
250 \mysection{\langsummary} % Has the side-effect of generating a page break.
251 \setcounter{secnumdepth}{2} % Start numbering sections again.
252 % The \setcounter{secnumdepth} stuff is the way the author of titlesec suggests doing
253 % this. Using section* messes up footers & toc.
255 {\vfill}
257 \newenvironment{vocab}{\begin{summarysubsectiontab}{\langselvocab}}{\end{summarysubsectiontab}}
258 \newenvironment{vocabw}[2]{\begin{summarysubsectiontabw}{\langselvocab}{#1}{#2}}{\end{summarysubsectiontabw}}
259 \newcommand{\vocabitem}[2]{#1\summaryleaders {} & #2\\}
260 \newenvironment{notation}{\begin{summarysubsectiontab}{\langnotation}}{\end{summarysubsectiontab}}
261 \newenvironment{othernotation}{\begin{summarysubsectiontab}{\langothernotation}}{\end{summarysubsectiontab}}
262 \newcommand{\notationitem}[2]{#1\summaryleaders {} & #2\\}
263 \newenvironment{summarytext}[1][Summary]{\ifthenelse{\equal{#1}{}}{}{\summarysubsectionheader{#1}}}{}
264 %...use \begin{summarytext}[] as in ch. 8 of NP, where we don't want Summary twice in a row
265 \newenvironment{exploring}{\summarysubsectionheader{\langexploring}\par}{}
266 \newenvironment{reading}[2]{\noindent {\textbf{#1}}, #2. }{\par}
268 %---------------------------------------------------------------------------------------------------------------------------------------
269 %-------------------- fancyhdr -------------------
270 \newcommand{\yesiwantarabic}{\renewcommand{\thepage}{\arabic{page}}}
271 \renewcommand{\headrulewidth}{0mm}
272 \renewcommand{\footrulewidth}{0mm}
273 %\setlength{\headrulewidth}{0mm}
274 \newcommand{\printthesection}{Section\ \thesection} % for titlesec, hw environment
275 % LaTeX companion, p. 96
276 % Force headings outward, so they're not confined to text column:
277 \setlength{\headwidth}{\textwidth}
278 \addtolength{\headwidth}{\marginfigoverhang}
279 \newlength{\myfooterspace}
280 \setlength{\myfooterspace}{5mm}
281 \newlength{\myfooterspacep}
282 \setlength{\myfooterspacep}{19mm}
283 \pagestyle{fancy}
284 \renewcommand{\chaptermark}[1]%
285 {\markboth{\textsf{Chapter\ \thechapter\hspace{\myfooterspace}#1}}{}}
286 \newcommand{\blankchaptermarks}{
287 \renewcommand{\chaptermark}[1]%
288 {\markboth{}{}}
290 \newcommand{\normalchapters}{%
291 \renewcommand{\thechapter}{\arabic{chapter}}%
292 \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}%
294 \renewcommand{\thepart}{}
295 \newcommand{\optionalchapternote}[1]{\emph{#1}}
296 \renewcommand{\sectionmark}[1]%
297 {\markright{\textsf{\printthesection\hspace{\myfooterspace}#1}}{}}
298 \newcommand{\myheadertext}{}
299 \lhead[\myheadertext]{}
300 \chead[]{}
301 \rhead[]{\myheadertext}
302 \lfoot[\textbf{\textsf{\thepage}} \hspace{\myfooterspacep} \nouppercase{\textsf{\leftmark}}]{}
303 \cfoot[]{}
304 \rfoot[]{\nouppercase{\textsf{\rightmark}} \hspace{\myfooterspacep} \textbf{\textsf{\thepage}}}
305 \fancypagestyle{plain}{%
306 \fancyhf{}% clear everything, except...
307 \fancyfoot[LE,RO]{\textbf{\textsf{\thepage}}} % page numbers on left of even pages, right of odd pages
309 %-------------------- preface
310 \newenvironment{preface}{%
311 \renewcommand{\thesection}{\hspace{-2mm}} % kludge!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
312 \renewcommand{\printthesection}{} % Footers should read ``Preface,'' not ``Section Preface''
315 \renewcommand{\printthesection}{Section\ \thesection} % for titlesec, hw environment
317 \newcommand{\wugga}{\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}}
318 %-------------------- epigraph commands -------------------
319 \newcommand{\epigraphlong}[2]{
320 \noindent{}\myindented{10mm}{\textsf{#1}}\par
321 \noindent{}\hfill \textsf{\textit{#2}}
323 \newcommand{\epigraphlongfitbyline}[2]{
324 \noindent{}\myindented{10mm}{\textsf{#1} \hfill \textsf{\textit{#2}}}
326 \newcommand{\epigraphnobyline}[2]{
327 \noindent{}\myindented{10mm}{\textsf{#1}}
329 \newcommand{\epigraph}[2]{
330 \noindent{}#1 \hspace*{\fill}\nolinebreak[1]\hspace*{\fill}\textit{#2}
332 %...based on an example on p. 443 of LaTeX Companion
333 %-------------------- oneofaseriesofpoints -----------------------------------------------------------
334 % The following is basically like an item in the description environment, but the stuff in bold can
335 % be more than one line:
336 \newcommand{\oneofaseriesofpoints}[2]{\myindented{\egindent}{\noindent\textbf{#1}\ {#2}}\par}
337 %-------------------- homework remark -------------------
338 \newcommand{\hwremark}[1]{\par\noindent\footnotesize{\textit{Remark:\/} #1}}
339 %-------------------- photo credit command -------------------
340 \newcommand{\photocredit}[1]{\footnotesize{(\textit{#1})}}% for use in captions
341 % for use in photo credits appendix:
342 \newcommand{\barecred}[2]{ \emph{#1:} #2.\quad}
343 \newcommand{\docred}[3]{\textbf{#1} \emph{#2:} #3.\quad}
344 \newcommand{\cred}[3]{\docred{\pageref{fig:#1}}{#2}{#3}}
345 \newcommand{\credtwo}[4]{\docred{\pageref{fig:#1},\pageref{fig:#2}}{#3}{#4}}
346 \newcommand{\credthree}[5]{\docred{\pageref{fig:#1},\pageref{fig:#2},\pageref{fig:#3}}{#4}{#5}}
347 %-------------------- theorem header -------------------
348 \newcommand{\mythmhdr}[1]{\noindent\textbf{#1:}}
349 %-------------------- equation numbering -------------------
350 \numberwithin{equation}{section}
351 % Equation numbers have square brackets:
352 % Original code from amsmath.sty:
353 % \def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
354 % Change it as follows:
355 \renewcommand{\tagform@}[1]{\maketag@@@{[\ignorespaces#1\unskip\@@italiccorr]}}
356 % Use \eqref to refer to an equation.
357 %\renewcommand{\theequation}{\ensuremath{\fnsymbol{equation}}} % used to use symbols...
358 \renewcommand{\theequation}{\ensuremath{\arabic{equation}}} % ... now using numbers
359 %-------------------- tuning placement of floating figures -------------------
360 % The following three numbers are to make TeX more likely to put figures on the
361 % same page rather than on a separate figures page. Can tinker with these, but
362 % make sure floatpagefraction<topfraction.
363 % Values recommended by the web page I found were 0.85, 0.1, 0.75
364 \renewcommand{\topfraction}{0.99}
365 \renewcommand{\textfraction}{0.01}
366 \renewcommand{\floatpagefraction}{0.98}
367 %-------------------- hw section & hw problem environments-------------------
368 \newcommand{\hwdifficulty}{0}
369 % ... This needs to be a global variable because I only display the symbol in \end{hw},
370 % which doesn't have access to #1.
371 \newsavebox{\hwtrailingstuff}
372 % There is also a boolean register, hwhavetrailing, defined under AtBeginDocument.
374 % The homework problem section is supposed to be like any other section, but not numbered.
375 % addtocontents: see Lamport, p. 176
376 \newcommand{\displayhwdifficulty}[1]{\ifthenelse{\equal{#1}{2}}{$\star$}{}}
377 \newcommand{\hwtopboilerplate}{%
378 \noindent\formatlikesubsection{\langkey}\\*
379 \begin{tabular}{lll}
380 \hwcheckmark & A computerized answer check is available online. \\
381 $\int$ & A problem that requires calculus. \\
382 \displayhwdifficulty{2} & A difficult problem.
383 \end{tabular}
385 \newenvironment{hwsection}[1][Problems]{
386 \setcounter{secnumdepth}{0} % Don't number this section.
387 \renewcommand{\printthesection}{} % Footers should read ``Problems,'' not ``Section X.Y Problems''
388 \hwcaptions % figures in hw section don't have a, b, c, labels
389 \setcounter{figure}{0} %
390 \begingroup
391 \renewcommand{\addcontentsline}[3]{}% temporarily disable \addcontentsline
392 \mysection{#1} % Has the side-effect of generating a page break.
393 \endgroup
394 \setcounter{secnumdepth}{2} % Start numbering sections again.
395 % The \setcounter{secnumdepth} stuff is the way the author of titlesec suggests doing
396 % this. Using section* messes up footers & toc.
397 \setlength{\parindent}{0mm}%undone by normalparafmt
398 \hwtopboilerplate\par
401 \vfill
402 \normalparafmt
404 \newenvironment{handson}[3]{
405 \setcounter{secnumdepth}{0} % Don't number this section.
406 \renewcommand{\printthesection}{} % Footers should read ``Problems,'' not ``Section X.Y Problems''
407 \hwcaptions % figures in this section don't have a, b, c, labels
408 \setcounter{figure}{0} %
409 \nomarginlayout %
410 #3 % Normally \onecolumn. I don't understand why this is necessary, but it is. If I don't do it, no change in format occurs.
411 \mysection{Exercise \thechapter#1: #2} % Has the side-effect of generating a page break.
412 \setcounter{secnumdepth}{2} % Start numbering sections again.
413 % The \setcounter{secnumdepth} stuff is the way the author of titlesec suggests doing
414 % this. Using section* messes up footers & toc.
415 \setlength{\parindent}{0mm}%undone by normalparafmt
416 \par
419 \vfill
420 \normallayout\normalparafmt\onecolumn
423 \newcommand{\hwnote}[1]{\noindent\emph{#1}}
424 \newcommand{\currenthwlabel}{}
425 \newcommand{\calccrud}{}
426 \newenvironment{homework}[3]
428 \refstepcounter{hwctr}%
429 \begin{homeworkforcelabel}{#1}{#2}{#3}{\thehwctr}
432 \end{homeworkforcelabel}
435 \newenvironment{homeworkforcelabel}[4]
436 {\renewcommand{\@currentlabel}{#4}\label{hw:#1}\noindent\textbf{#4}%
437 \renewcommand{\hwdifficulty}{#2}%
438 \hwcleartrailingstuff
439 \renewcommand{\currenthwlabel}{#1}
440 \quad%
441 \renewcommand{\calccrud}{}
442 \ifthenelse{\equal{#3}{1}}{\renewcommand{\calccrud}{\hwaddtrailingstuff{$\int$}}}{}
445 \calccrud
446 \hwaddtrailingstuff{%
447 \displayhwdifficulty{\hwdifficulty}
449 \hwflushtrailingstuff\par%
452 \newcommand{\hwendpart}[1][3]{\hwflushtrailingstuff[#1]\\}
453 % The optional argument ends up being passed to \nolinebreak. It defaults to 3, but
454 % you can make it 2 or 4 if it seems to be making the wrong decision.
455 % If there is only one part to the problem, or if you're fiddling with the very last
456 % part of a multipart problem, I think you can add a gratuitous \hwendpart, but
457 % except in this situation, don't do \hwendpart after the last part, because sometimes
458 % it causes extra blank lines to appear.
460 \newcommand{\hwhint}[1]{\hwaddtrailingstuff{\hwtriangle\ Hint, p. \pageref{#1}}}
461 \newcommand{\hwans}[1]{\hwaddtrailingstuff{\hwtriangle\ Answer, p. \pageref{#1}}}
462 \newcommand{\hwsoln}{\hwaddtrailingstuff{\hwtriangle\ Solution, p. \pageref{soln:\currenthwlabel}}}
463 \newcommand{\answercheck}{\hwaddtrailingstuff{\hwcheckmark}}
465 \newcommand{\hwtriangle}{$\triangleright$}
466 \newcommand{\hwcheckmark}{\scriptsize\raisebox{1mm}{$\surd$}\normalsize}
468 \newcommand{\hwflushtrailingstuff}[1][3]{\ifthenelse{\boolean{hwhavetrailing}}{\hwfill{#1}\usebox{\hwtrailingstuff}\hwcleartrailingstuff}{}}
470 \newcommand{\hwcleartrailingstuff}{\sbox{\hwtrailingstuff}{}\setboolean{hwhavetrailing}{false}}
472 \newcommand{\hwaddtrailingstuff}[1]{\sbox{\hwtrailingstuff}{\usebox{\hwtrailingstuff}\quad{}#1}%
473 \setboolean{hwhavetrailing}{true}}
475 \newcommand{\hwfill}[1]{\hspace*{\fill}\nolinebreak[#1]\nopagebreak[1]\hspace*{\fill}}
476 % ... cf LaTeX Companion, p. 443
479 \newcommand{\scans}[1]{$\triangleright$\ Answer, p. \pageref{scans:#1}}
480 \newcommand{\noetherimplies}{\ensuremath{\Rightarrow}}
481 \newenvironment{noethertable}{%
482 \noindent\hspace{5mm}\begin{tabular}{|p{40mm}cp{40mm}|}
483 \hline
484 \textbf{symmetry} & & \textbf{conserved quantity} \\
487 \hline
488 \end{tabular}
490 %=========================
491 \newcommand{\mynormaltype}{\normalsize\normalfont\myeqnspacing}
492 \newcommand{\myeqnspacing}{
493 \setlength{\abovedisplayskip}{4mm plus 1mm minus 3mm}
494 \setlength{\belowdisplayskip}{4mm plus 1mm minus 3mm}
495 \setlength{\abovedisplayshortskip}{0mm plus 1mm}
496 \setlength{\belowdisplayshortskip}{2mm plus 1mm minus 1mm}
498 %==============================toc==================================
499 \newcommand{\link}[2]{\protect\jumplink{anchor-#1}{\textcolor{blue}{#2}}} % navigator package
500 \newcommand{\brieftocentry}[3][\quad]% #1=\hfill (LM and Me.) or \quad (other books), #2=label, #3=title,
501 {\ref{#2} & #3 #1 \pageref{#2}}
502 \newcommand{\brieftocentrywithlink}[3][\quad]% #1=\hfill (LM and Me.) or \quad (other books), #2=label, #3=title,
503 {\link{#2}{\ref{#2}} & \link{#2}{#3} #1 \link{#2}{\pageref{#2}}}
504 \newcommand{\toclinewithlink}[4]% #1=subsection, etc., #2=label, #3=title, #4=\thesubsection, etc.
506 \addcontentsline{toc}{#1}{\protect\numberline{#4}\link{#2}{#3}}%
508 \newcommand{\toclinewithoutlink}[4]% #1=subsection, etc., #2=label, #3=title, #4=\thesubsection, etc.
510 \addcontentsline{toc}{#1}{\protect\numberline{#4}#3}%
512 %For the following, see the documentation for tocloft.sty:
513 \renewcommand{\contentsname}{}
514 \setlength{\cftbeforetoctitleskip}{0mm}
515 \setlength{\cftaftertoctitleskip}{0mm}
516 %titletoc stuff:
517 \newcommand{\formatchtoc}[3]{%
518 \titlecontents{chapter}[0mm]{\addvspace{#3}\sffamily}%
519 {\contentsmargin{0mm}#1\thecontentslabel\enspace#1}%
520 {\contentsmargin{0mm}#1}{#2}[]%
522 % Arguments to titlecontents are:
523 % {section}
524 % [left: horizontal space from left margin; is mandatory, even though in square brackets]
525 % {above: global formatting, vertical material allowed}
526 % {before with label: horizontal-mode stuff that occurs before the entry}
527 % {before without label: like the preceding arg, but for entries that do not have any label}
528 % {filler and page: e.g., you can put ... and page # commands here}
529 % [after: stuff that is happens after the entry, vertical material allowed]
530 % titlecontents* has up to three optional args at the tail end
531 % In the following, the -5mm is to get rid of a horizontal space that crops up for reasons I don't understand.
532 \titlecontents{part}%
533 [0mm]% left
534 {\addvspace{5mm}\sffamily\bfseries\noindent}% above
536 {\contentsmargin{0mm}\Large\noindent\hspace{-5mm}}% before without label
537 {}% filler and page
538 [\addvspace{2mm}]% after
539 \contentsmargin{6mm}
540 \titlecontents{section}%
541 [0mm]% left
542 {\sffamily}% above
543 {\contentsmargin{0mm}\thecontentslabel\enspace}% before with label
544 {}% before without label
545 {\titlerule*[4mm]{.}\contentspage}% filler and page
546 % In the following, titlecontents* is titletoc's way of saying I want subsections listed in a single paragraph.
547 \titlecontents*{subsection}%
548 [1.5em]% left
549 {\small}% above
550 {}% before with label
551 {}% before without label
552 {, \thecontentspage}% filler and page
553 [.---]% separator
554 [.]% end
555 \titlecontents{subsubsection}[]{}{}{}{}[]
556 % Brief contents:
557 \titlecontents{briefchapter}[0mm]{\Large\sffamily{}}
558 {}{}
560 %========================= graphicx package=========================
561 \usepackage{graphicx}
562 %========================= AtBeginDocument stuff=========================
563 \AtBeginDocument{
564 \newboolean{hwhavetrailing}
565 %\DeclareGraphicsExtensions{.pdf,.jpg,.png}
566 \input{declaregraphicsextensions.tex}
567 \newcommand{\chapdir}{glub}
568 \myeqnspacing
569 % This gets reset any time I do normalsize, so have to do it after preamble,
570 % and have to use \mynormaltype rather than \normalsize
572 %============= preamble commands such as includeonly, controllable from makefile ==============
573 \input{makefilepreamble}