# Mini index for subsection

There is the following code:

\subsection{some subsection}
Some \mindex[mean=aaa]{sentence} with some \mindex[mean=bbb]{unknown} words.
\listminiindexfromsubsection


The expected output:

Some subsection

Some sentence with some unknown words.

Mini index: sentence - aaa unknown - bbb

I would like to create something like a mini index, which can create a small dictionary. All words from specific subsection which are arguments of \mindex[mean=something]{word} should be collected and when the command \listminiindexfromsubsection is written, then the output should contain all of these words with their meaning.

What is the method to collect specific words from a subsection and then printing them out?

-
Where is the \mindex command defined? – egreg Jun 16 '11 at 22:45
it's not yet defined, it's just example how it could be defined – scdmb Jun 16 '11 at 22:47

## 2 Answers

\documentclass[a4paper]{article}

\def\mindexlist{}
\makeatletter
\newcommand{\mindex}[2]{\g@addto@macro\mindexlist{\textbf{#1} --- #2\par}#2}
\newcommand{\printmindex}{\begin{flushleft}\mindexlist\end{flushleft}
\gdef\mindexlist{}}
\makeatother

\begin{document}
\section{First}
Some \mindex{sentence}{aaa} with some \mindex{unknown}{bbb} words.

\printmindex

\section{Second}
Some \mindex{sentence}{ccc} with some \mindex{unknown}{ddd} words.

\printmindex
\end{document}


Each \printmindex command resets the list.

-

Perhaps not as simple as you expected, but also not much difficult. You can use the glossaries package and create one glossary for each subsection:

\documentclass{article}
\usepackage[nonumberlist,savewrites,xindy,nomain]{glossaries}

% Define new glossaries
\newglossary[sco]{seco}{oin}{ofi}{Short Index}
\newglossary[sct]{sect}{tin}{tfi}{Short Index}

\makeglossaries

% declare the entries
\newglossaryentry{seco:unk}{type=seco, name={unknown}, description={Not known}}

\newglossaryentry{seco:sen}{type=seco,name={sentence},description={Some description}}

\newglossaryentry{sect:rin}{type=sect,name={ring},description={Not known}}

\newglossaryentry{sect:gro}{type=sect,name={group},description={Simple structure}}

\begin{document}

\section{Test section}

\subsection{First subsection}
This is a \gls{seco:sen} with some \gls{seco:unk} words.
\printglossary[type=seco]

\subsection{Second subsection}
A \gls{sect:rin} is an algebraic structure whose definition is not known; A \gls{sect:gro} is a simple algebraic structure.
\printglossary[type=sect]

\end{document}


The example (let's call the above document test.tex) can be compiled using:

(pdf)latex test
makeglossaries test
(pdf)latex test
(pdf)latex test


The result:

-