문서 끝에 모든 색상 단어 표시

문서 끝에 모든 색상 단어 표시

문서 끝 부분에 모든 색상의 단어를 표시할 수 있는 방법이 있습니까?

정의를 빨간색으로, 정리를 파란색으로 표시한다고 가정해 보겠습니다.

빨간색 단어가 모두 나열되는 "키워드" 목록과 파란색 단어가 모두 포함된 또 다른 목록을 만드는 것이 가능합니까?

이 같은

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

답변1

예를 들어 다음 과 같은 정의를 사용할 수 있습니다 \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}

관련 정보