2

I have the following code to build a mindmap from sections/subsections of a beamer presentation. However, when I scale the mindmap to fit within the frame area, the hyperlink is not just the text itself, but also something that is hide in the pdf. You can see it if you place the mouse over the sections/subsections names in the mindmap and move the mouse towards the right. The text name ends, but the hyperlink continues. How can I guarantee that even resizing the picture the hyperlink will be in the correct place.

\documentclass{beamer}

\usepackage{lmodern}
\usepackage{totcount}
\usepackage{tikz}
\usetikzlibrary{mindmap}

\newcounter{totalsection}
\newcounter{totalsubsection}
\regtotcounter{totalsection}

\makeatletter
\let\oldsubsection\subsection
\renewcommand{\subsection}[2][]{%
    \refstepcounter{totalsubsection}%
    \oldsubsection[#1]{#2}% Call default \subsection (this also steps the subsection counter)
    \hypertarget{\csname Section\Alph{section}subsection\Alph{subsection}\endcsname}{}%
  \immediate\write\@auxout%
    {\string\global\string\def\string\Section\Alph{section}subsection\Alph{subsection}{%
      \arabic{section}.\arabic{subsection}{} #2}}%
}
\makeatother

\makeatletter
\let\oldsection\section
\renewcommand{\section}[2][]{%
    \refstepcounter{totalsection}%
    \oldsection[#1]{#2}% Call default \section (this also steps the section counter)
    \hypertarget{\csname Section\Alph{section}\endcsname}{}%
  \immediate\write\@auxout%
    {\string\global\string\def\string\Section\Alph{section}{%
      \arabic{section}{} #2}}%
}
\makeatother

\newcommand{\mindtoc}{%
    \centering
    \begin{tikzpicture}
        [%
            %framed,
            %every concept/.style={inner sep=2pt,text width=4cm,minimum width=5cm,font=\large},
            every concept/.style={inner sep=2pt,text width=4cm,minimum width=5cm},
            level 1 concept/.append style={%
                sibling angle=360/\totvalue{totalsection},
                level distance=3.5cm,
            },
            %every node/.append style={scale=0.5}
        ]
        \path[mindmap,concept color=blue,text=white]%
            node[concept,scale=0.5] {\inserttitle}%
            [clockwise from=135]%
            child[concept color=gray]%
                foreach \Idxsec in {A,...,Z}{%
                    \ifcsname Section\Idxsec \endcsname%
                        node[concept,scale=0.5] {%
                            \xdef\sectionname{\csname Section\Idxsec\endcsname}%
                            \hyperlink{\sectionname}{\sectionname}%
                            %\hyperlink{\csname Section\Idxsec\endcsname}{\csname Section\Idxsec\endcsname}%
                        }%
                    \fi%
        };%
    \end{tikzpicture}%
}

% http://tex.stackexchange.com/questions/118182/selectively-turn-off-hyperref-links-for-citations
\newcommand*{\nolink}[1]{%
    \begin{NoHyper}#1\end{NoHyper}%
}

\AtBeginSection{%
    \let\oldinsertsection\insertsection%
    \renewcommand{\insertsection}{\nolink{\oldinsertsection}}%
}

\AtBeginSubsection{%
    \let\oldinsertsubsection\insertsubsection%
    \renewcommand{\insertsubsection}{\nolink{\oldinsertsubsection}}%
}

\title{Presentation title}

\begin{document}

\begin{frame}
    \frametitle{\contentsname}
    \mindtoc
\end{frame}

\begin{frame}{All sections\slash subsections}

\foreach \Idxsec in {A,...,Z}{%
    \ifcsname Section\Idxsec \endcsname
        \xdef\sectionname{\csname Section\Idxsec\endcsname}
        \hyperlink{\sectionname}{\sectionname}\par
        \foreach \Idxsubsec in {A,...,Z}{%
            \ifcsname Section\Idxsec subsection\Idxsubsec \endcsname
                \xdef\subsectionname{\csname Section\Idxsec subsection\Idxsubsec\endcsname}
                \hspace{0.5em}\hyperlink{\subsectionname}{\subsectionname}\par
            \fi
        }
    \fi
}


\end{frame}

% For testing
\section{section A}
\begin{frame}{\insertsection}
\end{frame}

\section{section B}

\subsection{section B, subsection A}
\begin{frame}{\insertsubsection}
\end{frame}

\subsection{section B, subsection B}
\begin{frame}{\insertsubsection}
\end{frame}

\subsection{section B, subsection C}
\begin{frame}{\insertsubsection}
\end{frame}

\section{section C}
\begin{frame}{\insertsection}
\end{frame}

\subsection{section C, subsection A}
\begin{frame}{\insertsubsection}
\end{frame}

\subsection{section C, subsection B}
\begin{frame}{\insertsubsection}
\end{frame}

\end{document}
2

There seems to be an issue with how scale option is implemented. As a work-around putting the whole thing in a \scalebox works. (You might want to actually use bigger font size for the node text though; but the output here is the same as when using scale=0.5 option).

I did a screenshot with a pop up window from Skim.app (on mac os x) whose upper left corner is where the pointer was. Couldn't manage to get the pointer incorporated into the screenshot though.

enter image description here

\documentclass{beamer}

\usepackage{lmodern}
\usepackage{totcount}
\usepackage{tikz}
\usetikzlibrary{mindmap}

\newcounter{totalsection}
\newcounter{totalsubsection}
\regtotcounter{totalsection}

\makeatletter
\let\oldsubsection\subsection
\renewcommand{\subsection}[2][]{%
    \refstepcounter{totalsubsection}%
    \oldsubsection[#1]{#2}% Call default \subsection (this also steps the subsection counter)
    \hypertarget{\csname Section\Alph{section}subsection\Alph{subsection}\endcsname}{}%
  \immediate\write\@auxout%
    {\string\global\string\def\string\Section\Alph{section}subsection\Alph{subsection}{%
      \arabic{section}.\arabic{subsection}{} #2}}%
}
\makeatother

\makeatletter
\let\oldsection\section
\renewcommand{\section}[2][]{%
    \refstepcounter{totalsection}%
    \oldsection[#1]{#2}% Call default \section (this also steps the section counter)
    \hypertarget{\csname Section\Alph{section}\endcsname}{}%
  \immediate\write\@auxout%
    {\string\global\string\def\string\Section\Alph{section}{%
      \arabic{section}{} #2}}%
}
\makeatother

\newcommand{\mindtoc}{%
    \centering
    \scalebox{.5}{\begin{tikzpicture}
        [%
            %framed,
            %every concept/.style={inner sep=2pt,text width=4cm,minimum width=5cm,font=\large},
            every concept/.style={inner sep=2pt,text width=4cm,minimum width=5cm},
            level 1 concept/.append style={%
                sibling angle=360/\totvalue{totalsection},
                level distance=7cm,
            },
            %every node/.append style={scale=0.5}
        ]
        \path[mindmap,concept color=blue,text=white]%
            node[concept] {\inserttitle}%
            [clockwise from=135]%
            child[concept color=gray]%
                foreach \Idxsec in {A,...,Z}{%
                    \ifcsname Section\Idxsec \endcsname%
                        node[concept] {%
                            \xdef\sectionname{\csname Section\Idxsec\endcsname}%
                            \hyperlink{\sectionname}{\sectionname}%
                            %\hyperlink{\csname Section\Idxsec\endcsname}{\csname Section\Idxsec\endcsname}%
                        }%
                    \fi%
        };%
    \end{tikzpicture}}%
}

% http://tex.stackexchange.com/questions/118182/selectively-turn-off-hyperref-links-for-citations
\newcommand*{\nolink}[1]{%
    \begin{NoHyper}#1\end{NoHyper}%
}

\AtBeginSection{%
    \let\oldinsertsection\insertsection%
    \renewcommand{\insertsection}{\nolink{\oldinsertsection}}%
}

\AtBeginSubsection{%
    \let\oldinsertsubsection\insertsubsection%
    \renewcommand{\insertsubsection}{\nolink{\oldinsertsubsection}}%
}

\title{Presentation title}

\begin{document}

\begin{frame}
    \frametitle{\contentsname}
    \mindtoc
\end{frame}

\begin{frame}{All sections\slash subsections}

\foreach \Idxsec in {A,...,Z}{%
    \ifcsname Section\Idxsec \endcsname
        \xdef\sectionname{\csname Section\Idxsec\endcsname}
        \hyperlink{\sectionname}{\sectionname}\par
        \foreach \Idxsubsec in {A,...,Z}{%
            \ifcsname Section\Idxsec subsection\Idxsubsec \endcsname
                \xdef\subsectionname{\csname Section\Idxsec subsection\Idxsubsec\endcsname}
                \hspace{0.5em}\hyperlink{\subsectionname}{\subsectionname}\par
            \fi
        }
    \fi
}


\end{frame}

% For testing
\section{section A}
\begin{frame}{\insertsection}
\end{frame}

\section{section B}

\subsection{section B, subsection A}
\begin{frame}{\insertsubsection}
\end{frame}

\subsection{section B, subsection B}
\begin{frame}{\insertsubsection}
\end{frame}

\subsection{section B, subsection C}
\begin{frame}{\insertsubsection}
\end{frame}

\section{section C}
\begin{frame}{\insertsection}
\end{frame}

\subsection{section C, subsection A}
\begin{frame}{\insertsubsection}
\end{frame}

\subsection{section C, subsection B}
\begin{frame}{\insertsubsection}
\end{frame}

\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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