summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/easy-todo/easy-todo.sty
blob: 359475fe23c2fbcbbd17151cd4c7b8f0e81f64d1 (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% Created by Juan Rada-Vilela
% jcrada@fuzzylite.com

\NeedsTeXFormat{LaTeX2e} 
\ProvidesPackage{easy-todo}[2014/01/01]

\def\@todoindexas{section}
\newcommand{\todoindexas}[1]{\def\@todoindexas{#1}}

\def\@todoenable{true}
\newcommand{\todoenable}[1]{\def\@todoenable{#1}}

\def\@todoobeyfinal{false}
\newcommand{\todoobeyfinal}[1]{\def\@todoobeyfinal{#1}}

\DeclareOption{chapter}{\todoindexas{chapter}}
\DeclareOption{section}{\todoindexas{section}}
\DeclareOption{obeyFinal}{\todoobeyfinal{true}}
\DeclareOption{enable}{\todoenable{true}}
\DeclareOption{disable}{\todoenable{false}}


\DeclareOption*{% 
	\PackageError{easy-todo}{What is \CurrentOption ?}{Options available:  enable, disable, obeyFinal, chapter, section}% 
	\todoindexas{chapter}
} 

\ProcessOptions

\RequirePackage{color} %to add colour
\RequirePackage{tocloft} %to create index
\RequirePackage{ifthen} %to ifthenelse conditions
\RequirePackage{ifdraft} %to detect draft/final options

\newcommand{\todoindextitle}{ToDo}
\newcommand{\todoindexpagetitle}{P.}
\newcommand{\todocolor}{\color{red}}

\newcommand{\listoftodosname}{\todoindextitle} 
\newlistof[part]{todos}{lod}{\listoftodosname} 

%Command: listoftodos
%Description: Creates the todo list (Section or Chapter)
\renewcommand{\listoftodos}{
	{
	\ifthenelse{\equal{\@todoenable}{true}}
	{
	\todocolor
	\ifthenelse{\equal{\@todoindexas}{chapter}}
		{\chapter*{\todoindextitle}}
		{
			\ifthenelse{\equal{\@todoindexas}{section}}
				{\centering\section*{\todoindextitle}}
				{\PackageError{easy-todo}{Index as \@todoindexas NOT valid}{Choose between chapter or section}}
		}
	\flushright{\textbf{\todoindexpagetitle}}
	\@starttoc{lod}}
	\newpage
	}
	{}
}

\renewcommand{\thetodos}{\@arabic\c@todos}
%Command: todo
%Description: Creates a todo note with the number and information
%Parameter: TODO note
\newcommand{\todo}[1]{%
\todoii{#1}{#1}\unskip%
}

%Command: todoi
%Description: Creates a todo note with just a number
%Parameters: [1] the information to show at the list
\newcommand{\todoi}[1]{%
\todoii{}{#1}\unskip%
}

%Command: todoii
%Description: Creates a todo note
%Parameters: [1] the note to show, [2] the information to show at the list
\newcommand{\todoii}[2]{%
\ifthenelse{\equal{\@todoobeyfinal}{true}}{%
    \ifoptionfinal{\todoenable{false}}{\todoenable{true}}%
}{}%
\ifthenelse{\equal{\@todoenable}{true}}{%
\refstepcounter{todos}%
\noindent{\todocolor\normalfont\scriptsize{\bfseries{\thetodos.#1}}}%
\addcontentsline{lod}{todos}{\protect{\thetodos. }#2}%
}{}%
}