[Tex/LaTex] Customizing the navigation bar

beamerformattingnavigation

I was wondering how I can customize the sidebar such that it only shows the current section and subsections that I am currently presenting and how can I remove the navigation bar from the title slide.

Best Answer

Hiding other subsections is easy: it's enough to use the hideothersubsections option (either for the theme or for the sidebar outer theme). Hiding other sections is not so simple; it involves a redefinition of \insertverticalnavigation as implemented in beamerbasenavigation.sty. Hiding the navigation bar from the title frame can be achieved using the plain option for the frame. The following example code contains the required code:

\documentclass{beamer}
\usetheme[hideothersubsections]{PaloAlto}

\makeatletter
\def\insertverticalnavigation#1{%
  \vbox{%
    \def\sectionentry##1##2##3##4##5{%
      \ifnum##5=\c@part%
      \def\insertsectionhead{##2}%
      \def\insertsectionheadnumber{##1}%
      \def\insertpartheadnumber{##5}%
      \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 shaded}}%
              \fi%
            \fi%
          \else
            %{\usebeamertemplate{section in sidebar shaded}}%
          \fi}}}%
      \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}%
      {\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 shaded}}%
              \fi%
            \else%
              {\usebeamertemplate{subsection in sidebar shaded}}%
            \fi%
          \else%
            {\usebeamertemplate{subsection in sidebar shaded}}%
          \fi}}}%
      }%
      \fi}%
    \def\beamer@subsubsectionentry##1##2##3##4##5##6{%
      \ifnum##1=\c@part%
      \def\insertpartheadnumber{##1}%
      \def\insertsectionheadnumber{##2}%
      \def\insertsubsectionheadnumber{##3}%
      \def\insertsubsubsectionheadnumber{##3}%
      \def\insertsubsubsectionhead{##6}%
      \beamer@tocifnothide{\ifnum\c@section=##2\ifnum\c@subsection=##3\beamer@nav@css\else\beamer@nav@oss\fi\else\beamer@nav@ooss\fi}%
      {\hbox{{%
        \usebeamerfont{subsubsection in sidebar}\usebeamercolor[fg]{subsubsection in sidebar}%
          \hyperlink{Navigation##5}{%
          \ifnum\c@section=##2%
            \ifnum\c@subsection=##3%
              \ifnum\c@subsubsection=##4%
                {\usebeamertemplate{subsubsection in sidebar}}%
              \else
                {\usebeamertemplate{subsubsection in sidebar shaded}}%
              \fi%
            \else%
              {\usebeamertemplate{subsubsection in sidebar shaded}}%
            \fi%
          \else%
            {\usebeamertemplate{subsubsection in sidebar shaded}}%
          \fi}}}%
      }%
      \fi}%
    %\beamer@currentsubsection=0\relax%
    \dohead%
  }%
}
\makeatother

\title{The Title}
\author{The Author}
\institute{The Institute}

\begin{document}

\begin{frame}[plain] 
\maketitle
\end{frame}

\section{Test section one}
\begin{frame} test frame for section one\end{frame}
\subsection{Test subsection one one}
\begin{frame} test frame for section one\end{frame}
\subsection{Test subsection one two}
\begin{frame} test frame for section one\end{frame}

\section{Test section two}
\begin{frame} test frame for section two\end{frame}
\subsection{Test subsection two one}
\begin{frame} test frame for section two\end{frame}
\subsection{Test subsection two two}
\begin{frame} test frame for section two\end{frame}

\end{document}

enter image description here