我有以下代码,用于根据 Beamer 演示文稿的章节/子章节构建思维导图。但是,当我缩放思维导图以适合框架区域时,超链接不仅是文本本身,而且是隐藏在 pdf 中的内容。如果将鼠标放在思维导图中的章节/子章节名称上并将鼠标向右移动,则可以看到它。文本名称结束,但超链接继续。我如何保证即使调整图片大小,超链接也会位于正确的位置。
\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}
答案1
选项的实现方式似乎存在问题scale
。作为一种解决方法,将整个内容放在一个\scalebox
作品中。(不过,您可能实际上希望为节点文本使用更大的字体大小;但此处的输出与使用scale=0.5
选项时相同)。
我用 Skim.app(在 mac os x 上)的弹出窗口截取了一张屏幕截图,其左上角是指针所在的位置。但无法将指针合并到屏幕截图中。
\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}