Mostrar todas as palavras coloridas no final do documento

Mostrar todas as palavras coloridas no final do documento

Existe alguma maneira de mostrar todas as palavras coloridas no final de um documento?

Digamos que estou marcando as definições em vermelho e os teoremas em azul.

É possível fazer uma lista de "palavras-chave" onde estão listadas todas as palavras vermelhas e outra lista com todas as palavras azuis.

Algo assim

\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}

Responder1

Você pode usar, por exemplo, esta definição de \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}

informação relacionada