carl
Below I show a simple example of Beamer slides. I want to place a beamerbutton vertically to my footline. I know the way of \btVFill, which is very close to what I am looking for.
I would like to place the button directly next to the frame number, however, I only need the button on a few slides and so putting it in the footline does not seem like the right way to go.
Any thoughts on how to achieve this?
Code:
```
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{
\hspace*{0.2cm}
Author
\hfill
{\insertframenumber{}}
\hspace*{0.2cm}
\vspace{0.3cm}
}
\newcommand{\btVFill}{\vskip0pt plus 1filll}
\begin{document}
\begin{frame}
\frametitle{Header}
\btVFill\hfill\beamerbutton{Button}
\end{frame}
\end{document}
```
Expected Result:
![tex.JPG](/image?hash=7fdec98cdea539e45a566994744185bf4275b59eb47cd261f1187ec4a57b85fe)
Top Answer
samcarter
## Beamer solution
If the button should only be displayed on some slides, you can still temporarily add them to the footline by making any changes inside a group `{...}`:
```
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{page number in head/foot}[framenumber]
\setbeamertemplate{footline}{
\hspace*{0.2cm}
Author
\hfill
{\usebeamertemplate{page number in head/foot}}
\hspace*{0.2cm}
\vspace{0.3cm}
}
\begin{document}
{
\addtobeamertemplate{page number in head/foot}{\raisebox{-0.5ex}{\beamerbutton{Button}}\quad}{}
\begin{frame}
\frametitle{Header}
\end{frame}
}
\begin{frame}
content...
\end{frame}
\end{document}
```
If you need this for more (non-consecutive) frames, you could make a custom frame option out of this, see
@@@ answer 1369
for an example how to do this.
And just for completes, here also the code for adding the button for the whole presentation:
```
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{page number in head/foot}[framenumber]
\setbeamertemplate{footline}{
\hspace*{0.2cm}
Author
\hfill
{\raisebox{-0.5ex}{\beamerbutton{Button}}\quad\usebeamertemplate{page number in head/foot}}
\hspace*{0.2cm}
\vspace{0.3cm}
}
\begin{document}
\begin{frame}
\frametitle{Header}
\end{frame}
\begin{frame}
content...
\end{frame}
\end{document}
```
![Screen Shot 2021-04-14 at 10.06.50.png](/image?hash=a29203b78a905387dceeef1b0500f325ccebc6a109bba4f69ad0c0ecbe690e38)
(the `page number in head/foot` template needs beamer version 3.54 or newer)
## Rmarkdown solution
### Edit 1:
Rmarkdown makes all this a bit more complicate, but one could hack it by showing the button only on predefined framenumbers.
For example
```
\ifnum\insertframenumber=2
\raisebox{-0.5ex}{
\hyperlink{slide-3}{\beamerbutton{Button}}
}\quad
\fi
```
will only show the button on the second frame. To add it to more frames, either repeat the code or, if you want the button on several consecutive frames, use some ifcase with `>` and `<`.
The other difficulty is to get a label for the link target. In normal beamer that is so easy with `\begin{frame}[label=quack]`, but in markdown you have to make a lucky guess on what name markdown will use for the labels it automatically created. For example if you want to link to a frame with the title `slide 3`, the automatic label seems to be `slide-3`. Replace this with whatever frame you want to link to
```
---
output:
beamer_presentation:
keep_tex: true
header-includes:
- \setbeamertemplate{navigation symbols}{}
- \setbeamertemplate{page number in head/foot}{\insertframenumber}
- \setbeamertemplate{footline}{\hspace*{0.2cm}Author\hfill{\ifnum\insertframenumber=2 \raisebox{-0.5ex}{\hyperlink{slide-3}{\beamerbutton{Button}}}\quad\fi\usebeamertemplate{page number in head/foot}}\hspace*{0.2cm}\vspace{0.3cm}}
---
# slide 1
test
# slide 2
test
# slide 3
test
```
### Edit 2:
Totally different approach: one can also use tikz to position the button
```
---
output:
beamer_presentation:
keep_tex: true
header-includes:
- \include{preamble}
---
# slide 1
test
# slide 2
\mybutton{slide-3}{some text}
test
# slide 3
test
```
with `preamble.tex`:
```
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{page number in head/foot}{\insertframenumber}
\setbeamertemplate{footline}{
\hspace*{0.2cm}
Author
\hfill
{\usebeamertemplate{page number in head/foot}}
\hspace*{0.2cm}
\vspace{0.3cm}
}
\usepackage{tikz}
\newcommand{\mybutton}[2]{%
\begin{tikzpicture}[remember picture, overlay]
\node[xshift=-1.5cm, yshift=0.4cm] at (current page.south east) {\hyperlink{#1}{\beamerbutton{#2}}};
\end{tikzpicture}
}
```