Take the 2-minute tour ×
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.

This is a very general question, but I would like to make and index for my thesis, that indexes any word that I bf in the documents, and references the page number next to it. I am using the makeidx package.

I just need the command to work it. Thanks guys!

share|improve this question
    
When you say "any word that I bf in the documents", does that mean you're highlighting words using the (deprecated) \bf command, and you want to create an index of all occurrences of those words? –  Jake Feb 5 at 15:23
3  
Welcome to TeX.SX! It's better if you provide a minimal working example (MWE) illustrating what you've tried. –  Nicola Talbot Feb 5 at 15:25
    
When I say bf, I mean words like \textbf{nilpotent}, then continuing on. I just want one page at the end of the document that lists all words that have been made bold, and references the page. I haven't tried anything yet. –  Calculus08 Feb 5 at 15:37
    
Also see Mark indexed entries in the text itself. –  Crissov Feb 5 at 15:43
1  
Fair enough @Jake I withdraw my comment, I am writing this only to let you know that. Sorry. –  Alec Teal Feb 5 at 20:15
show 4 more comments

2 Answers

As noted in Best practice for index construction -- recommendations and references, constructing an index requires time, dedication, and skill, and should almost certainly not be automated- the results could lead to a useless index.

However, the following code does what you requested: it makes an index entry for every entry that is contained in the textbf command.

Note, in particular, the arara directives at the top of the document; to compile the document (say, myfile.tex), simply run

arara myfile

Here's the complete code:

% arara: pdflatex
% arara: makeindex
% arara: pdflatex

\documentclass{article}
\usepackage{makeidx}

\let\oldtextbf\textbf
\renewcommand{\textbf}[1]{%
\oldtextbf{#1}%
\index{#1}
}
\makeindex
\begin{document}

\textbf{my text}

\clearpage
\textbf{another}
\printindex
\end{document}
share|improve this answer
add comment

Instead of the package hvindex, I use this command \dfn in some documents:

%% \dfn[index entry]{defined term}
\newcommand{\dfn}[2][]{\textbf{#2}%
  \ifthenelse{\equal{#1}{\empty}}{\index{#2}}{\index{#1}}}

It highlights the mandatory parameter, i.e. the defined term, in bold and indexes it unless an optional parameter is provided which would take precedence. There are more advanced techniques in makeidx, of course, which ar enot supported by this convenient macro.

I would advise against renewcommanding \textbf.

share|improve this answer
add comment

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.