Debian Codegraph @

texmf-dist/doc/latex/chs-physics-report/chs-physics-report.tex

raw
1 % !TeX program = XeLaTeX
2 \documentclass[12pt]{ltxdoc}
3
4 \usepackage{amssymb}
5 \usepackage{showexpl}
6 \lstset{%
7 basicstyle=\ttfamily\small,
8 keywordstyle=\ttfamily\small,
9 commentstyle=\itshape\ttfamily\small,
10 numbers = left,
11 numbersep = .5em,
12 numberstyle=\scriptsize\sffamily,
13 breaklines=true,
14 escapeinside={/*}{*/},
15 backgroundcolor=\color{black!10},
16 breakautoindent=true,
17 captionpos=t,
18 language = TeX
19 }
20 \lstdefinestyle{mc}{
21 name=mc,
22 language=[LaTeX]TeX,
23 columns=fullflexible,
24 numbers=left,
25 numberfirstline=1,
26 firstnumber=auto,
27 numbersep=.5em,
28 }
29
30 \usepackage{metalogo}
31
32 \usepackage{booktabs}
33 \usepackage{hyperref}
34 \hypersetup{
35 pdftitle={Lab reports with professionalism: the CHS Physics Report package for LaTeX},
36 pdfauthor={Gary Zhang},
37 pdfnewwindow=true,
38 colorlinks=true,
39 linkcolor=black,
40 urlcolor=blue
41 }
42 \usepackage{chs-physics-report}
43 \geometry{left = 4cm, right = 4cm}
44 \usepackage{fontspec}
45 \setsansfont[Ligatures = TeX]{Calibri}
46 \setmathsf{CMU Sans Serif}
47 \setmonofont[Scale = .9]{Courier New}
48
49 \sectionstyle{\rmfamily\bfseries\Large}
50 \subtitlestyle{\normalsize}
51 \title{\hspace*{-3.25cm}\parbox{\textwidth + 6.5cm}{\centering\fontspec{Latin Modern Roman}[Scale = .93] Writing lab reports with professionalism:\\the CHS Physics Report package}\vspace{2mm}}\makeatletter
52 \author{Gary Zhang\footnoteDuplic@teDuplic@te{\sffamily Correspondence may be sent to \texttt{garyzhang00 \char`\$\char`\@\char`\$\ gmail.com}}}
53
54
55 \def\@workedWith{\\2017-11-23}
56 \def\LaTeX{ L\kern -.21em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.1em\TeX}% Otherwise, it really sucks when viewed in Calibri
57 \makeatother
58
59 \let\sfsum\undefined
60 \let\sfprod\undefined
61 \DeclareMathOperator*{\sfsum}{\fontfamily{lmss}\fontsize{.9cm}{1cm}\selectfont\text{Σ}}
62 \DeclareMathOperator*{\sfprod}{\fontfamily{lmss}\fontsize{.9cm}{1cm}\selectfont\text{\MakeUppercase{π}}}
63
64 \begin{document}
65 \maketitle\vspace{13mm}
66 \sffamily
67
68 \section{Abstract}
69
70
71 The CHS Physics Report package may be used to stylize lab reports written in \LaTeX. The package also provides some useful commands to expedite the process of writing a lab report by providing a commands that are otherwise not very readily available to use in \LaTeX. It is compatible with many other \LaTeX\ packages and may be used, among other possibilities, for reports in physics.
72
73 \section{Introduction}
74
75 I wrote this package in order to accomplish my goal of writing Lab Reports for Mr.\ James' AP Physics C class at Carmel High School. Because all my documents largely took the same form, I wound up writing a package in order to simplify the files I used for writing my reports. As my style of writing lab reports has drawn questions of repeating my successes with lab reports, especially amongst AP Physics 1 students at Carmel High, it looks like I have to write the documentation for this package! \emph{Sigh!}
76
77 In all seriousness though, the intended purpose of this package is to typeset a highly technical document, for any type of science class. Although it is not designed to help to write reports in chemistry and biology, a few additional packages may supply this functionality if desired. Consequently, this package may be a nice little souvenir to keep for your other classes to use to write the professional-appearing reports you need. And you \emph{can} keep it too! That's because the code for the CHS Physics Report package has been released into the public domain through the use of the CC0 license,\footnote{\sffamily A copy of the CC0 license may be found at\\ \url{https://creativecommons.org/publicdomain/zero/1.0/legalcode}.} with the exception of a small segment written by Stefan Kottwitz that I have slightly edited, available under a \href{https://creativecommons.org/licenses/by-sa/3.0/legalcode}{CC BY-SA 3.0 License}. However, although this package may be freely used to write your reports in other AP courses, this package is neither supported nor endorsed by the CollegeBoard, which has no affiliation with this package.
78
79 To install this package, follow the directions found at
80
81 \begin{minipage}{\textwidth - 2\parindent}\url{https://artofproblemsolving.com/wiki/index.php?title=LaTeX:Packages#Making_Your_Own}.\end{minipage}
82
83 To learn how to use \LaTeX,
84 the \href{https://artofproblemsolving.com/wiki/index.php?title=LaTeX}{Art of Problem Solving Wiki} has a mathematics-oriented guide to \LaTeX\ that avoids most of the technical details and goes straight into how to use it to typeset mathematics.
85
86 \section{Features}
87
88 The CHS Physics Report package calls upon these packages:
89 \begin{multicols}{2}
90 \begin{itemize}
91 \item{amsmath}\vspace{-.8\parskip}
92 \item{fancyhdr}\vspace{-.8\parskip}
93 \item{geometry} - by default, this is set to \verb|\geometry{top = 2.5cm,| \verb|bottom = 2.5cm}|\vspace{-.8\parskip}
94 \item{transparent}\vspace{-.8\parskip}
95 \item{calc}\vspace{-.8\parskip}
96 \item{graphicx}\vspace{-.8\parskip}
97 \item{titlesec}\vspace{-.8\parskip}
98 \item{color} - unnecessary because of xcolor\vspace{-.8\parskip}
99 \item{}{xcolor} with option \texttt{svgnames}\vspace{-.8\parskip}
100 \item{letltxmacro}
101 \end{itemize}
102 \end{multicols}
103 \noindent Some of these packages are included for convenience, not because they are so crucial that they are inseparable from the lab reports. For example, the packages \makebox{transparent}, xcolor, and graphicx are loaded because the Physics C lab reports that we submitted always were required to have a sketch of the setup of our lab; these packages are useful for inputting a \texttt{pdf\char`\_tex} file generated by Inkscape, among other uses.
104
105 Additional packages that you may want to use alongside the CHS Physics Report package include the following.\vspace{-.5\parskip} \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\bfseries\sffamily{#1}}
106 \begin{description}
107 \item[amssymb] -\; allows the typesetting of certain symbols, such as blackboard bold
108 \item[booktabs] -\; helps to format tables to be neater so that they better display data
109 \item[hyperref] -\; may be used to create hyperlinks, links within your document, PDF bookmarks, and formatted URLs; also can add PDF metadata
110 \item[lmodern and fontenc] -\; when both the lmodern (Latin Modern) and fontenc packages are called, and fontenc is loaded with option \verb|T1|, the quality of copying and pasting from your PDF is improved. You don't want to know what happens when you use fontenc without lmodern or an equivalent. (Note that lmodern sets your font; you may use other font packages such as newtxtext as an alternative.)
111 \item[fontspec] -\; fontspec is an alternative to the combination of lmodern and fontenc, and it lets you use any font you want; however, you must use \begingroup\let\nLaTeX\LaTeX\def\LaTeX{\!\makebox{\nLaTeX}}\XeLaTeX\endgroup\ or \makebox{Lua\hspace{-.22em}\LaTeX}\ in order to use fontspec
112 \item[pdfpages] -\; lets you include pages from another PDF as \emph{entire}, \emph{separate} pages. Note that if you want to include a page from another PDF (such as a one-page graph or a table) but you do not want to include it as an \emph{entirely new} page, then you would not use pdfpages, but rather, as a figure on your current page, then you would say \verb|\includegraphics{your_file.pdf}|
113 \item[soul] -\; provides working underlining
114 \end{description}
115
116 \subsection{Package options}
117
118 The CHS Physics Report package provides options to control page style and the style of mathematical notation. There are two page style options: \texttt{light} and \texttt{standard}, which are mutually exclusive. The \texttt{standard} option is used by default; just by calling \\[\parskip]\indent\verb|\usepackage{chs-physics-report}|, \\[\parskip]you get the \verb|standard| option. To select the \texttt{light} option, load the package with\\[\parskip]\indent\verb|\usepackage[light]{chs-physics-report}|.\\[\parskip] The \verb|light| option is generally more suitable for short reports of one or two pages. It places your name, the names of those you worked with, and the title of your report in the header, with a black line beneath these three things.
119
120 There are two mathematics style options: \verb|display| and \verb|inline-math|, which are mutually exclusive to each other, but not to the page style options. Like the \texttt{standard} option, the \verb|display| option is the default option and results in large, display style math even when you use \verb|$|\emph{math text}\verb|$|. To use the \verb|inline-math| option, load the package with\\[2.5mm]\indent\verb|\usepackage[inline-math]{chs-physics-report}|\\[2.5mm]The \verb|inline-math| option is what \LaTeX\ does normally without this package. (This package basically reverses what \LaTeX\ does by default.) The following code illustrates the difference between these two math options.
121
122 \begin{lstlisting}[numbers = none, pos = t]
123 The series $\sum_{n = 1}^\infty\frac{1}{n(n + 1)} = 1$ is called
124 a telescoping series because you don't need a telescope to see
125 it; the series is its own telescope.
126
127 \[K = \frac{1}{2}mv^2\]
128 \end{lstlisting}
129
130 \pagebreak
131
132 \noindent\begin{minipage}{.5\textwidth}\centering
133 \bfseries Using \texttt{display} (default)
134 \end{minipage}
135 \begin{minipage}{.5\textwidth}\centering
136 \bfseries Using \texttt{inline-math}
137 \end{minipage}\\\fbox{\begin{minipage}[c][4cm][t]{.5\textwidth - 2\fboxsep-2\fboxrule}\rmfamily\small
138 The series $\sum_{n = 1}^\infty\dfrac{1}{n(n + 1)} = 1$ is called
139 a telescoping series because you don't need a telescope to see
140 it; the series is its own telescope.
141
142 \[K = \frac{1}{2}mv^2\]
143 \end{minipage}}\fbox{\begin{minipage}[c][4cm][t]{.5\textwidth - 2\fboxsep-2\fboxrule}\rmfamily\small
144 The series $\textstyle\sum_{n = 1}^\infty\textstyle\frac{1}{n(n + 1)} = 1$ is called
145 a telescoping series because you don't need a telescope to see
146 it; the series is its own telescope.
147
148 \[K = \frac{1}{2}mv^2\]\end{minipage}}
149
150 \subsection{Document title and styles}
151
152 \DescribeMacro{\title}\DescribeMacro{\name}\DescribeMacro{\ww}
153 To set the title, your name, and the names of those you worked with, use the \cs{title}, \cs{name}, and \cs{ww} commands, respectively. These each have one argument, and you should probably place them in the preamble of your document.
154
155 The \cs{author} macro may be used in place of \cs{name}; both are defined to be identical. The CHS Physics Report package redefines some \LaTeX\ internal commands relating to titles, so be aware that this package may not be compatible with other packages or document classes that set titles. If you are using the \verb|light| option, the title will automatically appear; however, if you are using the \texttt{standard} option, you must enter \cs{maketitle} at the beginning of your document to make your title appear. As always, you may only use \cs{maketitle} once.
156
157 \DescribeMacro{\titlestyle}\DescribeMacro{\subtitlestyle}
158 To change the style of the main title of your lab report, you may insert the appropriate style macros as arguments of \cs{titlestyle}. To change the style of the subtitles (your name and those you worked with), insert the appropriate style macros as arguments of \cs{subtitlestyle}. Do note that these macros are those that change an entire group of text, such as \cs{itshape} or \cs{bfseries}; they do \textsc{not} include macros such as \cs{emph} or \cs{textbf}. To change the style of the section headers, \cs{sectionstyle}\DescribeMacro{\sectionstyle}\ takes the appropriate style macros as arguments. Do note that while \cs{titlestyle} and \cs{subtitlestyle} apply styles in \emph{addition} to the default styles, \cs{sectionstyle} \emph{resets} the default style, and \emph{then} applies the styles you chose! (There's no good reason for this design; I just wound up writing the package like this.) However, all of these three macros reset their previous values if called a second time.
159
160 These are the default values for each: \vspace{-2mm}
161 \begin{itemize}
162 \item Title: \verb|\Huge\bfseries| with \texttt{standard} and \verb|\small\itshape| with \texttt{light}\vspace{-1mm}
163 \item Subtitle: \cs{small}\vspace{-1mm}
164 \item Section: \verb|\Large\bfseries|
165 \end{itemize}
166
167 By the way, if you want to center your section header, \cs{centering} will not work. You are better off redefining the section style by \verb|\titlesection|\marg{style macros}\verb|{\thesection $\bullet$}{0mm}{}|.
168
169 The following code illustrates the macros discussed.
170
171 \noindent\hspace*{3.5mm}\begin{minipage}{\textwidth - 3.5mm}
172 \begin{lstlisting}[numbers = left, language = TeX]
173 \documentclass[12pt]{article}
174 \usepackage{chs-physics-report}
175
176 \subtitlestyle{\itshape}
177 % sets subtitle (name and names of those worked with) to italic
178
179 \title{Exploring ancient death trap sites: an anthropological survey}
180 \name{Hugo First}
181 \ww{Dooby Careful}
182
183 \begin{document}
184
185 \maketitle
186
187 \section{Abstract}
188
189 To enter, or not to enter, that is the question.
190 \end{document}
191 \end{lstlisting}
192 \end{minipage}
193
194 This produces the following:
195
196 \noindent\hspace{-25mm}\begingroup\setlength{\fboxsep}{0pt}%
197 \fbox{%
198 \begin{minipage}{\textwidth-4\fboxrule+5cm}
199 \rmfamily\vspace{1mm}
200 \begin{center}
201 {\bfseries\Huge Exploring ancient death trap sites: an anthropological survey}\\{\small\itshape{}Hugo First\\Worked with Dooby Careful}\\[7.11317pt]
202
203 \parbox{386.6729pt}{{\bfseries\Large%
204 \hspace{-13mm}\makebox[13mm][l]%
205 {%
206 1%
207 \hspace{\fill}%
208 {\raisebox{1.7pt}{\fontsize{14.4pt}{0pt}\selectfont$\bullet$}}%
209 \hspace{\fill}\hspace{.3mm}%
210 }Abstract}\\[16pt]To enter, or not to enter, that is the question.}
211 \end{center}\vspace{1mm}
212 \end{minipage}}
213 \endgroup
214
215 \pagebreak
216
217 \subsection{Content macros}
218
219 \DescribeMacro{\fig} This macro takes one argument, and outputs it after the word {\rmfamily\textsc{Figure}}.
220
221 \rmfamily
222 \begin{LTXexample}[pos = o, numbers = none]
223 \fig 1 is a graph of the height
224 of the object as it falls off
225 the cliff with respect to time.
226 If you replace the $y$-axis
227 with my grade in this class,
228 \fig1 will still remain true.
229 \end{LTXexample}
230 \sffamily
231
232 \DescribeMacro{\haiku}\DescribeMacro{\haikus}These macros provide an easy way to add a haiku to your lab report. The outputs of these macros depend on whether you are using the \texttt{light} or \texttt{standard} options. Also, the distinction between \texttt{\char`\\haiku} and \texttt{\char`\\haiku\underline{s}} only exists when using the \verb|light| option.
233
234 With the \texttt{standard} option:\vspace*{-\parskip}
235 \rmfamily\small\begin{LTXexample}[pos = o,numbers = none]
236 \haiku{\itshape
237 One two three four five\\
238 Ay Bee See Dee Ea Eff Gee\\
239 Refrigerator
240 }
241 \end{LTXexample}\sffamily
242
243 \normalsize With the \texttt{light} option:
244
245 \begingroup
246 \def\haiku{\hspace{-55pt}\emph{Haiku:}\hspace{35.25pt}}
247 \def\haikus{\hspace{-60pt}\emph{Haikus:}\hspace{35.25pt}}
248 \noindent\hspace*{3.5mm}\begin{minipage}{\textwidth - 3.5mm}
249 \begin{lstlisting}[numbers = left]
250 \haiku{\itshape
251 One two three four five / Ay Bee See Dee Ea Eff Gee / Refrigerator
252 }
253
254 \haikus{\itshape
255 One two three four five / Ay Bee See Dee Ea Eff Gee / Refrigerator\\
256 \indent\indent This is not really / a haiku but it does have / enough syllables
257 }
258 \end{lstlisting}
259 \end{minipage}
260
261 \noindent\hspace{-25mm}\begingroup\setlength{\fboxsep}{0pt}%
262 \fbox{%
263 \begin{minipage}{\textwidth-4\fboxrule+5cm}
264 \rmfamily\vspace{1mm}
265 \centering\parbox{386.6729pt}{
266 \haiku{\itshape
267 \hspace{18pt}One two three four five / Ay Bee See Dee Ea Eff Gee / Refrigerator
268 }
269
270 \haikus{\itshape
271 \hspace{18pt}One two three four five / Ay Bee See Dee Ea Eff Gee / Refrigerator\\
272 \hspace*{36pt}This is not really / a haiku but it does have / enough syllables
273 }}
274 \vspace{1mm}
275 \end{minipage}}
276 \endgroup\endgroup
277
278 I personally prefer to employ italic in my haikus; this is why \cs{itshape} is present. However, you can set your haikus however you want.
279
280 \pagebreak
281
282 To \DescribeMacro{\diff} typeset the upright letter \emph d in a differential instead of using the italic letters normally given in math mode, \cs{diff} provides an easy shortcut.\vspace{-1mm}
283
284 \begin{LTXexample}[pos = o, numbers = none]
285 \[
286 \frac{\diff^2 x}{\diff t^2} = a
287 \]
288 \end{LTXexample}\vspace{-1mm}
289
290 \DescribeMacro{\sqrt}The CHS Physics Report package also redefines the square root to have a descender, which serves to distinguish what is in the square root from what is outside the square root. The code used to implement the new square root comes from Stefan Kottwitz with some of my own edits, and is available under a CC BY-SA 3.0 license. It is the only part of the package not in the public domain. \vspace{-1mm}
291
292 \begin{LTXexample}[pos = o, numbers = none]
293 \[
294 \sqrt[4]{\frac{1}{9}} =
295 \frac{1}{\sqrt{3}}
296 \]
297 \end{LTXexample}\vspace{-1mm}
298
299 \DescribeMacro{\sfsum}\DescribeMacro{\sfprod}Oh, by the way, since we are on the topic of math, here are two macros from a long time ago that I forgot to remove when writing this package. They allow you to use sans-serif sum and product notation. You can have fun with them if you would like to use them, but they are largely useless for physics lab reports, and they are still here as part of my early experiences with \TeX. However, these macros are so badly designed that I will not give an explanation of how to (functionally) use them.
300 The example below uses sans-serif math, although the code to do so is not shown.
301
302 \renewcommand{\geq}{\geqslant}
303
304 \fontfamily{lmss}\selectfont
305
306 \noindent\begin{minipage}{.5\textwidth - 10pt}
307 \begin{lstlisting}[numbers = none]
308 \[\raisebox{-.4em}{$\sfsum_{n=
309 1}^\infty$}\frac{1}{n^2}=
310 \frac{\pi^2}{6}\]
311 \[\raisebox{-.4em}{$\sfprod_{n=
312 1}^k$}\frac{n + 1}{n} = k + 1
313 \quad\forall k\geq 1\]
314 \end{lstlisting}\end{minipage}
315 \hspace{7.3pt}\fbox{
316 \begin{minipage}{.5\textwidth - 9.5pt}
317 \[\raisebox{-.4em}{$\sfsum_{\emph n=
318 \text1}^{\text{∞}}$}\frac{\text1}{\emph{n}^\text{\hspace{.8pt}2}}=
319 \frac{\pi^\text{2}}{\text6}\]
320 \[\raisebox{-.4em}{$\sfprod_{\emph{n}=\text1}^{\emph k}$}\frac{\emph n + \text1}{\emph n} = \emph k + \text1
321 \quad\forall \emph k\geq\text1\]
322 \end{minipage}}\sffamily
323
324
325 \DescribeMacro{\footnote}Footnotes are also redefined so that they do not cause confusion with exponents. Now each footnote looks\ldots\footnote{\sffamily Something like this! (There never has been a good way to illustrate what footnotes look like without actually adding a footnote in the documentation at the very bottom of the page. It's not even really possible to have small boxes of code on the side; I have to awkwardly break off my sentence and end it in a footnote to show what a footnote looks like.)}
326
327 \DescribeMacro{\degree}\DescribeMacro{\degrees} The macros \cs{degree} and \cs{degrees} are used to output a degree symbol. They only work in math mode and are compatible with other packages that also implement a \cs{degree} command.\vspace{-2mm}
328
329 \rmfamily
330 \begin{LTXexample}[pos = o, numbers = none]
331 If the potato is at $91\degrees
332 $C, then is the angle of its
333 temperature in degrees or
334 centigrade?
335 \end{LTXexample}
336
337 \vspace{1mm}
338
339 \sffamily
340
341 \section{Implementation}
342
343 The following section details the implementation of the CHS Physics Report package. I do explain many of the idiosyncrasies and inefficiencies within this package, although I do not plan on making any further major changes to this package in the future. That's partly to keep the portability of the package, and partly because I like that the date on the package is all prime numbers. However, if you're thinking about editing it for your own use, go ahead! Except for the code by Stefan Kottwitz, all of the package is in the public domain, so feel free to edit your version of the package to how you'd like it.
344
345 First, we initiate the CHS Physics Report package and load the various packages that it uses.
346 \begin{lstlisting}[style = mc]
347 \NeedsTeXFormat{LaTeX2e}
348 \ProvidesPackage{chs-physics-report}[2017/11/23 CHS Physics Lab Report]
349 \RequirePackage{amsmath}
350 \RequirePackage{fancyhdr}
351 \RequirePackage{geometry}
352 \geometry{top = 2.5cm, bottom = 2.5cm}
353 \RequirePackage{transparent}
354 \RequirePackage{calc}
355 \RequirePackage{graphicx}
356 \RequirePackage{titlesec}
357 \RequirePackage{color}
358 \RequirePackage[svgnames]{xcolor}
359 \RequirePackage{letltxmacro}
360 \end{lstlisting}\vspace{4mm}
361
362 The code below was written by Stefan Kottwitz on TeX StackExchange to change the look of square roots. I have edited his code to improve the resolution of the square root at up to 15000\% zoom, and to improve the spacing of the square root. This code is available under the \href{https://creativecommons.org/licenses/by-sa/3.0/legalcode}{CC BY-SA 3.0} License.
363 \begin{lstlisting}[style = mc]
364 \let\oldr@@t\r@@t
365 \def\r@@t#1#2{%
366 \setbox0=\hbox{$\oldr@@t#1{#2\,}$}\dimen0=\ht0
367 \advance\dimen0-0.167\ht0
368 \setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
369 {\box0\lower0.478pt\box2}}
370 \LetLtxMacro{\oldsqrt}{\sqrt}
371 \renewcommand*{\sqrt}[2][\ ]{\oldsqrt[#1]{#2\!}}
372 \end{lstlisting}
373
374 The code that follows, however, is in the public domain. \pagebreak
375
376 Here, we define macros that hold the values of our title information and style information (those with an \char`\@ \ in their name). We then define commands to help us set the value of our style commands (\cs{titlestyle}, \cs{subtitlestyle}, and \cs{sectionstyle}).
377 \begin{lstlisting}[style = mc]
378 \let\@title\undefined
379 \let\@author\undefined
380 \def\@titleArgs{}
381 \def\@subTitleArgs{}
382 \def\@sectionArgs{\Large\bfseries}
383 \newcommand{\titlestyle}[1]{\def\@titleArgs{#1}}
384 \newcommand{\subtitlestyle}[1]{\def\@subTitleArgs{#1}}
385 \newcommand{\sectionstyle}[1]{\def\@sectionArgs{#1}}
386 \end{lstlisting}\vspace{4mm}
387
388 The following is the definition of the \verb|light| option. It defines a page style \texttt{light-first-page} for the first page of the lab report, and another page style \texttt{light} for all other pages. The \texttt{light-first-page} style is the page style for the page at which the document begins (i.e. the first page), but because \texttt{light} is document's page style, only the first page has the \texttt{light-first-page} style, which sets the lab report's title.
389
390 Other things that we do are to define the macros for writing haikus and to ensure that \cs{maketitle} throws a warning because the title is in the header of the first page. It is helpful to throw a warning if a user switches from the \texttt{standard} option to the \texttt{light} option, although not completely necessary.
391 \begin{lstlisting}[style = mc]
392 \DeclareOption{light}{
393 \fancypagestyle{light}{
394 \fancyhf{}
395 \cfoot{\textsf{\textbf{-\raisebox{-.7pt}{\thepage}-}}}
396 \renewcommand{\headrulewidth}{0pt}
397 }
398 \fancypagestyle{light-first-page}{
399 \fancyhf{}
400 \lhead{
401 \emph{\small\@titleArgs\@title}\\
402 }
403 \rhead{
404 {\small\@subTitleArgs\@author%
405 \@workedWith}%
406 }
407 \cfoot{\textsf{\textbf{-\raisebox{-.7pt}{\thepage}-}}
408 }
409 \renewcommand{\headrulewidth}{.6pt}
410 \fancyhfoffset{13mm}
411 }
412 \pagestyle{light}
413 \AtBeginDocument{\thispagestyle{light-first-page}}
414 \def\haiku{\hspace{-55pt}\emph{Haiku:}\hspace{35.25pt}}
415 \def\haikus{\hspace{-60pt}\emph{Haikus:}\hspace{35.25pt}}
416 \def\maketitle{\PackageWarning{chs-physics-report}{
417 Remember that maketitle is no longer useful
418 because you are using the light option of
419 CHS Physics Report, so all the information
420 that would have been included in maketitle
421 is now in the header of the first page.}}
422 }
423 \end{lstlisting}\vspace{4mm}
424
425
426 The \texttt{standard} option is much shorter.
427 \begin{lstlisting}[style = mc]
428 \DeclareOption{standard}{
429 \renewcommand{\maketitle}{%
430 \begin{center}{\Huge\textbf{\@titleArgs\@title}}\\%
431 {\small\@subTitleArgs\@author\@workedWith}
432 \end{center}
433 }
434 \ifx\@workedWith\undefined
435 \def\@workedWith{{Please set the names of those whom you %
436 worked with by typing \texttt{\char`\\%
437 ww\{\textrm{\emph{others in your lab group}}\}}}}
438 \fi
439 % for compatibility with the light option:
440 \newcommand{\haiku}[1]{\begin{center}#1\end{center}}
441 \newcommand{\haikus}[1]{\begin{center}#1\end{center}}
442 }
443 \end{lstlisting}\vspace{4mm}
444
445 In the event that \cs{@author}, \cs{@title}, or \cs{@workedWith} is not defined, we define them so that they tell the user to define them ahead of time. You may think that it would be best to throw an error if they are undefined, but I have tried \cs{errmessage} and \cs{PackageError} for these if statements, and neither work better than what I have here, bad though it is. The reason is that the package is called before the document begins, so these commands are necessarily undefined before \TeX\ reaches \cs{title}, \cs{name}, and \cs{ww}.
446
447 You will probably notice that I have a conditional to check if \cs{@workedWith} is defined, but I already have such a conditional in the \texttt{standard} option (shown above above). The two are different, although the package definitely could be made more efficient. However, I do not want to alter this package any further, so I will not make any such changes.
448 \begin{lstlisting}[style = mc]
449 \ifx\@author\undefined
450 \author{Please enter your name by using \texttt{\char`\\%
451 name\char`\{\emph{your name}\char`\}}}
452 \fi
453
454 \ifx\@title\undefined
455 \title{Please set the title by typing %
456 \texttt{\char`\\%
457 title\char`\{{\emph{title of lab report}}\char`\}}}
458 \fi
459 \ifx\@workedWith\undefined
460 \def\@workedWith{{\\Please set the names of those whom you %
461 worked with by typing \texttt{\char`\\%
462 ww\char`\{{\emph{others in your lab group}}\char`\}}}}
463 \fi
464 \end{lstlisting}
465 \vspace{5mm}
466
467 Now, we select the \texttt{display} and \texttt{standard} options as our default options, and we've finished handling package options.
468 \begin{lstlisting}[style = mc]
469 \DeclareOption{display}{\everymath{\displaystyle}}
470
471 \DeclareOption{inline-math}{\everymath{}}
472
473 \ExecuteOptions{display,standard}
474
475 \ProcessOptions\relax
476 \end{lstlisting}\vspace{4mm}
477
478 We set \cs{parskip} and we define \cs{fig} and \cs{diff}.
479 \begin{lstlisting}[style = mc]
480 \setlength{\parskip}{2.5mm}
481 \newcommand{\fig}[1]{\textsc{Figure~#1}}
482 \newcommand{\diff}{\mathrm d}
483 \end{lstlisting}
484 \vspace{4mm}
485
486 Sans-serif math operators:
487 \begin{lstlisting}[style = mc]
488 \@ifpackageloaded{amsmath}{\DeclareMathOperator*{\sfsum}{\fontsize{.9cm}{1cm}\text{$\mathsf\Sigma$}}
489 \DeclareMathOperator*{\sfprod}{\fontsize{.9cm}{1cm}\text{$\mathsf\Pi$}}}
490 \end{lstlisting}\vspace{4mm}
491
492 At this point, we create the style used for sections. The first matter of business is to set a distance that will determine how far from the text each section number will go. This distance, which we will call \cs{@boxwidth}, is normally set to 13~mm. If you need two-digit section numbers (10,11,12\ldots), you may find it helpful to increase this distance.
493 \begin{lstlisting}[style = mc]
494 \newlength{\@boxwidth}
495 \setlength{\@boxwidth}{13 mm}
496 \end{lstlisting}
497 Next, we use titlesec to construct a box of width \cs{@boxwidth}. We place the section number in the box, and we place a bullet point to the right of the section number. We then uniformly fill the space in the box, by placing in \verb|\hspace{\fill}| between the bullet point and the section number, and by placing another \verb|\hspace{\fill}| between the bullet point and the right side of the box.
498 \begin{lstlisting}[style = mc]
499 \titleformat{\section}
500 {%
501 \@sectionArgs%
502 }
503 {\hspace{-\@boxwidth}%
504 \makebox[\@boxwidth][l]%
505 {%
506 \thesection%
507 \hspace{\fill}%
508 {\raisebox{1.7pt}{\fontsize{14.4pt}{0pt}\selectfont$\bullet$}}%
509 \hspace{\fill}\hspace{.3mm}%
510 }%
511 }
512 {0cm}
513 {}
514 \end{lstlisting}
515 \vspace{4mm}
516
517 We change the style of footnotes. I know that what I have here is not a best practice, but I didn't know that when I first wrote the package! For best practices, I should have used \cs{textsuperscript} and made a \cs{@oldfootnote} macro.
518 \begin{lstlisting}[style = mc]
519 \let\footnoteDuplic@teDuplic@te\footnote
520 \def\footnoteDuplic@te#1{$^\text{Note }$\footnoteDuplic@teDuplic@te{#1}}
521 \let\footnote\footnoteDuplic@te
522 \end{lstlisting}\vspace{4mm}
523
524 To define \cs{degree} and \cs{degrees}, we use \cs{providecommand} instead of \cs{newcommand} so that if other packages that define either one of these are loaded, there will not be an error due to conflicting definitions.
525 \begin{lstlisting}[style = mc]
526 \providecommand{\degree}{^\circ}
527 \providecommand{\degrees}{\degree}
528 \end{lstlisting}\vspace{4mm}
529
530 We define \cs{name} and \cs{ww} to set the values of title information.
531 \begin{lstlisting}[style = mc]
532 \newcommand{\name}[1]{\author{#1}}
533 \newcommand{\ww}[1]{\def\@workedWith{\\Worked with #1}}
534 \end{lstlisting}\vspace{4mm}
535
536
537 And we're done!
538 \begin{lstlisting}[style = mc]
539 \endinput
540 \end{lstlisting}
541
542 \section{Having trouble?}
543
544
545 If you can't get your document to compile as you'd like to, even if your problem is unrelated to this package, you can always contact me. Emails are fine, although if you see me in the hallways, you may always ask a question. If you would like to find me before school, my first class is physics on blue days, and my first class is statistics (A322) on gold days.\vspace{1cm}
546
547 \noindent``The most common mistake is spending too long on \TeX\ coding and not getting the document written.''
548
549 \hspace{\fill}--\mbox{David Carlisle}
550 \end{document}