beamer add tag
Yousef Ahmadi (imported from SE)
My navigation bar is divided into 2 parts, which I have sections in one part and subsections in the other part. The number of sections and subsections is too much to fit in one line. I want them to be wrapped. I found the following code in a question answered some years ago, but it is written for wrapping sections. What change should I make on the code so that is works for subsections too? 

Here is the code: 


    \makeatletter
    \def\insertsectionnavigationhorizontal#1#2#3{%
     \hbox to #1{{%
       \def\slideentry##1##2##3##4##5##6{}%
       #2\hskip.3cm%
       \newdimen\tmp@parbox%
       \setlength\tmp@parbox{#1}%
       \addtolength\tmp@parbox{-.6cm}%
       \parbox{\tmp@parbox}{\raggedleft%
         \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
         \setbox\beamer@sectionbox=\hbox{}%
         \ht\beamer@sectionbox=1.875ex%
         \dp\beamer@sectionbox=0.75ex%
         \hskip-1.875ex plus-1fill\dohead%
         \box\beamer@sectionbox}\hfil\hskip.3cm%
         #3}}}
    \makeatother
Top Answer
samcarter
The following code will wrap both the section and subsection navigation. The total height can be adjusted by modifying `\setlength{\myheight}{0.8cm}`

```
\documentclass[compress]{beamer}

\usetheme{Warsaw}

\makeatletter

\newbox\mysectionbox
\newbox\mysubsectionbox
\newlength{\myheight}
\setlength{\myheight}{0.8cm}

\setbeamertemplate{headline}{%
  \leavevmode%
   \setbox\mysectionbox=\hbox{\insertsectionnavigationhorizontal{.5\paperwidth}{\hskip0pt plus1filll}{}}%
   \setbox\mysubsectionbox=\hbox{\insertsubsectionnavigationhorizontal{.5\paperwidth}{}{\hskip0pt plus1filll}}%
   \begin{beamercolorbox}[wd=.5\paperwidth,dp=0cm,ht=\myheight]{section in head/foot}%
      \vfil\box\mysectionbox\vfil
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.5\paperwidth,dp=0cm,ht=\myheight]{subsection in head/foot}%
      \vfil\box\mysubsectionbox\vfil%
    \end{beamercolorbox}%
}

\def\insertsectionnavigationhorizontal#1#2#3{%
  \hbox to #1{{%
     \def\slideentry##1##2##3##4##5##6{}%
     #2\hskip.3cm%
     \parbox{.45\paperwidth}{\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
     \setbox\beamer@sectionbox=\hbox{}%
     \ht\beamer@sectionbox=1.875ex%
     \dp\beamer@sectionbox=0.75ex%
     \hskip-1.875ex plus-1fill\dohead%
     \box\beamer@sectionbox}\hfil\hskip.3cm%
     #3}}}

\def\insertsubsectionnavigationhorizontal#1#2#3{%
  \hbox to #1{{%
    \usebeamerfont{subsection in head/foot}\usebeamercolor[fg]{subsection in head/foot}%
    \beamer@currentsubsection=0%
    \def\sectionentry##1##2##3##4##5{}%
    \def\slideentry##1##2##3##4##5##6{\ifnum##6=\c@part\ifnum##1=\c@section%
      \ifnum##2>\beamer@currentsubsection%
      \beamer@currentsubsection=##2%
      \box\beamer@sectionbox\hskip1.875ex plus1fill%
      \setbox\beamer@sectionbox=
      \hbox{\def\insertsubsectionhead{##5}%
         \def\insertsectionheadnumber{##1}%
         \def\insertsubsectionheadnumber{##2}%
         \def\insertpartheadnumber{##6}%
         \ifnum\c@subsection=##2%
        \beamer@link(##4){{\usebeamertemplate{subsection in head/foot}}}\else%
        \beamer@link(##4){{\usebeamertemplate{subsection in head/foot shaded}}}\fi}%
      \ht\beamer@sectionbox=1.875ex%
      \dp\beamer@sectionbox=0.75ex%
      \fi\fi\fi\ignorespaces}%
    \hskip.3cm\parbox{.45\paperwidth}{ #2\setbox\beamer@sectionbox=\hbox{}%
    \hskip-1.875ex plus-1fill\dohead%
    \box\beamer@sectionbox\hfil%
    #3}}}}

\makeatother




\begin{document}

\section{title}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}
\section{titlea}

\subsection{title}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}

\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}

\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} \subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}

\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 
\subsection{titlea}
\begin{frame}
    abc
\end{frame} 

\end{document}
```


![Screen Shot 2020-07-09 at 15.20.22.png](/image?hash=c67f8ec5e2aa53ba434cbcca110549a4e65cf2ac77d7e696b49997820af889bd)

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.