![Beamer 垂直导航栏,带水平分段点](https://linux22.com/image/270774/Beamer%20%E5%9E%82%E7%9B%B4%E5%AF%BC%E8%88%AA%E6%A0%8F%EF%BC%8C%E5%B8%A6%E6%B0%B4%E5%B9%B3%E5%88%86%E6%AE%B5%E7%82%B9.png)
我想要在垂直导航栏内有一个水平子部分导航。
这个想法是获得与 outersmoothbar 相同的子部分导航,但是在垂直导航栏中。
我搜索了一下,但找不到任何解决方案。有什么想法吗?
埃兰迪尔
编辑:我正在写我的主题,并把有关侧边栏的代码放在这里。
% ============================================================
% LENGTH
% ============================================================
\newlength{\SidebarWidth}
\setlength{\SidebarWidth}{\beamer@sidebarwidth}
\newlength{\HeadlineWidth}
\setlength{\HeadlineWidth}{\paperwidth}
\addtolength{\HeadlineWidth}{-\SidebarWidth}
\addtolength{\HeadlineWidth}{-1pt}
\newlength{\HeadlineHeight}
\settoheight{\HeadlineHeight}{\large TexTe}
\addtolength{\HeadlineHeight}{1ex}
% ============================================================
% SIDEBAR
% ============================================================
% color
\setbeamercolor{sidebar}{bg=white}
\setbeamercolor{section in head/foot}{fg=black, bg=white}
% sidebar itself
\setbeamertemplate{sidebar \beamer@sidebarside}
{
\vfill
\insertverticalnavigation{\beamer@sidebarwidth}%
\vfill
}%
% vertical rule
\setbeamertemplate{sidebar canvas \beamer@sidebarside}{
\vspace*{-0.7\HeadlineHeight}%
\ifx\beamer@sidebarside\beamer@lefttext{%
\hspace*{0.99\beamer@sidebarwidth}%
\color{black}\rule{1pt}{0.9\paperheight}%
}
\else{%
\color{black}\rule{1pt}{0.9\paperheight}%
}
\fi
}
% section in sidebar
\setbeamertemplate{section in sidebar}%{sidebar theme}
{%
\vbox{%
\vskip1ex%
\beamer@sidebarformat{3pt}{section in sidebar}{
\centering\tikz[opacity=1.0] \node[xshift=0cm,yshift=0cm] at (0,0) {\includegraphics[height=0.7\beamer@sidebarwidth]{obian/sec\expandafter\insertsectionheadnumber\expandafter}};%
}%
}%
}
% section in sidebar shaded
\setbeamertemplate{section in sidebar shaded}%{sidebar theme}
{%
\vbox{%
\vskip1ex%
\beamer@sidebarformat{3pt}{section in sidebar}{
\centering\tikz[opacity=0.3] \node at (0,0) {\includegraphics[height=0.7\beamer@sidebarwidth]{obian/sec\expandafter\insertsectionheadnumber\expandafter}};%
}%
}%
}
% Patch sidebar to not hide section when show subsection
\patchcmd{\insertverticalnavigation}%
{\ifx\beamer@nav@css\beamer@hidetext{\usebeamertemplate{section in sidebar}}\else{\usebeamertemplate{section in sidebar shaded}}\fi}%
{{\usebeamertemplate{section in sidebar}}}{}{}
一个简单的例子就是在序言中加载前面的代码:
\documentclass{beamer}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\tableofcontents[subsectionstyle=show]
\end{frame}
\section{Section 1}
\begin{frame}
\begin{itemize}
\item No frametitle
\item section 1
\end{itemize}
\end{frame}
\subsection{Subsection 1}
\begin{frame}
\begin{itemize}
\item No frametitle
\item section 1
\item subsection 1
\end{itemize}
\end{frame}
\end{document}
答案1
最后我通过重写内部宏找到了解决方案\insertverticalnavigation
。我把代码贴出来,看看是否对某些人有帮助。
如果您有任何改进的想法,请告诉我。
在 MyStyle.sty 文件中我写道:
% Style
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{MyStyle}[2013/06/21 Beamer theme]
% Outer theme
\useoutertheme[left]{sidebar}
% Package
\RequirePackage{wasysym} %\Circle, \CIRCLE -> subsection symbol
% Length
\newlength{\SidebarWidth}
\setlength{\SidebarWidth}{\beamer@sidebarwidth}
% Internal insertverticalnavigation macro
\def\insertverticalnavigation#1{%
\begin{minipage}[t]{\SidebarWidth}
\centering
\vbox to \paperheight{%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\def\insertsectionhead{##2}%
\def\insertsectionheadnumber{##1}%
\def\insertpartheadnumber{##5}%
\vskip0.9em
\hbox{{%
\usebeamerfont{section in sidebar}\usebeamercolor[fg]{section in sidebar}%
\hyperlink{Navigation##3}{%
\ifnum\c@section=##1%
\ifnum\c@subsection=0\relax%
{\usebeamertemplate{section in sidebar}}%
\else%
\ifx\beamer@nav@css\beamer@hidetext%
{\usebeamertemplate{section in sidebar}}%
\else%
{\usebeamertemplate{section in sidebar}}%
\fi%
\fi%
\else
{\usebeamertemplate{section in sidebar shaded}}%
\fi}}}%
\vskip0pt
\beamer@currentsubsection=0\relax\fi}%
\def\slideentry##1##2##3##4##5##6{}%
\def\beamer@subsectionentry##1##2##3##4##5{%
\ifnum##1=\c@part%
\def\insertpartheadnumber{##1}%
\def\insertsectionheadnumber{##2}%
\def\insertsubsectionheadnumber{##3}%
\def\insertsubsectionhead{##5}%
\beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
{\hskip0pt\hbox{{%
\usebeamerfont{subsection in sidebar}\usebeamercolor[fg]{subsection in sidebar}%
\hyperlink{Navigation##4}{%
\ifnum\c@section=##2%
\ifnum\c@subsection=##3%
\ifnum\c@subsubsection=0\relax%
{\usebeamertemplate{subsection in sidebar}}%
\else%
{\usebeamertemplate{subsection in sidebar}}%
\fi%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi%
\else%
{\usebeamertemplate{subsection in sidebar shaded}}%
\fi}}}%
}%
\fi}%
\dohead%
}%
\end{minipage}
}
% subsection in sidebar
\setbeamertemplate{subsection in sidebar}
{
\usebeamercolor{subsection in sidebar}\CIRCLE%
}
% subsection in sidebar shaded
\setbeamertemplate{subsection in sidebar shaded}
{
\usebeamercolor{subsection in sidebar shaded}\Circle%
}
MWE 可以是:
\documentclass{beamer}
\usepackage{MyStyle}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\tableofcontents
\end{frame}
\section{Section 1}
\begin{frame}
\begin{itemize}
\item No frametitle
\item section 1
\end{itemize}
\end{frame}
\subsection{Subsection 1}
\begin{frame}
\begin{itemize}
\item No frametitle
\item section 1
\item subsection 1
\end{itemize}
\end{frame}
\subsection{Subsection 2}
\begin{frame}
\begin{itemize}
\item No frametitle
\item section 1
\item subsection 2
\end{itemize}
\end{frame}
\section{Section 2}
\begin{frame}
\begin{itemize}
\item No frametitle
\item section 2
\end{itemize}
\end{frame}
\end{document}
这个小例子提供了我想要的,即垂直导航栏内的水平模式的子部分。