MakeIndex, Nomenclature, Glossaries and AcronymsLinked Index for Presentation

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Post Reply
mafis103
Posts: 7
Joined: Sat Feb 23, 2013 9:29 am

Linked Index for Presentation

Post by mafis103 »

Hi everyone,

I am supposed to do a linked index for some lecture slides. There is no problem with the indexing itself, but with the linking - I can see the page numbers, but there are no links, although hyperref is loaded (and I think it is loaded by the beamer class anyway).

I have no clue, what I am doing wrong. Here is an example that can show my problem:

Code: Select all

\documentclass[16pt,pdftex]{beamer}
\usepackage{multicol}
\usepackage{makeidx}
\usepackage{hyperref}

\makeindex
\newenvironment{theindex}{
\let\item\par
\let\subitem\par
}{}
\newcommand\indexspace{}
\newcommand{\myindex}[1]{#1\index{#1}}

\newcommand{\mypart}[1]{\section{#1}}
\newcommand{\mysection}[1]{\subsection{#1}}
\newcommand{\mydef}[1]{\alert{#1}\index{#1}}

%\newcommand{\bb}[1]{\hyperpage{\textbf{#1}}}

\begin{document}

\begin{frame}
\frametitle{TableOfContents}
\tableofcontents
\end{frame}

\begin{frame}
\frametitle{Part1SecA}
test \myindex{taindex} \myindex{waindex!ssubaz} \myindex{zbzindex!isubbu}
\end{frame}

\begin{frame}
\frametitle{Part1SecA}
test \myindex{taindex} \myindex{ezzz!ezsubaz} \myindex{ezzbindex!uzsubbu}
\end{frame}

\mypart{Part2}
\mysection{SecB}

\begin{frame}
\frametitle{Part2SecB}
test \myindex{binden}\myindex{aindex!suba2} \myindex{bindex!subb2}
\end{frame}

\begin{frame}[allowframebreaks]
\frametitle{Index}
\printindex
\end{frame}
\end{document}
The commented line you can see is one of my tries to make it work and one of the rare things I found on the internet concerning that topic. (When activated, I put of course a |bb behind the index terms). But that try didn't even compile.

Can you tell me where the problem is and maybe what the solution is? I haven't found much about that topic in forums etc. so I am wondering if I am the only one with this problem? :oops:

Best regards and thanks in advance

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Linked Index for Presentation

Post by nlct »

mafis103 wrote:

Code: Select all

\newcommand{\bb}[1]{\hyperpage{\textbf{#1}}}
\hyperpage requires just the page number as its argument, so this would need to be

Code: Select all

\newcommand{\bb}[1]{\textbf{\hyperpage{#1}}}
However beamer disables \hyperpage so you can't use it. Here's a possible alternative that uses the datagidx package (part of the datatool bundle):

Code: Select all

    \documentclass[16pt,pdftex]{beamer}

    \makeatletter
    % beamer doesn't define \@idxitem, but it's used by the
    % \printterms "index" style, so define it:
    \newcommand\@idxitem{\par\hangindent40pt}
    \makeatother

    \usepackage{datagidx}

    \newgidx{index}{Index}
    \DTLgidxSetDefaultDB{index}

    \newterm{taindex}
    \newterm{waindex}
    \newterm[parent=waindex]{ssubaz}
    \newterm{zbzindex}
    \newterm[parent=zbzindex]{isubbu}
    \newterm{ezzz}
    \newterm[parent=ezzz]{ezsubaz}
    \newterm{ezzbindex}
    \newterm[parent=ezzbindex]{uzsubbu}
    \newterm{binden}
    \newterm{aindex}
    \newterm[parent=aindex]{suba2}
    \newterm{bindex}
    \newterm[parent=bindex]{subb2}

    \begin{document}

    \begin{frame}
    \frametitle{TableOfContents}
    \tableofcontents
    \end{frame}

    \begin{frame}
    \frametitle{Part1SecA}
    test \gls{taindex} \gls{ssubaz}
    \gls{isubbu}
    \end{frame}

    \begin{frame}
    \frametitle{Part1SecA}
    % Make the next term have a bold page number in the index:
    test \gls{[textbf]taindex} 
    \gls{ezsubaz}
    \gls{uzsubbu}
    \end{frame}

    \begin{frame}
    \frametitle{Part2SecB}
    test \gls{binden}\gls{suba2}
    \gls{subb2}
    \end{frame}

    \begin{frame}[allowframebreaks]
    \frametitle{Index}
    \printterms[style=index]
    \end{frame}
    \end{document}
You don't need makeindex, just two LaTeX runs. On the second run, the page numbers in the index will be hyperlinks.

Regards
Nicola Talbot
mafis103
Posts: 7
Joined: Sat Feb 23, 2013 9:29 am

Linked Index for Presentation

Post by mafis103 »

Hi nicola,

thank you very much for your help. Is there any way to avoid always naming the index-terms twice?
(One time in the text and the other time by

Code: Select all

\newterm{INDEXNAME}
)

EDIT: And another question,

I redefined the "myindex" command like this:

Code: Select all

\newcommand{\myindex}[1]{\gls{#1}}
But now I have the problem that I want to refer to indexes, that have the same name, but a different Parent-concept. How can I differentiate them (with makeindex it was possible to do this {concept!sub} thing to differentiate, with \gls that doesn't work anymore of course)
Is it possible to make them sort automatically by alphabet?

Thanks in advance
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Linked Index for Presentation

Post by nlct »

mafis103 wrote:Is there any way to avoid always naming the index-terms twice? (One time in the text and the other time by

Code: Select all

\newterm{INDEXNAME}
)
No, I'm sorry. With datagidx you have to define the terms in the preamble.
I redefined the "myindex" command like this:

Code: Select all

\newcommand{\myindex}[1]{\gls{#1}}
But now I have the problem that I want to refer to indexes, that have the same name, but a different Parent-concept. How can I differentiate them (with makeindex it was possible to do this {concept!sub} thing to differentiate, with \gls that doesn't work anymore of course)
You can override the default label using the label key in the optional argument of \newterm:

Code: Select all

\newterm[label=foobar,parent=foo]{bar}
Now you can reference it using

Code: Select all

\gls{foobar}
You can also override how the text appears when using \gls (as opposed to how it will appear in the index):

Code: Select all

\newterm[label=foobar,text={bar (foo)},parent=foo]{bar}
or

Code: Select all

\newterm[label=foobar,text={foo bar},parent=foo]{bar}
etc.
Is it possible to make them sort automatically by alphabet?
The entries should automatically be sorted alphabetically (according to the entry level, as with makeindex). If this isn't happening, can you provide a minimal example illustrating the problem.

Regards
Nicola Talbot
mafis103
Posts: 7
Joined: Sat Feb 23, 2013 9:29 am

Re: Linked Index for Presentation

Post by mafis103 »

Hi Nicola,

please excuse my late response and thank you very much for your helpful answers. I will try your hints as soon as possible and maybe come back again with other question

But until that: Just Thank you, I wouldn't have found out about that solution by myself.
mafis103
Posts: 7
Joined: Sat Feb 23, 2013 9:29 am

Linked Index for Presentation

Post by mafis103 »

Hi there again.

Everything is working fine so far, but I have got a problem:
When I add a lot of indexes, the pages don't break and the indexes flow over the frame.... (see example).
Is there any solution for that?

Code: Select all

        \documentclass[16pt,pdftex]{beamer}

        \makeatletter
        % beamer doesn't define \@idxitem, but it's used by the
        % \printterms "index" style, so define it:
        \newcommand\@idxitem{\par\hangindent40pt}
        \makeatother

        \usepackage{datagidx}

        \newgidx{index}{Index}
        \DTLgidxSetDefaultDB{index}

        \newterm{taindex}
        \newterm{waindex}
        \newterm[parent=waindex]{ssubaz}
        \newterm{zbzindex}
        \newterm[parent=zbzindex]{isubbu}
        \newterm{ezzz}
        \newterm[parent=ezzz]{ezsubaz}
        \newterm{ezzbindex}
        \newterm[parent=ezzbindex]{uzsubbu}
        \newterm{binden}
        \newterm{aindex}
        \newterm[parent=aindex]{suba2}
        \newterm{bindex}
        \newterm[parent=bindex]{subb2}
        \newterm{cindex}
        \newterm{dindex}
        \newterm{eindex}
        \newterm{findex}
        \newterm{gindex}
        \newterm{hindex}
        \newterm{iindex}
        \newterm{jindex}
        \newterm{kindex}
         \newterm{dindex2}
        \newterm{eindex2}
        \newterm{findex2}
        \newterm{gindex2}
        \newterm{hindex2}
        \newterm{iindex2}
        \newterm{jindex2}
        \newterm{kindex2}
        \newterm{dindex3}
        \newterm{eindex3}
        \newterm{findex3}
        \newterm{gindex3}
        \newterm{hindex3}
        \newterm{iindex3}
        \newterm{jindex3}
        \newterm{kindex3}

        \begin{document}

        \begin{frame}
        \frametitle{TableOfContents}
        \tableofcontents
        \end{frame}

        \begin{frame}
        \frametitle{Part1SecA}
        test \gls{taindex} \gls{ssubaz}
        \gls{isubbu}
        \end{frame}

        \begin{frame}
        \frametitle{Part1SecA}
        % Make the next term have a bold page number in the index:
        test \gls{[textbf]taindex}
        \gls{ezsubaz}
         \gls{dindex}
        \gls{eindex}
        \gls{findex}
        \gls{gindex}
        \gls{hindex}
        \gls{iindex}
        \gls{jindex}
        \gls{kindex}
        \gls{uzsubbu}
        \gls{dindex2}
        \gls{eindex2}
        \gls{findex2}
        \gls{gindex2}
        \gls{hindex2}
        \gls{iindex2}
        \gls{jindex2}
        \gls{kindex2}
        \gls{dindex3}
        \gls{eindex3}
        \gls{findex3}
        \gls{gindex3}
        \gls{hindex3}
        \gls{iindex3}
        \gls{jindex3}
        \gls{kindex3}
        \end{frame}

        \begin{frame}
        \frametitle{Part2SecB}
        test \gls{binden}\gls{suba2}
        \gls{subb2}
        \end{frame}

        \begin{frame}[allowframebreaks]
        \frametitle{Index}
        \printterms[style=index]
        \end{frame}
        \end{document} 
mafis103
Posts: 7
Joined: Sat Feb 23, 2013 9:29 am

Re: Linked Index for Presentation

Post by mafis103 »

- just pushing that thread up, because the last posted question still remains -
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Re: Linked Index for Presentation

Post by Stefan Kottwitz »

This thread was originally about hyperlinking the index, and the original question has been solved. Probably that's why your follow-up question at the end wasn't seen by many readers. It's usually the best to open a new topic for a new problem. You can always provide a link back to a related topic.

Stefan
LaTeX.org admin
Post Reply