0

I have the following org file:

#+TITLE: Some title
#+OPTIONS: H:2
#+latex_class: beamer


* Section 1
** Frame 1

* Section 2
** Frame 2

After org-exporting I obtain the .tex, which includes

% beginning of the document
\begin{document}

\maketitle
\begin{frame}{Outline}
\tableofcontents
\end{frame}
% rest of the document  ...

However, I want to apply some user-defined latex commands before and after outline frame to get something like:

% beginning of the document
\begin{document}

\maketitle
\AddBackButton
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\AddTableOfContentsButton
% rest of the document  ...

Keep in mind that user-defined commands should be applied only for an outline frame and not for others. How should I modify beamer exporting process to get above content in tex file?

PS. FYI, I want to add a button for each presentation frame that links to an outline frame (this is the job of \AddTableOfContentsButton command), and a button on an outline that allows user go back to the last frame he visited (this part is handled by \AddBackButton):

\newcommand\AddTableOfContentsButton{%
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=west] at ([yshift=5pt,xshift=\paperwidth/2-\shift]current page.south west)
  {\hyperlink{toc}{
  \setbeamercolor{button}{fg=white,bg=lightgray}%
  \beamerbutton{T} %\beamergotobutton{T}
  }};
\end{tikzpicture}%
  }%
}


\newcommand\AddBackButton{%
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=west] at ([yshift=5pt,xshift=\paperwidth/2-\shift]current page.south west)
  {
  \setbeamercolor{button}{fg=white,bg=lightgray}
  \beamerbutton{\Acrobatmenu{GoBack}{B}}
  };
\end{tikzpicture}%
  }%
2
  • Can you specify what \doSomethingBeforeOutline would do? Depending on what it does you could either use hooks to add it it to the \tableofocntents macro or automatically change the page style of the toc frame. Commented Sep 28, 2023 at 19:46
  • @samcarter_is_at_topanswers.xyz I have edited my question to give some more insights into what I want to achieve... I hope it's a bit more clear now Commented Sep 28, 2023 at 20:28

2 Answers 2

1

You can use the same trick as in https://topanswers.xyz/tex?q=1004 to automatically change the background template for your toc frame.

However are you sure you need to add a back button yourself? Beamer automatically includes them in the the navigation symbols (one could also add an icon to jump to the toc). They are placed in front of the content, so won't be obscured by large images or similar. Here the relevant excerpt from the beamer user guide:

enter image description here

Also many pdf viewers have a keyboard shortcut to go back to the previously viewed page, consider consulting the user manual of your viewer.

\documentclass{beamer}

\usepackage{tikz}

\setbeamertemplate{background canvas}{%
  \begin{tikzpicture}[remember picture,overlay]
    \node[anchor=west] at ([yshift=5pt,xshift=\paperwidth/2]current page.south west) {
      \hyperlink{toc}{
        \setbeamercolor{button}{fg=white,bg=lightgray}%
        \beamerbutton{T} %\beamergotobutton{T}
      }
    };
  \end{tikzpicture}%
}%


\makeatletter
\pretocmd{\tableofcontents}{\thispagestyle{navigation@toc}\label{toc}}{}{}
\addtobeamertemplate{title page}{\thispagestyle{navigation@title}}{}

\def\ps@navigation@title{%
  \setbeamertemplate{background canvas}{}
}

\def\ps@navigation@toc{%
  \setbeamertemplate{background canvas}{%
    \begin{tikzpicture}[remember picture,overlay]
      \node[anchor=west] at ([yshift=5pt,xshift=\paperwidth/2]current page.south west) {
      \setbeamercolor{button}{fg=white,bg=lightgray}
      \beamerbutton{\Acrobatmenu{GoBack}{B}}
      };
    \end{tikzpicture}%
  }
}
\makeatother





\begin{document}

\maketitle

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

\section{section}
\begin{frame}
content...
\end{frame}

\end{document}

enter image description here

4
  • That's the fast answer :). Thanks. Now the title page looks ok, and the buttons are where I want them to be but... this solution turned my table of contents from my enumerated, left aligned list into centered and unenumerated list of section titles... Commented Sep 29, 2023 at 13:15
  • The code from this answer does not change the formatting of the toc. The code fragments you show in your question don't produce numbered sections. There's probably something else in your code which you don't show. Commented Sep 29, 2023 at 13:17
  • Yes, you are right. I've got a whole bunch of lines in my latex .sty file, which I removed in my attempts to obtain what I was hoping would be MWE of the original problem. I guess that during this process I managed to transform it into sort of XY problem... Sorry about that. Commented Sep 30, 2023 at 10:08
  • 1
    Let's end this conversation now, because my new problems probably would require a new thread and since I succeeded to solve what I was interested in (point 3 here) I don't feel like doing it and wasting your precious time more ;) On the other hand, I think that difficulty of the issue partly comes from the the fact that the original code is written in org. If the source was a .tex file the problem would never appear. Commented Sep 30, 2023 at 10:08
0

@samcarter_is_at_topanswers.xyz

Sorry, I'm writing here but it's too long to put it as a comment...

  1. I like my navigation buttons because they are located at the same position on each slide, so you don't need to move the cursor on slide to go back-and-forth, you just click.

  2. The solution you provided works almost fine except the fact that it adds toc button to the titlepage and this is not what I want.

    I tried to circumvent it by mimicking your piece of code for the titlepage like this:

    \makeatletter
    \pretocmd{\maketitle}{\thispagestyle{navigation@titlepage}\label{toc}}{}{}
    
    \def\ps@navigation@titlepage{%
      \setbeamertemplate{background canvas}{%
       \begin{tikzpicture}[remember picture,overlay]
         \node[anchor=west] at ([yshift=5pt,xshift=\paperwidth/2]current page.south west) {
           \setbeamercolor{button}{fg=white,bg=lightgray}
    
      };
       \end{tikzpicture}%
      }
    }
    \makeatother
    

    but this, in turn, devastates the titlepage. Can I set background canvas just for the titlepage in the same manner as for toc page?

  3. Anyway, the line with pretocmd in your code inspired me to invent one more approach. I added: #+beamer_header:\apptocmd{\maketitle}{\AddBackButton}{}{} to the preamble, and

    #+begin_export beamer
    \AddTableOfContentsButton
    #+end_export
    

    somewhere below the first section and before the first frame (between the first node with * and the first node with ** in an org-file). It's not very elegant solution I guess, but it works at least.

1
  • See my updated answer. You can use a different page style for the title page, but don't use the same label twice! Commented Sep 29, 2023 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.