-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomework-template-macros.tex
79 lines (72 loc) · 1.76 KB
/
homework-template-macros.tex
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
\usepackage{etoolbox} % for ifdefempty (checking for empty strings)
\usepackage{ifthen} % For more advanced logic
\newboolean{gradescope}
\setboolean{gradescope}{false}
\newcounter{problem}
\newcounter{qpart}[problem]
\newboolean{showquestiontext}
\setboolean{showquestiontext}{true}
\newcommand{\questiontext}{}
\newcommand{\question}[1]
{
\renewcommand{\questiontext}{#1}
\ifshowquestiontext
\begin{trivlist}
\item[\hskip \labelsep {\bfseries\Large Problem \arabic{problem}: \problemname}]
\item \ifdefempty{\questiontext}{}{\noindent \questiontext}
\end{trivlist}
\setboolean{showquestiontext}{false}
\fi
}
\newcommand{\subquestion}[1]
{
\ifgradescope
\ifdobreak
\newpage
\fi
\fi
\ifshowquestiontext
\begin{trivlist}
\item[\hskip \labelsep {\bfseries\Large Problem \arabic{problem}: \problemname}]
\item \ifdefempty{\questiontext}{}{\noindent \questiontext}
\end{trivlist}
\fi
\ifgradescope
\setboolean{showquestiontext}{true}
\fi
\stepcounter{qpart}
\begin{trivlist}
\item \textbf{Part \arabic{qpart}:} #1
\end{trivlist}
\setboolean{dobreak}{true}
}
\newcommand{\solution}[1]
{
\setboolean{dobreak}{false}
\begin{trivlist}
\item \textbf{Solution:} #1
\end{trivlist}
\ifgradescope
\newpage
\fi
}
\newcommand{\problemname}{}
\newenvironment{problem}[1]
{
\stepcounter{problem}
\renewcommand{\problemname}{#1}
\renewcommand{\questiontext}{}
\begin{trivlist}
\item
}
{
\end{trivlist}
\ifgradescope
\newpage
\else
\vspace{0.5cm}
\fi
\renewcommand{\questiontext}{}
}
\newboolean{dobreak}
\setboolean{dobreak}{false}