├── LICENSE.txt ├── Makefile ├── README.md ├── example.pdf ├── example.tex ├── homework.cls └── template.tex /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Artem Mavrin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | LATEX := pdflatex 2 | LATEXFLAGS := --shell-escape --file-line-error 3 | LATEXMK := latexmk 4 | LATEXMKFLAGS := -quiet -recorder -use-make -pdf 5 | 6 | .PHONY: clean 7 | 8 | example.pdf: example.tex homework.cls 9 | $(LATEXMK) $(LATEXMKFLAGS) -pdflatex="$(LATEX) $(LATEXFLAGS) %O %S" $< 10 | 11 | clean: 12 | $(LATEXMK) -quiet -c 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The `homework` class 2 | 3 | Provides the LaTeX class [homework.cls](homework.cls) for typesetting homework 4 | in a straightforward problem-solution format. 5 | Designed to avoid [this mistake](http://tex.stackexchange.com/a/139878/23505). 6 | 7 | Read on for a description of the `homework` class. 8 | 9 | ---- 10 | 11 | ## Table of Contents 12 | 13 | * [**Introduction**](#introduction) 14 | * [**Features**](#features) 15 | * [**Example**](#example) 16 | * [**Getting Started**](#getting-started) 17 | * [**Template**](#template) 18 | * [**Usage**](#usage) 19 | * [**Documentation**](#documentation) 20 | * [**Commands**](#commands) 21 | * [**Environments**](#environments) 22 | * [**Class Options**](#class-options) 23 | * [**License**](#license) 24 | 25 | ## Introduction 26 | 27 | ### Features 28 | 29 | * Simple interface for specifying homework information (e.g., name and course). 30 | * Environments for writing problem statements, problem parts, and solutions. 31 | * Automatic title creation. 32 | * Compatible with `article` class options. 33 | * Loads the AMS math packages. 34 | * Automatic PDF author/title/bookmark metadata creation. 35 | 36 | ### Example 37 | 38 | For an examples of homework solutions created using the `homework` class, 39 | see [example.tex](example.tex) and the resulting [PDF](example.pdf). 40 | 41 | ## Getting Started 42 | 43 | ### Template 44 | 45 | [template.tex](template.tex) is a ready-to-use homework template that uses the 46 | `homework` class. 47 | 48 | ### Usage 49 | 50 | * Download `homework.cls` and save it in the same directory as your homework 51 | `.tex` file (*alternatively*, see 52 | [this question](http://tex.stackexchange.com/questions/1137/) to learn where 53 | to put `.cls` files to be globally available to TeX) 54 | * At the top of the homework `.tex` file, put `\documentclass{homework}`. 55 | * In the preamble, specify the homework information using the commands listed in 56 | the [Commands](#commands) section. 57 | * In the document, begin writing problems in `problem` environments and 58 | solutions in `solution` environments (see [Environments](#environments)). 59 | 60 | ## Documentation 61 | 62 | ### Commands 63 | 64 | The following commands should be used in the preamble of the homework `.tex` 65 | file. 66 | If these are not used, you will get an error. 67 | 68 | * `\name{}`: 69 | Replace `` with your name. 70 | * `\course{}`: 71 | Replace `` with the name of the course. 72 | * `\term{}`: 73 | Replace `` with the term when the course is held. 74 | * `\hwnum{}`: 75 | Replace `` with the number of the homework. 76 | 77 | Thus, at a *minimum*, your preamble must contain 78 | 79 | ```tex 80 | \documentclass{homework} 81 | 82 | \name{} 83 | \course{} 84 | \term{} 85 | \hwnum{} 86 | ``` 87 | 88 | You can also change the default text of various labels that appear on the 89 | document by using the following commands. 90 | 91 | * `\hwname{}`: 92 | Replace `` with the desired label for the type of homework (e.g., 93 | *Assignment* or *Problem Set*). 94 | The default is *Homework*. 95 | * `\problemname{}`: 96 | Replace `` with the desired label for problems created with the 97 | `problem` environment (e.g., *Exercise* or *Question*). 98 | The default is *Problem*. 99 | * `\solutionname{}`: 100 | Replace `` with the desired label for solutions created with the 101 | `solution` environment (e.g., *Proof*, *Answer*, or a label in another 102 | language). 103 | The default is *Solution*. 104 | 105 | ### Environments 106 | 107 | The following environments are provided to typeset the homework. 108 | 109 | * `problem`: 110 | wraps individual problem statements. 111 | By default, problems are numbered beginning at `1`. 112 | To change the number of a given problem to `n`, use the command 113 | `\problemnumber{n}` before the `problem` environment. 114 | * `solution`: 115 | wraps the solution to a problem. 116 | * `parts`: 117 | enumerates parts of a multiple-part problem. 118 | If multiple `parts` environments are used in a single `problem` environment, 119 | labels will resume unless you use the `\unresume` command right after the 120 | beginning of each `parts` environment. 121 | New parts are declared using the `\part` command. 122 | The part labels can be customized by providing one of the following options to 123 | the `parts` environment: 124 | * `a`: 125 | (default) Lowercase letters. 126 | * `A`: 127 | Uppercase letters. 128 | * `r`: 129 | Lowercase Roman numerals. 130 | * `R`: 131 | Uppercase Roman numerals. 132 | * `n`: 133 | Numbers. 134 | 135 | To specify your own labels to `parts` (for example, 136 | to only list parts `b`, `d` and `e`) use the custom label as parameter as in `\part[b)]`. 137 | 138 | * `claim`, `lemma`, `propostion`, `theorem`, `corollary`, `proof`: 139 | organize claims made in a solution (and prove these claims). 140 | The 'claim' environment takes an optional argument that labels the claim 141 | (e.g., `\begin{claim}[Conjecture]` will make the claim be labelled 142 | "Conjecture"). 143 | The other listed environments are derived from the 'claim' environment. 144 | 145 | ### Class Options 146 | 147 | To use a class option, write 148 | 149 | ```tex 150 | \documentclass[]{homework} 151 | ``` 152 | 153 | at the beginning of your homework file, where `` is a comma-separated 154 | list of the options that you wish to use. 155 | 156 | All the options of the `article` class may be used. 157 | In addition, the `homework` class provides the following options. 158 | 159 | * `boxes`: 160 | Use this option if you want the `problem` environment to enclose problem 161 | statements in boxes. 162 | * `hidesolutions`: 163 | Use this option to hide solutions in the output. 164 | With this option enabled, you can still write solutions in the `solution` 165 | environment, but these solutions will not show up in the final document. 166 | * `qed`: 167 | Use this option if you want an end-of-proof symbol printed at the end of 168 | solutions. 169 | 170 | ## License 171 | 172 | This code is distributed under the MIT license. For more info, read the 173 | [LICENSE](LICENSE.txt) file. 174 | -------------------------------------------------------------------------------- /example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artemmavrin/latex-homework/1173aa780847175fcc0adde63cf06d6773469e50/example.pdf -------------------------------------------------------------------------------- /example.tex: -------------------------------------------------------------------------------- 1 | \documentclass{homework} 2 | 3 | \name{Leonhard Euler} 4 | \course{Math 101} 5 | \term{Fall 1737} 6 | \hwnum{1} 7 | 8 | \begin{document} 9 | 10 | \begin{problem} 11 | \begin{parts} 12 | \part 13 | \label{1.a} 14 | Prove that there is no rational number whose square is $2$. 15 | \part 16 | \label{1.b} 17 | Let $p$ be a prime number and $n$ an integer greater than $1$. 18 | Prove that there is no rational number whose $n$th power is $p$. 19 | \end{parts} 20 | \end{problem} 21 | 22 | \begin{solution} 23 | \ref{1.a} 24 | Suppose that there is a rational number whose square is $2$. 25 | Then we can find coprime nonzero integers $a$ and $b$ such that $a^2 / b^2 = 2$. 26 | Then $a^2 = 2 b^2$, so $a^2$ is even. 27 | It follows that $a$ is even, so $a = 2 k$ for some integer $k$. 28 | Then $2 b^2 = 4 k^2$, so $b^2 = 2 k^2$, which implies that $b^2$ is even. 29 | But then $b$ itself is even, which is a contradiction since $a$ is even and $a$ 30 | and $b$ are coprime. 31 | Thus, there is no rational number whose square is $2$. 32 | 33 | \ref{1.b} 34 | If there were such a rational number, then it would be a root of the polynomial 35 | $f = x^n - p$. 36 | This polynomial is irreducible over $\mathbb{Z}$ by Eisenstein's criterion, and 37 | so it is irreducible over $\mathbb{Q}$ by Gauss's Lemma. 38 | In particular, $f$ has no roots in $\mathbb Q$, there is no rational number 39 | whose $n$th power is $p$. 40 | \end{solution} 41 | 42 | \begin{problem} 43 | Let $S$ be a dense subset of $\mathbb R$. 44 | \begin{parts}[r] 45 | \part 46 | \label{2.i} 47 | Suppose $f : \mathbb R \to \mathbb R$ is continuous and $f(x) = 0$ for all 48 | $x \in S$. 49 | \begin{parts}[A] 50 | \part 51 | \label{2.i.1} 52 | Prove, using the \emph{definition} of denseness, that $f(x) = 0$ for all 53 | $x \in \mathbb R$. 54 | \part 55 | \label{2.i.2} 56 | Prove, using the fact that a subset of $\mathbb R$ is dense if and only if it is 57 | \emph{sequentially dense}, that $f(x) = 0$ for all $x \in \mathbb R$. 58 | \end{parts} 59 | \part 60 | \label{2.ii} 61 | Suppose $f, g : \mathbb R \to \mathbb R$ are continuous and $f(x) = g(x)$ for 62 | all $x \in S$. 63 | Prove that $f(x) = g(x)$ for all $x \in \mathbb R$. 64 | \end{parts} 65 | \end{problem} 66 | 67 | \begin{solution} 68 | \ref{2.i}\ref{2.i.1} 69 | Let $x \in \mathbb R$ be given, and pick any $\varepsilon > 0$. 70 | Since $f$ is continuous at $x$, there exists a $\delta > 0$ such that 71 | $|f(x) - f(y)| < \varepsilon$ for all $y \in \mathbb R$ such that 72 | $|x - y| < \delta$. 73 | Since $S$ is dense in $\mathbb R$, there exists a number 74 | $y \in S \cap (x - \delta, x + \delta)$. 75 | Then $f(y) = 0$ and $|x - y| < \delta$. 76 | Therefore, $|f(x)| = |f(x) - f(y)| < \varepsilon$. 77 | Since $|f(x)| < \varepsilon$ for an arbitrary $\varepsilon > 0$, it follows that 78 | $f(x) = 0$. 79 | Since $x$ was arbitrary, this shows that $f(x) = 0$ for all $x \in \mathbb R$. 80 | 81 | \ref{2.i}\ref{2.i.2} 82 | Since $S$ is a dense subset of $\mathbb R$, it is also sequentially dense (i.e., 83 | every real number is a limit of some sequence in $S$). 84 | Let $x \in \mathbb R$ be given, and choose a sequence $\{x_n\}$ in $S$ that 85 | converges to $x$. 86 | For all $n \in \mathbb N$, we have $f(x_n) = 0$ since $x_n \in S$. 87 | Thus, $\{f(x_n)\} \to 0$. 88 | However, since $f$ is continuous and $\{x_n\} \to x$, it must be the case that 89 | $\{f(x_n)\} \to f(x)$, so $f(x) = 0$. 90 | Since $x$ was arbitrary, $f(x) = 0$ for all $x \in \mathbb R$. 91 | 92 | \ref{2.ii} 93 | Define $h : \mathbb R \to \mathbb R$ by $h(x) = f(x) - g(x)$. 94 | Then $h$ is continuous and $h(x) = 0$ for all $x \in S$ (since $f(x) = g(x)$ for 95 | all $x \in S$). 96 | By part \ref{2.i}, it follows that $h(x) = 0$ for all $x \in \mathbb R$, so 97 | therefore $f(x) = g(x)$ for all $x \in \mathbb R$. 98 | \end{solution} 99 | 100 | \begin{problem}[Ahlfors \S4.2.3 \#2, p. 123] 101 | Prove that a function which is analytic in the whole plane and satisfies an 102 | inequality $|f(z)| < |z|^n$ for some $n$ and all sufficiently large $|z|$ 103 | reduces to a polynomial. 104 | \end{problem} 105 | 106 | \begin{solution} 107 | Since $f$ is entire, we may write $f$ as a power series centered at $0$ which 108 | converges for every complex number $z$: 109 | \begin{equation*} 110 | f(z) = \sum_{k=0}^\infty a_k z^k. 111 | \end{equation*} 112 | Let $R > 0$ be large enough such that $|f(z)| < |z|^n$ whenever $|z| \geq R$. 113 | Let $\gamma$ be the positively oriented circle of radius $R$ centered at the 114 | origin, parametrized as $\gamma(t) = R e^{i t}$ for $0 \leq t \leq 2\pi$. 115 | For each $k \geq 0$ we have 116 | \begin{align*} 117 | a_k 118 | &= \frac{f^{(k)}(0)}{n!} 119 | = \frac{1}{2 \pi i} \int_\gamma \frac{f(z)}{z^{k+1}} \, dz 120 | = \frac{1}{2 \pi i} \int_0^{2\pi} \frac{f(\gamma(t))}{\gamma(t)^{k+1}} \gamma^\prime(t) \, dt 121 | \\&= \frac{1}{2 \pi i} \int_0^{2\pi} \frac{f(R e^{i t})}{R^{k+1} e^{i(t+1) t}} i R e^{i t} \, dt 122 | = \frac{1}{2 \pi R^k} \int_0^{2\pi} \frac{f(R e^{i t})}{e^{i k t}} \, dt, 123 | \end{align*} 124 | and hence 125 | \begin{align*} 126 | |a_k| 127 | &= \frac{1}{2 \pi R^k} \left|\int_0^{2\pi} \frac{f(R e^{i t})}{e^{i k t}} \, dt\right| 128 | \leq \frac{1}{2 \pi R^k} \int_0^{2\pi} \frac{|f(R e^{i t})|}{|e^{i k t}|} \, dt 129 | \\&= \frac{1}{2 \pi R^k} \int_0^{2\pi} |f(R e^{i t})| \, dt 130 | \leq \frac{1}{2 \pi R^k} \int_0^{2\pi} R^n \, dt 131 | = \frac{R^n}{R^k} 132 | = \frac{1}{R^{k - n}}. 133 | \end{align*} 134 | If $k > n$, then letting $R \to \infty$ gives $|a_k| = 0$. 135 | Thus, we have $a_k = 0$ for $k > n$, so that 136 | \begin{equation*} 137 | f(z) = a_0 + a_1 x + \cdots + a_n x^n. 138 | \end{equation*} 139 | That is, $f$ is a polynomial. 140 | \end{solution} 141 | 142 | \begin{problem} 143 | Prove that there are infinitely many prime numbers. 144 | \end{problem} 145 | 146 | \begin{solution} 147 | Let $p_1,\ldots,p_n$ be a finite list of prime numbers. 148 | The number $Q = p_1\cdots p_n + 1$ is coprime to $p_i$ for $i=1,\ldots,n$, so 149 | $Q$ has a prime factor $q$ which is not among the primes $p_1, \ldots, p_n$. 150 | Thus, given any finite list of primes numbers, we can find a prime number not in 151 | the list. 152 | It follows that there are infinitely many prime numbers. 153 | \end{solution} 154 | 155 | \begin{problem} 156 | Let $p_n$ be the $n$th prime number. 157 | Prove that the series 158 | \begin{equation} 159 | \label{eq:sum of reciprocals of primes} 160 | \sum_{n=1}^\infty \frac{1}{p_n} 161 | \end{equation} 162 | diverges. 163 | \end{problem} 164 | 165 | \begin{solution} 166 | Suppose, for the sake of contradiction, that 167 | \eqref{eq:sum of reciprocals of primes} converges. 168 | Then there is an integer $k$ such that 169 | \begin{equation} 170 | \label{eq:tail of sum of reciprocals of primes} 171 | \sum_{n > k} \frac{1}{p_n} < \frac{1}{2}. 172 | \end{equation} 173 | Let $Q = p_1 \cdots p_k$, and, for every positive integer $N$, define 174 | \begin{equation*} 175 | S(N) = \sum_{n=1}^N \frac{1}{1 + n Q}. 176 | \end{equation*} 177 | Also, let $P(N)$ be the finite set of primes $q$ which divide $1 + n Q$ for at 178 | least one $n \in \{1,\ldots,N\}$. 179 | For each positive integer $n$, the integers $Q$ and $1 + n Q$ are coprime, so 180 | none of the prime numbers $p_1,\ldots,p_k$ divide $1 + n Q$. 181 | It follows that 182 | \begin{equation} 183 | \label{eq:P(N) subset} 184 | P(N) \subseteq \{p_{k+1}, p_{k+2}, \ldots\} 185 | \end{equation} 186 | for every positive integer $N$. 187 | If $m$ is another positive integer, then we define $A(N, m)$ to be the set of 188 | all integers $n$ such that $1 \leq n \leq N$ and such that $1 + n Q$ has exactly 189 | $m$ (not necessarily distinct) prime divisors. 190 | Consider the sum 191 | \begin{equation*} 192 | S(N, m) = \sum_{n \in A(N, m)} \frac{1}{1 + n Q}. 193 | \end{equation*} 194 | Observe that $S(N, m) = 0$ for $m$ sufficiently large (since $A(N,m)$ is empty 195 | for $m$ sufficiently large) and that 196 | \begin{equation} 197 | \label{eq:S(N) as sum} 198 | S(N) 199 | = \sum_{m=1}^\infty S(N, m). 200 | \end{equation} 201 | If $n \in A(N, m)$, then $1 + n Q = (q_1\cdots q_m)^{-1}$ for some 202 | $q_1,\ldots,q_m \in P(N)$, so 203 | \begin{equation*} 204 | S(N, m) 205 | \leq \sum_{q_1,\ldots,q_m \in P(N)} \frac{1}{q_1\cdots q_m} 206 | = \left(\sum_{p \in P(N)} \frac{1}{p}\right)^{m}. 207 | \end{equation*} 208 | It then follows from \eqref{eq:tail of sum of reciprocals of primes} and 209 | \eqref{eq:P(N) subset} that 210 | \begin{equation*} 211 | S(N, m) 212 | \leq \left(\sum_{p \in P(N)} \frac{1}{p}\right)^{m} 213 | \leq \left(\sum_{n > k} \frac{1}{p_n}\right)^{m} 214 | < \frac{1}{2^m} 215 | \end{equation*} 216 | Now \eqref{eq:S(N) as sum} implies that 217 | \begin{equation*} 218 | S(N) 219 | = \sum_{m=1}^\infty S(N, m) 220 | \leq \sum_{m=1}^\infty \frac{1}{2^m} = 1. 221 | \end{equation*} 222 | Thus, the sequence $\{S(N)\}_{N=1}^\infty$ is a monotone increasing bounded 223 | sequence, so it converges to the limit 224 | \begin{equation*} 225 | \lim_{N \to \infty} S(N) 226 | = \lim_{N \to \infty} \sum_{n=1}^N \frac{1}{1 + n Q} 227 | = \sum_{n=1}^\infty \frac{1}{1 + n Q}. 228 | \end{equation*} 229 | However, the series above diverges (e.g., by the integral test), so we have 230 | reached a contradiction. 231 | It follows that the series \eqref{eq:sum of reciprocals of primes} diverges. 232 | \end{solution} 233 | 234 | \begin{problem}[Atiyah-Macdonald 1.1] 235 | Let $x$ be a nilpotent element of a ring $A$. 236 | Show that $1 + x$ is a unit of $A$. 237 | Deduce that the sum of a nilpotent element and a unit is a unit. 238 | \end{problem} 239 | 240 | \begin{solution} 241 | Let $y = -x$. 242 | Then $y$ is also nilpotent, so choose a positive integer $n$ such that 243 | $y^n = 0$. 244 | We have 245 | \begin{align*} 246 | (1 - y) (1 + y + y^2 + \cdots + y^{n-1}) 247 | = 1 - y^n 248 | = 1 249 | \end{align*} 250 | which shows that $1 + x = 1 - y$ is a unit. 251 | 252 | Next, let $x\in A$ be nilpotent and $u\in A$ a unit. 253 | Then $u^{-1} x$ is nilpotent, so $1 + u^{-1}x$ is a unit by the first part. 254 | Therefore 255 | \begin{equation*} 256 | u + x = u(1 + u^{-1} x). 257 | \end{equation*} 258 | Since it is a product of units, $u + x$ is a unit. 259 | \end{solution} 260 | 261 | \end{document} 262 | -------------------------------------------------------------------------------- /homework.cls: -------------------------------------------------------------------------------- 1 | % homework.cls 2 | % LaTeX class for typesetting homework 3 | % Author: Artem Mavrin 4 | % 5 | % The most recent version can be found here: 6 | % https://github.com/artemmavrin/latex-homework/blob/master/homework.cls 7 | \NeedsTeXFormat{LaTeX2e} 8 | \ProvidesClass{homework}[2017/11/09 LaTeX class for typesetting homework] 9 | 10 | 11 | %%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % Class base and options % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%% 14 | 15 | % Support for key-value class options 16 | \RequirePackage{kvoptions} 17 | \SetupKeyvalOptions{ 18 | family=HW, 19 | prefix=HW@, 20 | } 21 | 22 | % Options for 10pt, 11pt, or 12pt fonts 23 | % We don't defer this to the article class because we want 12pt to be the 24 | % default font size 25 | \def\@fontsize{12pt} 26 | \DeclareVoidOption{10pt}{\renewcommand{\@fontsize}{10pt}} 27 | \DeclareVoidOption{11pt}{\renewcommand{\@fontsize}{11pt}} 28 | \DeclareVoidOption{12pt}{\renewcommand{\@fontsize}{12pt}} 29 | 30 | % True/False options. Defaults are False 31 | \DeclareBoolOption{qed} % End solutions with a QED tombstone symbol 32 | \DeclareBoolOption{hidesolutions} % Do not display solutions 33 | \DeclareBoolOption{boxes} % Wrap problems in boxes 34 | 35 | % All other options get passed to the article class 36 | \DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{article}} 37 | 38 | % Process the options provided to the class and load the `article' class 39 | \ProcessKeyvalOptions* 40 | \LoadClass[\@fontsize]{article} 41 | 42 | 43 | %%%%%%%%%%%%%%%%%%%% 44 | % Homework details % 45 | %%%%%%%%%%%%%%%%%%%% 46 | 47 | % Internal names for homework details 48 | 49 | % The internal student name, course name, term, and HW number macros have no 50 | % default value and will raise an error if used before being set by their 51 | % corresponding defining macros. 52 | \def\@name{\@latex@error{No \noexpand\name given}\@ehc} 53 | \def\@course{\@latex@error{No \noexpand\course given}\@ehc} 54 | \def\@term{\@latex@error{No \noexpand\term given}\@ehc} 55 | \def\@hwnum{\@latex@error{No \noexpand\hwnum given}\@ehc} 56 | % The following internal homework detail macros have default values and do not 57 | % have to be specified manually. 58 | \def\@hwname{Homework} 59 | \def\@problemname{Problem} 60 | \def\@solutionname{Solution} 61 | % The homework title is determined by the course name, homework name, and 62 | % homework number, and cannot be changed by the user (without redefining 63 | % \@hwtitle). 64 | \def\@hwtitle{\@course\ \@hwname\ \@hwnum} 65 | 66 | % The following macros let the user specify the values of the internal homework 67 | % detail macros defined above. 68 | 69 | % The following four macros must be used in the preamble. 70 | \def\name#1{\renewcommand\@name{#1}} 71 | \def\course#1{\renewcommand\@course{#1}} 72 | \def\term#1{\renewcommand\@term{#1}} 73 | \def\hwnum#1{\renewcommand\@hwnum{#1}} 74 | % The following just redefine default values and are therefore optional 75 | \def\hwname#1{\renewcommand\@hwname{#1}} 76 | \def\solutionname#1{\renewcommand\@solutionname{#1}} 77 | \def\problemname#1{\renewcommand\@problemname{#1}} 78 | 79 | 80 | %%%%%%%%%%%%%%%%%%% 81 | % Page formatting % 82 | %%%%%%%%%%%%%%%%%%% 83 | 84 | % Set up page headers and footers using the `fancyhdr' package 85 | \RequirePackage{fancyhdr} 86 | \renewcommand\headrulewidth{0pt} 87 | % First page style 88 | \fancypagestyle{firstpage} 89 | { 90 | \fancyhf{} 91 | \fancyhead[R]{{\@name}\\{\@term}} 92 | \fancyfoot[C]{\small\thepage} 93 | } 94 | % Subsequent page style 95 | \fancypagestyle{runningpage} 96 | { 97 | \fancyhf{} 98 | \fancyhead[L]{\small\@hwtitle} 99 | \fancyhead[R]{\small\@name} 100 | \fancyfoot[C]{\small\thepage} 101 | } 102 | \pagestyle{runningpage} 103 | 104 | % Specify how the title is printed 105 | \renewcommand\maketitle 106 | { 107 | \thispagestyle{firstpage} 108 | \begingroup 109 | \center 110 | \sffamily\bfseries\Large\@hwtitle 111 | \endcenter 112 | \endgroup 113 | } 114 | % The title is printed automatically, no need to type \maketitle manually 115 | \AtBeginDocument{\maketitle} 116 | 117 | 118 | %%%%%%%%%%%%%%%%% 119 | % Miscellaneous % 120 | %%%%%%%%%%%%%%%%% 121 | 122 | \RequirePackage{lmodern} % Use the Latin Modern font 123 | \RequirePackage[utf8]{inputenc} % Use UTF-8 encoding 124 | \RequirePackage[T1]{fontenc} % Use Type 1 fonts 125 | \RequirePackage{microtype} % Microtypography package 126 | 127 | % Insert hyperlinks to internal or external links 128 | \RequirePackage[bookmarks=true, hidelinks]{hyperref} 129 | 130 | % Add student name and homework title to the PDF document metadata 131 | \AtBeginDocument{ 132 | \hypersetup{ 133 | pdfauthor={\@name}, 134 | pdftitle={\@hwtitle}, 135 | } 136 | } 137 | 138 | % Mathematics packages 139 | \RequirePackage{amsmath, amsthm, amssymb} 140 | \RequirePackage{mathtools} 141 | 142 | 143 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 144 | % Problem, parts, solution, and claim environments % 145 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 146 | 147 | % Problem environment 148 | \ifHW@boxes 149 | \RequirePackage{framed} 150 | \fi 151 | \theoremstyle{definition} 152 | \newtheorem{@problem}{\sffamily\@problemname} 153 | \numberwithin{equation}{@problem} 154 | \numberwithin{table}{@problem} 155 | \numberwithin{figure}{@problem} 156 | \newenvironment{problem}[1][] 157 | { 158 | \ifHW@boxes 159 | \framed 160 | \vspace{-1.5ex} 161 | \fi 162 | \def\@arg{#1} 163 | \ifx\@arg\empty 164 | \@problem 165 | \else 166 | \@problem[\normalfont\@arg\sffamily] 167 | \fi 168 | \pdfbookmark{\@problemname\ \arabic{@problem}}{\arabic{@problem}} 169 | } 170 | { 171 | \end@problem 172 | \ifHW@boxes 173 | \vspace{-1.5ex} 174 | \endframed 175 | \fi 176 | } 177 | 178 | % Problems are numbered 1, 2, 3, ... by default 179 | % If a custom problem number is desired for a particular problem, use the 180 | % following macro before the problem. 181 | \def\problemnumber#1{\setcounter{@problem}{#1}\addtocounter{@problem}{-1}} 182 | 183 | % Parts environment 184 | % By default, parts are labeled by lowercase letters. 185 | % The parts environment provides options for other labels: 186 | % `a' (default) lowercase letters 187 | % `A' uppercase letters 188 | % `r' lowercase Roman numerals 189 | % `R' uppercase Roman numerals 190 | % `n' numbers 191 | \RequirePackage{enumitem} 192 | 193 | % Define parts environment option actions 194 | \@namedef{partlabel@a}{\def\@partlabel{\textup{(\alph*)}}} 195 | \@namedef{partlabel@A}{\def\@partlabel{\textup{(\Alph*)}}} 196 | \@namedef{partlabel@r}{\def\@partlabel{\textup{(\roman*)}}} 197 | \@namedef{partlabel@R}{\def\@partlabel{\textup{(\Roman*)}}} 198 | \@namedef{partlabel@n}{\def\@partlabel{\textup{(\arabic*)}}} 199 | 200 | % Actual parts environment 201 | \newenvironment{parts}[1][a] 202 | { 203 | % Process option (default is `a') 204 | \@ifundefined{partlabel@#1} 205 | { 206 | \@latex@error{Invalid parts environment option: #1}\@ehc 207 | } 208 | { 209 | \@nameuse{partlabel@#1} 210 | } 211 | \renewcommand\part\item 212 | \ % Make the list always starts on a new line 213 | \enumerate 214 | [ label=\@partlabel, 215 | , itemsep=1pt 216 | , parsep=1pt 217 | , topsep=0pt 218 | , partopsep=100pt 219 | , labelindent=0pt 220 | , labelwidth=4.5em 221 | , labelsep=0.5em 222 | , resume 223 | ] 224 | } 225 | { 226 | \endenumerate 227 | } 228 | \def\unresume{\setcounter{enumi}{0}} 229 | 230 | % Solution environment 231 | \ifHW@hidesolutions 232 | % Hide solutions if the `hidesolutions' class option is enabled 233 | \RequirePackage{comment} 234 | \excludecomment{solution} 235 | \else 236 | % This is a modification of the `proof' environment from the amsthm package 237 | \newenvironment{solution}[1][\@solutionname] 238 | { 239 | \par 240 | \ifHW@qed 241 | \pushQED{\qed} 242 | \else 243 | \renewcommand\qedhere{} 244 | \fi 245 | \normalfont \topsep6\p@\@plus6\p@\relax 246 | \trivlist 247 | \item[\hskip\labelsep 248 | \sffamily\bfseries#1\@addpunct{.}]\ignorespaces 249 | } 250 | { 251 | \ifHW@qed 252 | \popQED 253 | \fi 254 | \endtrivlist\@endpefalse 255 | } 256 | \fi 257 | 258 | % 'claim' environment for better organization of claims made within a problem 259 | % solution. 260 | \def\@defaultclaimname{Claim} 261 | \newenvironment{claim}[1][\@defaultclaimname]{ 262 | \begin{quote} 263 | \textsf{\textbf{#1\@addpunct{.}}} 264 | } 265 | { 266 | \end{quote}\noindent 267 | } 268 | 269 | % Some common alternative uses of the 'claim' environment 270 | \newcommand{\newclaim}[2]{\newenvironment{#1}{\begin{claim}[#2]}{\end{claim}}} 271 | \newclaim{lemma}{Lemma} 272 | \newclaim{proposition}{Proposition} 273 | \newclaim{theorem}{Theorem} 274 | \newclaim{corollary}{Corollary} 275 | \newclaim{remark}{Remark} 276 | 277 | % The 'proof' environment is re-defined to serve as a proof environment for 278 | % claims made within a problem 279 | \let\proof\@undefined 280 | \let\endproof\@undefined 281 | \newclaim{proof}{Proof} 282 | 283 | % Remove indentation after 'claim' and all the related environments 284 | \RequirePackage{noindentafter} 285 | \NoIndentAfterEnv{claim} 286 | \NoIndentAfterEnv{lemma} 287 | \NoIndentAfterEnv{proposition} 288 | \NoIndentAfterEnv{theorem} 289 | \NoIndentAfterEnv{corollary} 290 | \NoIndentAfterEnv{remark} 291 | \NoIndentAfterEnv{proof} 292 | -------------------------------------------------------------------------------- /template.tex: -------------------------------------------------------------------------------- 1 | \documentclass{homework} 2 | 3 | % This is a slightly-more-than-minimal document that uses the homework class. 4 | % See the README at http://git.io/vZWL0 for complete documentation. 5 | 6 | \name{(Your Name)} % Replace (Your Name) with your name. 7 | \term{(Current Term)} % Replace (Current Term) with the current term. 8 | \course{(Course Name)} % Replace (Course Name) with the course name. 9 | \hwnum{(Number)} % Replace (Number) with the number of the homework. 10 | 11 | %\hwname{(Name)} % Uncomment and replace (Name) with the type of the 12 | % homework (e.g, Assignment, Problem Set, etc.) if you 13 | % don't want the document to be labeled as "Homework." 14 | %\problemname{(Name)} % Uncomment and replace (Name) with the desired label 15 | % for problems created with the problem environment. 16 | %\solutionname{(Name)} % Uncomment and replace (Name) with the desired label 17 | % for solutions created with the solution environment. 18 | 19 | % Load any other packages you need here. 20 | 21 | \begin{document} 22 | 23 | \begin{problem} 24 | Write the problem statement here. 25 | \end{problem} 26 | 27 | \begin{solution} 28 | Write the solution here. 29 | \end{solution} 30 | 31 | \end{document} 32 | --------------------------------------------------------------------------------