I want to place picture in Beamer presentation next to the table of contents (TOC), specifically on the right side of the TOC.

I know that there are several questions about similar or even identical problems, e.g.:

but the posted answers doesn't work well because as a result I get TOC lowered (see screenshots below).

\documentclass{beamer}
\begin{document}

\begin{frame}
\begin{minipage}[t][0.6\textheight]{0.6\textwidth}
\vspace{0pt}
\tableofcontents
\end{minipage}
\begin{minipage}[t]{0.35\textwidth}
\vspace{0pt}
\includegraphics[width=.9\textwidth]{example-image-a}
\end{minipage}
\end{frame}

\section{A section with a name}
\begin{frame}
\end{frame}

\section{A longer section name, ....................}
\begin{frame}
\end{frame}

\section{another section}
\begin{frame}
\end{frame}

\section{a medium long section name}
\begin{frame}
\end{frame}

\end{document}


this is the result:

It seems to work well, but if you remove minipages like this:

\documentclass{beamer}
\begin{document}

\begin{frame}
\tableofcontents
\end{frame}

\section{A section with a name}
\begin{frame}
\end{frame}

\section{A longer section name, ....................}
\begin{frame}
\end{frame}

\section{another section}
\begin{frame}
\end{frame}

\section{a medium long section name}
\begin{frame}
\end{frame}

\end{document}


you get this:

If you put above screenshots side by side, like this:

you can clearly see that suggested solution lowers TOC. I want to place image next to TOC without lowering TOC and without absolute image positioning (because I want to be able to change aspectratio of the presentation without modifying hard coded image offsets).

How can I do this?

• The [t] option refers to the first baseline, which for an image is the same as the bottom, Use \raisebox to align images. – John Kormylo Sep 22 '17 at 23:06

Here is a start.

It works as second section etc... is not too long else it would hit the picture. In that case you only need to use a suitable \rightskip setting (or whatever works with beamer class to temporarily set right margin; I suspect rightskip will not necessarily play well but I have not tested as the code works fine enough with given example) and push the picture by a \rlap into available space.

\documentclass{beamer}

\DeclareRobustCommand\PICINTOC{}%

\newcommand\MYPICINTOC
{\hfill
\smash{\raisebox{-\height}{\includegraphics[width=.3\textwidth]{example-image-a}}}}

\begin{document}

\begin{frame}
\tableofcontents
\end{frame}

\section{A section with a name\PICINTOC}
\begin{frame}
\end{frame}

\section{A longer section name, ....................}
\begin{frame}
\end{frame}

\section{another section}
\begin{frame}
\end{frame}

\section{a medium long section name}
\begin{frame}
\end{frame}

\end{document}


• Clever! Get the TOC itself to write the picture. That way it doesn't matter what sort of offsets Beamers throws in. – John Kormylo Sep 26 '17 at 20:39
• @JohnKormylo but main defect is that the picture reserves no space... for this one would need more advanced tricks and possibly to check beamer code for the TOC, which I wanted to not have to do ;-) ... – user4686 Sep 26 '17 at 20:43
• I did check the beamer code. It didn't help. – John Kormylo Sep 26 '17 at 20:45