diff options
Diffstat (limited to 'macros/latex/contrib/homework')
19 files changed, 157 insertions, 60 deletions
diff --git a/macros/latex/contrib/homework/README.md b/macros/latex/contrib/homework/README.md index 57da7f2d66..e33fcf609d 100644 --- a/macros/latex/contrib/homework/README.md +++ b/macros/latex/contrib/homework/README.md @@ -4,7 +4,7 @@ ## Introduction -The current document class is for writing homework. It has the following features. +The current document class is for writing homework or assignment. It has the following features. - Simple and clear interface. - 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. - Multilingual support: currently supporting Chinese (both simplified and traditional), English, French, German, Italian, Japanese, Portuguese (European and Brazilian), Russian and Spanish. @@ -36,16 +36,23 @@ These are necessary if you wish to write your document in Chinese (either simpli ## Usage +> It is recommended that you start by looking at one of the demo documents that suits your need and edit the code there to get your own template. + +> If you don't find what you were 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). + A typical homework document looks like this: ```latex \documentclass[a4paper, 11pt, + % twoside, % Use this option if you wish to use double-sided printing logo = {image-of-university-logo}, % Remove this line if you don't want logo presented. % logo height = 1cm, % In case you are not satisfied with the default logo size. title in boldface, title in sffamily, theorem in new line, - % twoside, % Use this option if you wish to use double-sided printing + % remove qed, % Remove the Q.E.D. symbol for problems/questions/lemmas/... + colored solution, % Show solution/answer with color, default is blue + % You may specify this as "colored solution = ⟨color⟩" % hide solution, % Use this option to hide the solutions/answers ]{homework} @@ -175,11 +182,13 @@ Alternatively, if you are making an exercise sheet and prefer a more formal titl > You may refer to the demo documents for more examples. Regarding some of the class options: -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⟩}`. +1) As usual, the option `twoside` is for double-sided printing. +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⟩}`. 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. 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. -1) The option `twoside` is for double-sided printing. -1) The option `formal title` is for enabling the formal title style. +1) The option `remove qed` is for removing the Q.E.D. symbol for theorem-type environment. +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. +1) The option `colored solution` or `colored solution = ⟨color⟩` is for setting the text color of the solution/answer. 1) The option `hide solution` (or `hide answer`) is for hiding the `solution` and `answer` environments. A few extra remarks: diff --git a/macros/latex/contrib/homework/homework-demo-cn.pdf b/macros/latex/contrib/homework/homework-demo-cn.pdf Binary files differindex 6236b301e1..3bd812c402 100644 --- a/macros/latex/contrib/homework/homework-demo-cn.pdf +++ b/macros/latex/contrib/homework/homework-demo-cn.pdf diff --git a/macros/latex/contrib/homework/homework-demo-cn.tex b/macros/latex/contrib/homework/homework-demo-cn.tex index 79f28d7860..d3a384464f 100644 --- a/macros/latex/contrib/homework/homework-demo-cn.tex +++ b/macros/latex/contrib/homework/homework-demo-cn.tex @@ -1,10 +1,12 @@ \documentclass[11pt, + % twoside, logo = {example-image}, % logo height = 1cm, % logo width = 2cm, title in boldface, % title in sffamily, theorem in new line, - % twoside, + % remove qed, + colored solution, ]{homework} %% For highlighting the code in this document @@ -86,7 +88,7 @@ \bigskip\textcolor{gray!55}{(如果你想为一个大问题中的每个小问题分别撰写解答…)} \begin{problem}[一个由很多小问题构成的大问题] - \begin{enumerate}[itemsep=.5\baselineskip] + \begin{enumerate} \item 第一个问题。 \begin{solution} @@ -95,7 +97,7 @@ \item 第二个问题。 - \begin{enumerate}[itemsep=.3\baselineskip] + \begin{enumerate} \item 第一个小问。 \begin{solution} diff --git a/macros/latex/contrib/homework/homework-demo-de.pdf b/macros/latex/contrib/homework/homework-demo-de.pdf Binary files differindex 03ea38e7e0..fa13a296aa 100644 --- a/macros/latex/contrib/homework/homework-demo-de.pdf +++ b/macros/latex/contrib/homework/homework-demo-de.pdf diff --git a/macros/latex/contrib/homework/homework-demo-de.tex b/macros/latex/contrib/homework/homework-demo-de.tex index 09c3c123e6..4bd1e27e08 100644 --- a/macros/latex/contrib/homework/homework-demo-de.tex +++ b/macros/latex/contrib/homework/homework-demo-de.tex @@ -1,10 +1,12 @@ \documentclass[11pt, + % twoside, logo = {example-image}, % logo height = 1cm, % logo width = 2cm, title in boldface, % title in sffamily, theorem in new line, - % twoside, + % remove qed, + colored solution, ]{homework} %% For highlighting the code in this document @@ -86,7 +88,7 @@ \bigskip\textcolor{gray!55}{(Wenn Sie jede Unterfrage eines Problems einzeln beantworten möchten ...)} \begin{problem}[Ein Problem mit vielen Unterfragen] - \begin{enumerate}[itemsep=.5\baselineskip] + \begin{enumerate} \item Die erste Frage. \begin{solution} @@ -95,7 +97,7 @@ \item Die zweite Frage. - \begin{enumerate}[itemsep=.3\baselineskip] + \begin{enumerate} \item Die erste Unterfrage. \begin{solution} diff --git a/macros/latex/contrib/homework/homework-demo-en.pdf b/macros/latex/contrib/homework/homework-demo-en.pdf Binary files differindex ebd75dba40..2bd8f40f4d 100644 --- a/macros/latex/contrib/homework/homework-demo-en.pdf +++ b/macros/latex/contrib/homework/homework-demo-en.pdf diff --git a/macros/latex/contrib/homework/homework-demo-en.tex b/macros/latex/contrib/homework/homework-demo-en.tex index a4840d2948..c41d49ba46 100644 --- a/macros/latex/contrib/homework/homework-demo-en.tex +++ b/macros/latex/contrib/homework/homework-demo-en.tex @@ -1,10 +1,12 @@ \documentclass[11pt, + % twoside, logo = {example-image}, % logo height = 1cm, % logo width = 2cm, title in boldface, % title in sffamily, theorem in new line, - % twoside, + % remove qed, + colored solution, ]{homework} %% For highlighting the code in this document @@ -83,7 +85,7 @@ \bigskip\textcolor{gray!55}{(If you wish to answer each sub-question of a problem separately...)} \begin{problem}[A problem with many sub-questions] - \begin{enumerate}[itemsep=.5\baselineskip] + \begin{enumerate} \item First question. \begin{solution} @@ -92,7 +94,7 @@ \item Second question. - \begin{enumerate}[itemsep=.3\baselineskip] + \begin{enumerate} \item First sub-question. \begin{solution} diff --git a/macros/latex/contrib/homework/homework-demo-es.pdf b/macros/latex/contrib/homework/homework-demo-es.pdf Binary files differindex 530d8b016f..2e02644a1e 100644 --- a/macros/latex/contrib/homework/homework-demo-es.pdf +++ b/macros/latex/contrib/homework/homework-demo-es.pdf diff --git a/macros/latex/contrib/homework/homework-demo-es.tex b/macros/latex/contrib/homework/homework-demo-es.tex index 63ded1fe95..419e8dfd64 100644 --- a/macros/latex/contrib/homework/homework-demo-es.tex +++ b/macros/latex/contrib/homework/homework-demo-es.tex @@ -1,10 +1,12 @@ \documentclass[11pt, + % twoside, logo = {example-image}, % logo height = 1cm, % logo width = 2cm, title in boldface, % title in sffamily, theorem in new line, - % twoside, + % remove qed, + colored solution, ]{homework} %% For highlighting the code in this document @@ -86,7 +88,7 @@ \bigskip\textcolor{gray!55}{(Si desea responder cada subpregunta de un problema individualmente...)} \begin{problem}[Un problema con muchas subpreguntas] - \begin{enumerate}[itemsep=.5\baselineskip] + \begin{enumerate} \item La primera pregunta. \begin{solution} @@ -95,7 +97,7 @@ \item La segunda pregunta. - \begin{enumerate}[itemsep=.3\baselineskip] + \begin{enumerate} \item La primera subpregunta. \begin{solution} diff --git a/macros/latex/contrib/homework/homework-demo-fr.pdf b/macros/latex/contrib/homework/homework-demo-fr.pdf Binary files differindex b98eed2126..4d7c3941e8 100644 --- a/macros/latex/contrib/homework/homework-demo-fr.pdf +++ b/macros/latex/contrib/homework/homework-demo-fr.pdf diff --git a/macros/latex/contrib/homework/homework-demo-fr.tex b/macros/latex/contrib/homework/homework-demo-fr.tex index b8394edda5..58f6677505 100644 --- a/macros/latex/contrib/homework/homework-demo-fr.tex +++ b/macros/latex/contrib/homework/homework-demo-fr.tex @@ -1,10 +1,12 @@ \documentclass[11pt, + % twoside, logo = {example-image}, % logo height = 1cm, % logo width = 2cm, title in boldface, % title in sffamily, theorem in new line, - % twoside, + % remove qed, + colored solution, ]{homework} %% For highlighting the code in this document @@ -86,7 +88,7 @@ \bigskip\textcolor{gray!55}{(Si vous souhaitez répondre individuellement à chaque sous-question d'un problème...)} \begin{problem}[Un problème avec de nombreuses sous-questions] - \begin{enumerate}[itemsep=.5\baselineskip] + \begin{enumerate} \item La première question. \begin{solution} @@ -95,7 +97,7 @@ \item La deuxième question. - \begin{enumerate}[itemsep=.3\baselineskip] + \begin{enumerate} \item La première sous-question. \begin{solution} diff --git a/macros/latex/contrib/homework/homework-demo-jp.pdf b/macros/latex/contrib/homework/homework-demo-jp.pdf Binary files differindex 4439738e75..fee9139a2a 100644 --- a/macros/latex/contrib/homework/homework-demo-jp.pdf +++ b/macros/latex/contrib/homework/homework-demo-jp.pdf diff --git a/macros/latex/contrib/homework/homework-demo-jp.tex b/macros/latex/contrib/homework/homework-demo-jp.tex index 4ee7d4c62b..16e797f014 100644 --- a/macros/latex/contrib/homework/homework-demo-jp.tex +++ b/macros/latex/contrib/homework/homework-demo-jp.tex @@ -1,10 +1,12 @@ \documentclass[11pt, + % twoside, logo = {example-image}, % logo height = 1cm, % logo width = 2cm, title in boldface, % title in sffamily, theorem in new line, - % twoside, + % remove qed, + colored solution, ]{homework} %% For highlighting the code in this document @@ -84,7 +86,7 @@ \bigskip\textcolor{gray!55}{(問題の各小問に個別に回答したい場合は…)} \begin{problem}[多くの小問がある問題] - \begin{enumerate}[itemsep=.5\baselineskip] + \begin{enumerate} \item 一番目の問題。 \begin{solution} @@ -93,7 +95,7 @@ \item 二番目の問題。 - \begin{enumerate}[itemsep=.3\baselineskip] + \begin{enumerate} \item 一番目の小問。 \begin{solution} diff --git a/macros/latex/contrib/homework/homework-demo-tc.pdf b/macros/latex/contrib/homework/homework-demo-tc.pdf Binary files differindex 2860d04f15..021d5d0da1 100644 --- a/macros/latex/contrib/homework/homework-demo-tc.pdf +++ b/macros/latex/contrib/homework/homework-demo-tc.pdf diff --git a/macros/latex/contrib/homework/homework-demo-tc.tex b/macros/latex/contrib/homework/homework-demo-tc.tex index 1ceea979e6..4779b43ef2 100644 --- a/macros/latex/contrib/homework/homework-demo-tc.tex +++ b/macros/latex/contrib/homework/homework-demo-tc.tex @@ -1,10 +1,12 @@ \documentclass[11pt, + % twoside, logo = {example-image}, % logo height = 1cm, % logo width = 2cm, title in boldface, % title in sffamily, theorem in new line, - % twoside, + % remove qed, + colored solution, ]{homework} %% For highlighting the code in this document @@ -86,7 +88,7 @@ \bigskip\textcolor{gray!55}{(如果你想為一個大問題中的每個小問題分別撰寫解答…)} \begin{problem}[一個由許多小問題構成的大問題] - \begin{enumerate}[itemsep=.5\baselineskip] + \begin{enumerate} \item 第一個問題。 \begin{solution} @@ -95,7 +97,7 @@ \item 第二個問題。 - \begin{enumerate}[itemsep=.3\baselineskip] + \begin{enumerate} \item 第一個小問。 \begin{solution} diff --git a/macros/latex/contrib/homework/homework-example-sheet-answer.pdf b/macros/latex/contrib/homework/homework-example-sheet-answer.pdf Binary files differindex 44a2eb9724..482094bf5d 100644 --- a/macros/latex/contrib/homework/homework-example-sheet-answer.pdf +++ b/macros/latex/contrib/homework/homework-example-sheet-answer.pdf diff --git a/macros/latex/contrib/homework/homework-example-sheet.pdf b/macros/latex/contrib/homework/homework-example-sheet.pdf Binary files differindex a4640b04f9..f73aace2fe 100644 --- a/macros/latex/contrib/homework/homework-example-sheet.pdf +++ b/macros/latex/contrib/homework/homework-example-sheet.pdf diff --git a/macros/latex/contrib/homework/homework-example-sheet.tex b/macros/latex/contrib/homework/homework-example-sheet.tex index 00f703f5c1..050898e251 100644 --- a/macros/latex/contrib/homework/homework-example-sheet.tex +++ b/macros/latex/contrib/homework/homework-example-sheet.tex @@ -1,9 +1,11 @@ \documentclass[a4paper, 11pt, + % twoside, formal title, title in boldface, % title in sffamily, % theorem in new line, - % twoside, + % remove qed, + colored solution, hide solution, % Use this option to hide the solutions/answers ]{homework} @@ -43,6 +45,7 @@ We shall show that... \begin{problem} A preliminary result. \end{problem} + \begin{solution} \blindtext \end{solution} @@ -52,6 +55,7 @@ We shall show that... \blindtext \end{problem} + \begin{solution} \blindtext[2] \end{solution} @@ -64,61 +68,90 @@ At this stage, we may conclude that... Now we look at... \begin{problem}[Some prepration] + This is the prepration for... - \begin{enumerate}%[itemsep=.5\baselineskip] - \item First question. - \begin{solution} - \blindtext - \end{solution} - \item Second question. - \begin{solution} - \blindtext - \end{solution} - \item Third question. - \qedhere - \begin{solution} - \blindtext - \end{solution} + + \begin{enumerate} + + \item + First question. + + \begin{solution} + \blindtext + \end{solution} + + \item + Second question. + + \begin{solution} + \blindtext + \end{solution} + + \item + Third question. + \qedhere + + \begin{solution} + \blindtext + \end{solution} + \end{enumerate} \end{problem} \begin{problem}[Another problem with many sub-questions] \leavevmode % so that the first item start in new line - \begin{enumerate}%[itemsep=.5\baselineskip] - \item First question. + \begin{enumerate} + + \item + First question. \blindtext \begin{solution} \blindtext[2] \end{solution} - \item Second question. - \begin{enumerate}%[itemsep=.3\baselineskip] - \item First sub-question. + + \item + Second question. + + \begin{enumerate} + \item + First sub-question. \blindtext \begin{solution} \blindtext[2] \end{solution} - \item Second sub-question. - \\[.3\baselineskip] + + \item + Second sub-question. + \blindtext + \begin{solution} \blindtext[2] \end{solution} + \end{enumerate} - \item Third question. - \\[.5\baselineskip] + + \item + Third question. + \blindtext[2] + \begin{solution} \blindtext[2] \end{solution} - \item Conclusion. - \qedhere - \begin{solution} - \blindtext - \end{solution} + + \item + Conclusion. + \qedhere + + \begin{solution} + \blindtext + \end{solution} + \end{enumerate} \end{problem} diff --git a/macros/latex/contrib/homework/homework.cls b/macros/latex/contrib/homework/homework.cls index 3af754dd25..29f2227f9f 100644 --- a/macros/latex/contrib/homework/homework.cls +++ b/macros/latex/contrib/homework/homework.cls @@ -12,7 +12,7 @@ \NeedsTeXFormat{LaTeX2e}[2022-06-01] \ProvidesExplClass {homework} - {2023/09/30} {} + {2023/10/01} {} {Document class for writing homework} \keys_define:nn { homework } @@ -31,6 +31,20 @@ , formal~title .bool_set:N = \l__homework_formal_title_bool , formal title .bool_set:N = \l__homework_formal_title_bool + , colored-solution .tl_set:N = \l__homework_solution_color_tl + , colored-solution .initial:n = { main-text } + , colored-solution .default:n = { cyan!50!blue!90!main-text } + , colored~solution .tl_set:N = \l__homework_solution_color_tl + , colored~solution .default:n = { cyan!50!blue!90!main-text } + , colored solution .tl_set:N = \l__homework_solution_color_tl + , colored solution .default:n = { cyan!50!blue!90!main-text } + , colored-answer .tl_set:N = \l__homework_solution_color_tl + , colored-answer .default:n = { cyan!50!blue!90!main-text } + , colored~answer .tl_set:N = \l__homework_solution_color_tl + , colored~answer .default:n = { cyan!50!blue!90!main-text } + , colored answer .tl_set:N = \l__homework_solution_color_tl + , colored answer .default:n = { cyan!50!blue!90!main-text } + , hide-solution .bool_set:N = \l__homework_hide_solution_bool , hide-solution .initial:n = { false } , hide~solution .bool_set:N = \l__homework_hide_solution_bool @@ -39,6 +53,11 @@ , hide~answer .bool_set:N = \l__homework_hide_solution_bool , hide answer .bool_set:N = \l__homework_hide_solution_bool + , remove-qed .bool_set:N = \l__homework_no_qed_bool + , remove-qed .initial:n = { false } + , remove~qed .bool_set:N = \l__homework_no_qed_bool + , remove qed .bool_set:N = \l__homework_no_qed_bool + , unknown .code:n = { \PassOptionsToClass { \CurrentOption } { minimart } \PassOptionsToClass { \CurrentOption } { einfart } @@ -53,11 +72,19 @@ \sys_if_engine_pdftex:TF { - \PassOptionsToClass { use indent = false, theorem with qed } { minimart } + \bool_if:NF \l__homework_no_qed_bool + { + \PassOptionsToClass { theorem with qed } { minimart } + } + \PassOptionsToClass { use indent = false } { minimart } \LoadClass { minimart } } { - \PassOptionsToClass { use indent = false, theorem with qed } { einfart } + \bool_if:NF \l__homework_no_qed_bool + { + \PassOptionsToClass { theorem with qed } { einfart } + } + \PassOptionsToClass { use indent = false } { einfart } \LoadClass { einfart } } @@ -213,13 +240,27 @@ , RU = { Ответ } } +\newlist{soluenumerate}{enumerate}{3} +\setlist[soluenumerate]{labelsep=*, leftmargin=*} +\setlist[soluenumerate,1]{label = \normalfont$\big(\mskip-.5mu$\arabic*$\mskip-.5mu\big)$, + ref = \normalfont\color{.!45!paper}$\big(\mskip-.5mu$\arabic*$\mskip-.5mu\big)$, + leftmargin= \l__minimalist_item_indentation_dim + 2em } +\setlist[soluenumerate,2]{label = \normalfont$\big(\mskip-.5mu$\roman*$\mskip-.5mu\big)$, + ref = \normalfont\color{.!45!paper}$\big(\mskip-.5mu$\arabic{soluenumeratei}.\roman*$\mskip-.5mu\big)$} +\setlist[soluenumerate,3]{label = \normalfont$\big(\mskip-.5mu$\emph{\alph*}$\mskip-.5mu\big)$, + ref = \normalfont\color{.!45!paper}$\big(\mskip-.5mu$\arabic{soluenumeratei}.\roman{soluenumerateii}.\emph{\alph*}$\mskip-.5mu\big)$} + \newcommand\soluline{\bgroup\markoverwith{\rule[-.45ex]{1pt}{.75pt}}\ULon} \NewDocumentEnvironment { solution } { O{ \l__homework_solution_tl } } { \par \topsep0\p@\relax + \let\enumerate\soluenumerate + \let\endenumerate\endsoluenumerate + \setlist*[1]{itemsep=0\baselineskip, parsep=.5\parskip} + \setlist*[2]{itemsep=0\baselineskip, parsep=.5\parskip} \trivlist - \color{cyan!50!blue!90!main-text} + \color{\l__homework_solution_color_tl} \item[\hskip\labelsep\soluline{#1}\nobreakspace\nobreakspace] \let\qedsymbol\customqedsymbol \ignorespaces @@ -278,7 +319,7 @@ \setlist*[2]{itemsep=0\baselineskip, parsep=\parskip} } { - \setlist*[1]{itemsep=.5\baselineskip, parsep=\parskip} + \setlist*[1]{itemsep=.5\baselineskip, parsep=\parskip, after*=\medskip} \setlist*[2]{itemsep=.3\baselineskip, parsep=\parskip} } |