# Show all colored words at the end of document

Is there any way to show all colored words at the end of a document?

Say I'm marking definitions as red and theorems as blue.

Is it possible to make a list of "keywords" where all red words is listed, and another list with all blue words.

Something like this

\documentclass[12pt,a4paper]{article}
\usepackage{color}

\newcommand{\RC}{\textcolor{red}}
\newcommand{\BC}{\textcolor{blue}}

\begin{document}
\RC{red1} test

\BC{blue1} test

\BC{blue2} test

\RC{red2} test

\vfill

\RC{Definitions:}
\begin{itemize}
\item red1
\item red2
\end{itemize}

\bigskip

\BC{Theorems:}
\begin{itemize}
\item blue1
\item blue2
\end{itemize}
\end{document}

-
What about using thmtools's \listoftheorem macro instead? If you really want colors you can always customize it… – MickG Feb 25 at 13:15

## 1 Answer

You can use, for example, this definition of \RC, \BC:

\documentclass[12pt,a4paper]{article}
\usepackage{color}

\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\RC#1{\addto\RClist{\item#1}\textcolor{red}{#1}}
\def\BC#1{\addto\BClist{\item#1}\textcolor{blue}{#1}}
\def\RClist{}
\def\BClist{}

\begin{document}
\RC{red1} test

\BC{blue1} test

\BC{blue2} test

\RC{red2} test

\vfill

\textcolor{red}{Definitions:}
\begin{itemize}
\RClist
\end{itemize}

\bigskip

\textcolor{blue}{Theorems:}
\begin{itemize}
\BClist
\end{itemize}
\end{document}

-
Thanks! Is there any way to make links in \RClist so that when I click on red1 in the list, it will refer to '\RC{red1} test' in the main text? – Labbiqa Feb 25 at 14:17
I think you might want to use \gdef in the definition of \addto in case these commands are called from within some kind of scoped group. – A.Ellett Feb 25 at 15:29