1

I am trying to create a sidebar like the one present in beamer documents, which lists the Table of Contents information for easy document navigation. Even better if it can automatically show only the subsections for the current section. How can this be implemented in other LaTeX classes, such as the article class, for use with pdflatex? This page has a suggestion but it does not work in pdflatex.

  • please help us by adding an example of your code. – touhami Mar 8 '16 at 19:35
  • There is no example because I do not know how to implement this. Thus, the question. – user5359531 Mar 8 '16 at 19:53
  • What I mean is that we need to know class, packages used. – touhami Mar 8 '16 at 20:24
  • article class would be most convenient but is not essential. I do not know which packages are best suited for this. I am interested in any examples or any suggestions anyone might have on implementing this. – user5359531 Mar 8 '16 at 20:39
  • well i will try to see. – touhami Mar 8 '16 at 21:34
2

Here is a solution using etoc package

\documentclass{article}
\usepackage{lipsum}

\usepackage{etoc}
\etocsettocdepth{2}% only subsection
\etocsettocstyle{}{}% no heading
\etocsetstyle {subsection}
{}
{}
{\etocnumber.\etocname\nobreak\quad\nobreak\etocpage\hfill}
{}

% here with fancyhdr package
\usepackage{fancyhdr}
\fancyhf{} 
\fancyhead[C]{\tableofcontents \ref{\mt}} 
\fancyfoot[C]{\thepage}
\pagestyle{fancy}

% or with background package
%\usepackage[placement=top,scale=1]{background}
%\backgroundsetup{contents={\tableofcontents \ref{\mt}},color=blue}

\usepackage{hyperref}

\begin{document}
\section{Foo}
\edef\mt{foo}\invisiblelocaltableofcontents\label{\mt}
\subsection{Foo bar}
\lipsum[1]
\subsection{Foo baz}
\subsubsection{Foo baz}
\newpage
\lipsum[1]
\subsection{Foo Bye}
\lipsum[1]
\section{Baz}
\edef\mt{baz}\invisiblelocaltableofcontents\label{\mt}
\subsection{Baz bar}
\lipsum[1]
\newpage
\subsection{Baz baz}
\lipsum[1]
\subsection{Baz Bye}
\lipsum[1]
\end{document} 

with fancyhdr enter image description here


with background

enter image description here

| 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.