Debian Codegraph @

texmf-dist/doc/latex/homework/README.md

raw
1 <!-- Copyright (C) 2023-2026 by Jinwen XU -->
2
3 # `homework`, a LaTeX class for writing your homework
4
5 ## Introduction
6
7 The current document class is for writing homework or assignment. It has the following features.
8 - Simple and clear interface.
9 - Built-in support for many theorem-type environments, already configured and ready to use (in the mean time also very customizable, via `\SetTheorem`), with clever referencing supported.
10 - Multilingual support: currently supporting Chinese (both simplified and traditional), English, French, German, Italian, Japanese, Portuguese (European and Brazilian), Russian and Spanish.
11 - Page numbers are of the form `Page [current] of [total]`, which can help you ensure that there are no missing pages when you print your homework for submission.
12 - Support writing problem statements and solutions (or proofs) in different colors.
13 - Every statement and solution has its own Q.E.D. symbol, in hollow or solid shape, respectively.
14 - You may mark unfinished parts with `\DNF` or `\DNF<⟨remark⟩>` (meaning "did not finish") for reminding — this will give you a clickable report on the unfinished parts at the end of your document.
15
16 > Package dependencies: [*`einfart`*](https://ctan.org/pkg/einfart), [`lastpage`](https://ctan.org/pkg/lastpage), [`minimalist`](https://ctan.org/pkg/minimalist), [`projlib`](https://ctan.org/pkg/projlib), [`verbatim`](https://ctan.org/pkg/verbatim).
17
18 ## Installation and preparation
19
20 ### How to install this package
21
22 If you are using TeX Live 2024 or newer, or the most recent version of MiKTeX, then this package should already be included, and you don't need to do anything.
23
24 Otherwise, you need to check for package update to see if you can receive it. In case not, you can always go to [the CTAN page](https://ctan.org/pkg/homework) to download the `.zip` file with all related files included.
25
26 ### Regarding the fonts
27
28 If you are using a Unicode TeX engine, then the current document class requires the following open-source fonts that are not included in the standard TeX collection:
29
30 - The Source Han font series at [Adobe Fonts](https://github.com/adobe-fonts). More specifically:
31 - Source Han Serif, [go to its Release page](https://github.com/adobe-fonts/source-han-serif/releases).
32 - Source Han Sans, [go to its Release page](https://github.com/adobe-fonts/source-han-sans/releases).
33 - Source Han Mono, [go to its Release page](https://github.com/adobe-fonts/source-han-mono/releases).
34 > It is recommended to download the Super-OTC version, so that the total download size would be smaller, and the installation would be easier.
35
36 These are necessary if you wish to write your document in Chinese (either simplified or traditional) or Japanese.
37 Also, without these fonts installed, the compilation speed might be much slower — the compilation would still pass, but the system shall spend (quite) some time verifying that the fonts are indeed missing before switching to the fallback fonts.
38
39
40 ## Usage
41
42 > It is recommended that you start by looking at one of the [demo documents](https://github.com/Jinwen-XU/homework/tree/main/demo) that suits your need and edit the code there to get your own template.
43
44 > If you cannot find what you are expecting, or if you would like some elements to be changed or improved, feel free to post a feature request via [the GitHub issue](https://github.com/Jinwen-XU/homework/issues).
45
46 A typical homework document looks like this:
47
48 ```latex
49 \documentclass[a4paper, 11pt,
50 % twoside, % Use this option if you wish to use double-sided printing.
51 logo = {image-of-university-logo}, % Remove this line if you don't want logo presented.
52 % logo height = 1cm, % In case you are not satisfied with the default logo size.
53 title in boldface,
54 title in sffamily,
55 theorem in new line, % Print the theorem title in a separate line.
56 % remove qed, % Remove the Q.E.D. symbols,
57 % or only remove part of the Q.E.D. symbols,
58 % via "remove problem qed" or "remove solution qed".
59 colored solution, % Show solution/answer with color, default is blue.
60 % You may specify this as "colored solution = ⟨color⟩".
61 % hide solution, % Use this option to hide the solutions/answers.
62 ]{homework}
63
64 \UseLanguage{...} % If you wish to write your homework in languages other than English.
65
66
67 \title{The Subject, Week 1}
68 \author{Author NAME}
69 \date{\TheDate{2026-01-01}, Location} % or: \date{\today[only-year-month], Location}
70
71
72 \begin{document}
73
74
75 % If you wish to write the answer directly...
76
77 \begin{problem}
78 Here lies the solution / proof.
79 \end{problem}
80
81
82 % If you wish to state the problem and then write your answer...
83
84 \begin{problem}[You can add some brief problem description here]
85 You may also state the problem here...
86 \end{problem}
87
88 \begin{solution}% You may also use the "answer" environment, they are essentially the same.
89 ... and write the solution here...
90 \end{solution}
91
92
93 % If you prefer "Proof" instead of "Solution"...
94
95 \begin{solution}[Proof]
96 % You may write claims, lemmas, propositions, etc. inside your solution.
97 \begin{lemma}\label{lem}
98 Some auxiliary result.
99 \end{lemma}
100 \begin{proof}
101 The proof of \cref{lem}, where we use the following formula:
102 \[
103 \infty = \infty + 1.
104 \qedhere % For placing the Q.E.D. symbol in the right place.
105 \]
106 \end{proof}
107 \begin{fact}[This statement requires no proof]
108 \proofless % To change the hollow box marking the end of a theorem-type environment into a solid one.
109 Some statement.
110 \end{fact}
111 ... and the rest steps...
112 \end{solution}
113
114
115 % If you wish to answer each sub-question of a problem separately...
116
117 \begin{problem}[A problem with many sub-questions]
118 \begin{enumerate}
119 \item First question.
120
121 \begin{solution}
122 The solution of the first question.
123 \end{solution}
124
125 \item Second question.
126
127 \begin{enumerate}
128 \item First sub-question.
129
130 \begin{solution}
131 The solution of the first sub-question.
132 \end{solution}
133
134 \item Second sub-question.
135
136 \begin{solution}
137 The solution of the second sub-question.
138 \end{solution}
139
140 \end{enumerate}
141
142 \item Third question.
143
144 \begin{solution}
145 The solution of the third question.
146 \end{solution}
147
148 \end{enumerate}
149 \noQED % Use \noqed or \noQED at the end to suppress the Q.E.D. symbol that marks the end of the current problem.
150 \end{problem}
151
152
153 % If there is a question that you can't figure out how to solve at the moment...
154
155 \DNF<some description>
156
157
158 \end{document}
159 ```
160
161 Alternatively, if you are making an exercise sheet and prefer a more formal title style, you may write the title part as:
162 ```latex
163 \documentclass[a4paper,
164 formal title,
165 title in boldface,
166 % hide solution, % Use this option to hide the solutions/answers
167 ]{homework}
168
169
170 % EDIT THE FOLLOWING INFORMATION AS NEEDED
171
172 \pretitle{%
173 \scshape
174 The University
175 \hfill
176 The Program \& Level
177 \\
178 Course ID \& Course Name
179 \hfill
180 Year 2026--27
181 }
182
183 \title{%
184 Sheet 1. Title of the current file
185 }
186 \author{}
187 \date{%
188 % \TheDate{2026-01-01}
189 }
190
191
192 \begin{document}
193 ...
194 \end{document}
195 ```
196
197 > You may refer to the demo documents for more examples.
198
199 Regarding some of the class options:
200 1) As usual, the option `twoside` is for double-sided printing.
201 1) The logo image can be included via the class option `logo = {⟨image file name⟩}`, and if you are not satisfied with its default size, then you may manually specify the size via the option `logo height = {⟨height⟩}` or `logo width = {⟨width⟩}`. If you do not want to show any logo in the title bar, you may simply remove the option `logo = {⟨image file name⟩}`.
202 1) The options `title in boldface`, `title in sffamily` or even `title in scshape` are for configuring the text effect of the title line, the sectional titles and theorem names.
203 1) The option `theorem in new line` is for showing the problem / theorem name, numbering and description in a separate line, for the sake of clarity.
204 1) The option `remove qed` is for removing all the Q.E.D. symbol.
205 - If you only wish to remove the Q.E.D. symbol for problems/questions/lemmas/..., use `remove problem qed` or `remove question qed` (they are the same).
206 - If you only wish to remove the Q.E.D. symbol for solutions/answers, use `remove solution qed` or `remove answer qed` (they are the same).
207 1) The option `formal title` is for enabling the formal title style. There would be no logo and no separation lines, and the title would be centered.
208 1) The option `colored solution` or `colored solution = ⟨color⟩` is for setting the text color of the solution/answer.
209 1) The option `hide solution` (or `hide answer`) is for hiding the `solution` and `answer` environments.
210
211 A few extra remarks:
212 1) `\title`, `\author` and `\date`, etc. should be placed before `\begin{document}`.
213 1) Since the problem, solution and other theorem-type environments have a Q.E.D. symbol at the end, if your text ends with a displayed equation or a `itemize`/`enumerate`/`description` list, then you would need to add a `\qedhere` so that the Q.E.D. symbol is placed in the right place. There are also `\proofless` and `\noQED` for controlling the Q.E.D. symbol, see the demo documents for their usage.
214 1) Every theorem-type environment has a starred unnumbered version, for instance, `claim*` for unnumbered `claim`, `lemma*` for unnumbered `lemma`, etc.
215 1) It is recommended to use clever reference, such as `\cref`, `\Cref` and `\namecref`, etc. For languages such as French and German, to ensure that the generated referencing text is grammatically correct, you may write the definite article and/or declension as optional argument for the referencing commands, for instance, `\cref[à]{⟨label⟩}` or `\cref[de]{⟨label⟩}` for French, `\cref[nom.]{⟨label⟩}` or `\cref[von,dat.]{⟨label⟩}` for German, etc.
216
217
218 ## TeXnical details
219
220 ### Engines and base classes
221 - With pdfLaTeX, the base class is `minimart`.
222 - With XeLaTeX or LuaLaTeX, the base class is `einfart`.
223
224 ### Some other aspects
225
226 #### Regarding `\maketitle`
227
228 If the title is given and is not empty, then `\maketitle` shall automatically be added after `\begin{document}`, thus you don't need to write it by yourself.
229
230 > Note that, for this to work, `\title`, `\author` and `\date`, etc. should be placed before `\begin{document}`.
231
232 #### Regarding the numbering
233
234 A new counter named `homework` is defined, which is shared by the environments `problem`, `question` and `exercise`, thus you would see them numbered as `1`, `2`, `3`, etc. The other theorem-type environments are numbered within this counter `homework`, thus within, say, `Problem 1`, you would see them numbered as `Theorem 1.1`, `Lemma 1.2` and `Claim 1.3`, etc.
235
236 Therefore, if you wish to manually change the numbering, you may directly access the value of the counter `homework`. Also, each theorem-type environment has its own counter, thus it would still work if you write `\setcounter{exercise}{10}`, but this would also affect the numbering of `problem` and `question`, so don't forget to reset the value as needed.
237
238 Alternatively, you may use the command `\ManualNumbering{⟨env⟩}{⟨number⟩}`. For example, `\ManualNumbering{exercise}{A.1.1}` will change the number of the next exercise to `A.1.1`, but after that the numbering shall go back to the normal one.
239
240 If you wish these environments to be numbered separately, you may define new counters, say `problem-counter`, `question-counter` and `exercise-counter` via
241 ```latex
242 \newcounter{problem-counter}
243 \newcounter{question-counter}
244 \newcounter{exercise-counter}
245 ```
246 and then write this in your preamble:
247 ```latex
248 \SetTheorem{problem}{shared counter=problem-counter}
249 \SetTheorem{question}{shared counter=question-counter}
250 \SetTheorem{exercise}{shared counter=exercise-counter}
251 ```
252
253
254 ## Acknowledgement
255
256 The author would like to thank David García-Zelada for his valuable help with the Spanish language. He kindly demonstrated to me the difference between the "Tutoyer" and "Vouvoyer" version, patiently corrected many inaccuracies in the demo documents, and also pointed out a few improper translations in some of my other packages.
257
258 The author would also like to thank his friend Junzhuo Zhao for his valuable help with the German language. Danke schön!
259
260
261 ## License
262
263 This work is released under the LaTeX Project Public License, v1.3c or later.