Add class-option to control todos

Closes #27Signed-off-by: Adrian C. Hinrichs's avatarAdrian C. Hinrichs <adrian.hinrichs@rwth-aachen.de>
parent 3e53f328
...@@ -69,10 +69,11 @@ ...@@ -69,10 +69,11 @@
\DeclareBoolOption[false]{listings} \DeclareBoolOption[false]{listings}
\DeclareBoolOption[true]{twoside} \DeclareBoolOption[true]{twoside}
\DeclareComplementaryOption{oneside}{twoside} \DeclareComplementaryOption{oneside}{twoside}
\DeclareBoolOption[true]{twocolumn} \DeclareBoolOption[false]{twocolumn}
\DeclareComplementaryOption{onecolumn}{twocolumn} \DeclareComplementaryOption{onecolumn}{twocolumn}
\DeclareBoolOption[false]{punchmark} \DeclareBoolOption[false]{punchmark}
\DeclareStringOption[all]{hlines} \DeclareStringOption[all]{hlines}
\DeclareStringOption[all]{todos}
\ifxetex \ifxetex
\DeclareBoolOption[true]{unicodemath} \DeclareBoolOption[true]{unicodemath}
\else \else
...@@ -91,6 +92,28 @@ ...@@ -91,6 +92,28 @@
\fi \fi
\LoadClass{article} \LoadClass{article}
\newboolean{hwa@todos@inplace}
\newboolean{hwa@todos@list}
\setboolean{hwa@todos@inplace}{true}
\setboolean{hwa@todos@list}{true}
\ifthenelse{\equal{\hwa@todos}{all}}{
}{
\ifthenelse{\equal{\hwa@todos}{nolist}}{
\ClassWarning{homeworkassignment}{You specified todos=none,
there will be no list of TODO}
\setboolean{hwa@todos@list}{false}
}{
\ifthenelse{\equal{\hwa@todos}{none}}{
\ClassWarning{homeworkassignment}{You specified todos=none,
there will be no TODOs printed in the final document}
\setboolean{hwa@todos@list}{false}
\setboolean{hwa@todos@inplace}{false}
}{
\ClassError{homeworkassignment}{\hwa@todos is not a valid value
for the option `todos`}
}
}
}
\RequirePackage{hyperref} \RequirePackage{hyperref}
\ifhwa@listings \ifhwa@listings
\RequirePackage{listings} \RequirePackage{listings}
...@@ -395,22 +418,26 @@ ...@@ -395,22 +418,26 @@
\newcommand{\bigforall}{\mbox{\raisebox{-2pt}[\height][\depth]{\Large $\mathsurround4pt\forall$}}} \newcommand{\bigforall}{\mbox{\raisebox{-2pt}[\height][\depth]{\Large $\mathsurround4pt\forall$}}}
\newcommand{\bigexists}{\mbox{\raisebox{-2pt}[\height][\depth]{\Large $\mathsurround4pt\exists$}}} \newcommand{\bigexists}{\mbox{\raisebox{-2pt}[\height][\depth]{\Large $\mathsurround4pt\exists$}}}
\DeclareDocumentCommand\todo{G{}}{ \DeclareDocumentCommand\todo{G{}}{
{\color{red}\textbf{~\label{TODO\alph{todoNum}}TODO~}#1~} \ifthenelse{\boolean{hwa@todos@inplace}}{
\xdef\hwa@todoList@aux{\hwa@todoList@aux {\color{red}\textbf{~\label{TODO\alph{todoNum}}TODO~}#1~}
\string\item\string\hyperref[TODO\alph{todoNum}]{TODO #1} \xdef\hwa@todoList@aux{\hwa@todoList@aux
} \string\item\string\hyperref[TODO\alph{todoNum}]{TODO #1}
\stepcounter{todoNum} }
\stepcounter{todoNum}
}{}
} }
\newcounter{todoNum} \setcounter{todoNum}{1} \newcounter{todoNum} \setcounter{todoNum}{1}
\DeclareDocumentCommand\hwa@tableOfTodos{}{ \DeclareDocumentCommand\hwa@tableOfTodos{}{
\ifthenelse{\equal{\hwa@tableOfTodos}{}}{%Nothing \ifthenelse{\boolean{hwa@todos@list}}{
}{ \ifthenelse{\equal{\hwa@tableOfTodos}{}}{%Nothing
{\color{red} }{
\problem{Table of ToDos} {\color{red}
\begin{itemize} \problem{Table of ToDos}
\hwa@todoList \begin{itemize}
\end{itemize}} \hwa@todoList
} \end{itemize}}
}
}{}
} }
\DeclareDocumentCommand\addToGradingTable{m g}{ \DeclareDocumentCommand\addToGradingTable{m g}{
\edef\hwa@gradingtbl@aux@defs{\hwa@gradingtbl@aux@defs|p{\hwa@pointboxsize}} \edef\hwa@gradingtbl@aux@defs{\hwa@gradingtbl@aux@defs|p{\hwa@pointboxsize}}
......
...@@ -267,6 +267,13 @@ ...@@ -267,6 +267,13 @@
% \begin{macrocode} % \begin{macrocode}
\DeclareStringOption[all]{hlines} \DeclareStringOption[all]{hlines}
% \end{macrocode} % \end{macrocode}
% \DescribeMacro{todos=<1>}
% KeyValue-option. Takes which ToDos shall be displayed. Available are
% \texttt{all} (default),\texttt{nolist},\texttt{none}. See
% \autoref{cmd:TODOs} for explanation of the levels.
% \begin{macrocode}
\DeclareStringOption[all]{todos}
% \end{macrocode}
% \DescribeMacro{unicode-math} Loads the unicode--math--package and % \DescribeMacro{unicode-math} Loads the unicode--math--package and
% overwrites the damn \texttt{\textbackslash QED}--Command unicode--math % overwrites the damn \texttt{\textbackslash QED}--Command unicode--math
% introduces, that creates a filled out box and only works in % introduces, that creates a filled out box and only works in
...@@ -312,6 +319,28 @@ ...@@ -312,6 +319,28 @@
\fi \fi
\LoadClass{article} \LoadClass{article}
\newboolean{hwa@todos@inplace}
\newboolean{hwa@todos@list}
\setboolean{hwa@todos@inplace}{true}
\setboolean{hwa@todos@list}{true}
\ifthenelse{\equal{\hwa@todos}{all}}{
}{
\ifthenelse{\equal{\hwa@todos}{nolist}}{
\ClassWarning{homeworkassignment}{You specified todos=none,
there will be no list of TODO}
\setboolean{hwa@todos@list}{false}
}{
\ifthenelse{\equal{\hwa@todos}{none}}{
\ClassWarning{homeworkassignment}{You specified todos=none,
there will be no TODOs printed in the final document}
\setboolean{hwa@todos@list}{false}
\setboolean{hwa@todos@inplace}{false}
}{
\ClassError{homeworkassignment}{\hwa@todos is not a valid value
for the option `todos`}
}
}
}
% \end{macrocode} % \end{macrocode}
% Load Hyperref (breaks if it is loaded before article % Load Hyperref (breaks if it is loaded before article
% \begin{macrocode} % \begin{macrocode}
...@@ -949,7 +978,7 @@ ...@@ -949,7 +978,7 @@
\newcommand{\bigexists}{\mbox{\raisebox{-2pt}[\height][\depth]{\Large $\mathsurround4pt\exists$}}} \newcommand{\bigexists}{\mbox{\raisebox{-2pt}[\height][\depth]{\Large $\mathsurround4pt\exists$}}}
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
% \subsubsection{ToDos} % \subsubsection{ToDos\label{cmd:TODOs}}
% Utility for the Documentation of ToDos % Utility for the Documentation of ToDos
% \begin{macro}{\todo} % \begin{macro}{\todo}
% Creates a todo at the location of the command, highlighted in red. % Creates a todo at the location of the command, highlighted in red.
...@@ -957,11 +986,13 @@ ...@@ -957,11 +986,13 @@
% |todos=nolist| or |todos=none| is specified. % |todos=nolist| or |todos=none| is specified.
% \begin{macrocode} % \begin{macrocode}
\DeclareDocumentCommand\todo{G{}}{ \DeclareDocumentCommand\todo{G{}}{
{\color{red}\textbf{~\label{TODO\alph{todoNum}}TODO~}#1~} \ifthenelse{\boolean{hwa@todos@inplace}}{
\xdef\hwa@todoList@aux{\hwa@todoList@aux {\color{red}\textbf{~\label{TODO\alph{todoNum}}TODO~}#1~}
\string\item\string\hyperref[TODO\alph{todoNum}]{TODO #1} \xdef\hwa@todoList@aux{\hwa@todoList@aux
} \string\item\string\hyperref[TODO\alph{todoNum}]{TODO #1}
\stepcounter{todoNum} }
\stepcounter{todoNum}
}{}
} }
% \end{macrocode} % \end{macrocode}
% Uses the internal |hwa@todo|-counter % Uses the internal |hwa@todo|-counter
...@@ -973,14 +1004,16 @@ ...@@ -973,14 +1004,16 @@
% Prints all ToDos % Prints all ToDos
% \begin{macrocode} % \begin{macrocode}
\DeclareDocumentCommand\hwa@tableOfTodos{}{ \DeclareDocumentCommand\hwa@tableOfTodos{}{
\ifthenelse{\equal{\hwa@tableOfTodos}{}}{%Nothing \ifthenelse{\boolean{hwa@todos@list}}{
}{ \ifthenelse{\equal{\hwa@tableOfTodos}{}}{%Nothing
{\color{red} }{
\problem{Table of ToDos} {\color{red}
\begin{itemize} \problem{Table of ToDos}
\hwa@todoList \begin{itemize}
\end{itemize}} \hwa@todoList
} \end{itemize}}
}
}{}
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment