summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/chs-physics-report/chs-physics-report.sty
blob: 3eea90cd2e614b6bad7e914ee97355f7cf7d68c4 (plain)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
% Hi! You have opened the CHS Physics Lab Report Package, written 
% by Gary Zhang.  With the exception of a code snippet below from 
% Stefan Kottwitz, all the code in this package may be considered
% as public domain.
%
% To install this package, follow the instructions found here: 
%     http://artofproblemsolving.com/wiki/index.php?title=LaTeX:Packages#Making_Your_Own
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{chs-physics-report}[2017/11/23 CHS Physics Lab Report] % look! They're all prime!

\RequirePackage{amsmath}
\RequirePackage{fancyhdr}
\RequirePackage{geometry}
\geometry{top = 2.5cm, bottom = 2.5cm}
\RequirePackage{transparent}
\RequirePackage{calc}
\RequirePackage{graphicx}
\RequirePackage{titlesec}
\RequirePackage{color}
\RequirePackage[svgnames]{xcolor}
\RequirePackage{letltxmacro}
% ------------------------------------------------------
% Square root code below by Stefan Kottwitz, from 
% TeX Stack Exchange, used under a CC BY-SA 3.0 License.
% This section is the only part of this code NOT in the
% public domain. 
%
% Edited to improve resolution at over 15000\% zoom
%
\let\oldr@@t\r@@t
\def\r@@t#1#2{%
\setbox0=\hbox{$\oldr@@t#1{#2\,}$}\dimen0=\ht0
\advance\dimen0-0.167\ht0
\setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
{\box0\lower0.478pt\box2}}
\LetLtxMacro{\oldsqrt}{\sqrt}
\renewcommand*{\sqrt}[2][\ ]{\oldsqrt[#1]{#2\!}}
%
% end of copyrighted code
% ------------------------------------------------------

\let\@title\undefined
\let\@author\undefined
\def\@titleArgs{}
\def\@subTitleArgs{}
\def\@sectionArgs{\Large\bfseries}
\newcommand{\titlestyle}[1]{\def\@titleArgs{#1}}
\newcommand{\subtitlestyle}[1]{\def\@subTitleArgs{#1}}
\newcommand{\sectionstyle}[1]{\def\@sectionArgs{#1}}
\DeclareOption{light}{
  \fancypagestyle{light}{
    \fancyhf{}
    \cfoot{\textsf{\textbf{-\raisebox{-.7pt}{\thepage}-}}}
    \renewcommand{\headrulewidth}{0pt}
  }
  \fancypagestyle{light-first-page}{
    \fancyhf{}
    \lhead{
        \emph{\small\@titleArgs\@title}\\
    }
    \rhead{
        {\small\@subTitleArgs\@author%
        \@workedWith}%
    }
    \cfoot{\textsf{\textbf{-\raisebox{-.7pt}{\thepage}-}}
    }
    \renewcommand{\headrulewidth}{.6pt}
    \fancyhfoffset{13mm}
  }
  \pagestyle{light}
  \AtBeginDocument{\thispagestyle{light-first-page}}
  \def\haiku{\hspace{-55pt}\emph{Haiku:}\hspace{35.25pt}}
  \def\haikus{\hspace{-60pt}\emph{Haikus:}\hspace{35.25pt}}
  \def\maketitle{\PackageWarning{chs-physics-report}{
    Remember that maketitle is no longer useful 
    because you are using the light option of 
    CHS Physics Report, so all the information 
    that would have been included in maketitle 
    is now in the header of the first page.}}
}

\DeclareOption{standard}{
  \renewcommand{\maketitle}{%
    \begin{center}{\Huge\textbf{\@titleArgs\@title}}\\%
    {\small\@subTitleArgs\@author\@workedWith}
    \end{center}
  }
  \ifx\@workedWith\undefined
    \def\@workedWith{{Please set the names of those whom you %
      worked with by typing \texttt{\char`\\%
      ww\{\textrm{\emph{others in your lab group}}\}}}}
  \fi
  % for compatibility with the light option:
  \newcommand{\haiku}[1]{\begin{center}#1\end{center}}
  \newcommand{\haikus}[1]{\begin{center}#1\end{center}}
}

\ifx\@author\undefined
  \author{Please enter your name by using \texttt{\char`\\%
  name\char`\{\emph{your name}\char`\}}}
\fi
% Okay, so I have tried \errmessage and \PackageError for these if statements, and neither work better than what I have here, bad though it is
\ifx\@title\undefined
  \title{Please set the title by typing %
    \texttt{\char`\\%
    title\char`\{{\emph{title of lab report}}\char`\}}}
\fi
\ifx\@workedWith\undefined
  \def\@workedWith{{\\Please set the names of those whom you %
    worked with by typing \texttt{\char`\\%
    ww\char`\{{\emph{others in your lab group}}\char`\}}}}
\fi

\DeclareOption{display}{\everymath{\displaystyle}}

\DeclareOption{inline-math}{\everymath{}}

\ExecuteOptions{display,standard}

\ProcessOptions\relax


\setlength{\parskip}{2.5mm}
\newcommand{\fig}[1]{\textsc{Figure~#1}}
\newcommand{\diff}{\mathrm d}

% ------------ useless stuff -------------
\@ifpackageloaded{amsmath}{\DeclareMathOperator*{\sfsum}{\fontsize{.9cm}{1cm}\text{$\mathsf\Sigma$}}
\DeclareMathOperator*{\sfprod}{\fontsize{.9cm}{1cm}\text{$\mathsf\Pi$}}}
% ----------------------------------------

\newlength{\@boxwidth}
\setlength{\@boxwidth}{13 mm} 
% \@boxwidth sets the distance from the dot to the section title

\titleformat{\section}
{%
  \@sectionArgs%
}
{\hspace{-\@boxwidth}%
  \makebox[\@boxwidth][l]%
  {%
    \thesection%
    \hspace{\fill}%
    {\raisebox{1.7pt}{\fontsize{14.4pt}{0pt}\selectfont$\bullet$}}%
    \hspace{\fill}\hspace{.3mm}%
  }%
}
{0cm}
{}

\let\footnoteDuplic@teDuplic@te\footnote
\def\footnoteDuplic@te#1{$^\text{Note }$\footnoteDuplic@teDuplic@te{#1}} % yes, I know my jokes are never funny any more
\let\footnote\footnoteDuplic@te
% I also am pretty certain this is not good practice, but I do not 
% know how to do anything better!

% \providecommand is used instead of \newcommand so that if 
% other packages that define either one of these are loaded, 
% there will not be an error due to conflicting definitions.
\providecommand{\degree}{^\circ}
\providecommand{\degrees}{\degree}

% defines information for titles
\newcommand{\name}[1]{\author{#1}}
\newcommand{\ww}[1]{\def\@workedWith{\\Worked with #1}}


\endinput