TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question
1  
What about using thmtools's \listoftheorem macro instead? If you really want colors you can always customize it… – MickG Feb 25 at 13:15
    
up vote 9 down vote accepted

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}
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.