Combine labels and allowframebreaks in beamer class - latex

For my latex beamer presentations, I have used a labeling system with short, long, and both, to quickly switch between short presentations and longer ones.
To do so, I use the code
\includeonlyframes{both,short} (for a short presentation, and likewise \includeonlyframes{both,long} for a long one) in the preamble, and put a label to each slide like this:
\begin{frame}[label=both]
This system has served me relatively well in the past, but it has also created some problems. The particular one I am trying to solve is that my references exceed one slide. I tried to use allowframebreaks to solve this, so here is the code for my reference slide:
\begin{frame}[allowframebreaks,label=both]
\frametitle{References}
\tiny
\bibliographystyle{apalike}
\bibliography{references}
\end{frame}
What happens now is that the first reference slide is displayed as it's supposed to, but the remaining ones aren't part of the pdf. I guess what is happening is that the label is only applied to the first slide, so due to my \includeonlyframes command in the preamble, the remaining reference slides are produced, but not included in the pdf. Does anyone have an idea how I could get around this problem?
Also, this is my first post here, so please let me know if something is unclear/badly explained etc.
Edit: Here's a minimal working example. I usually use natbib, but that didn't work with the example bibliography I used here. The issue still occurs, so I don't think natbib has anyhting to do with it.
\documentclass{beamer}
%\usepackage{natbib}
\includeonlyframes{both,short}
\begin{document}
\begin{frame}[label=both]
\frametitle{Frametitle}
Some content for both presentations
\end{frame}
\begin{frame}[label=short]
\frametitle{Frametitle}
Some content for a short presentation
\end{frame}
\begin{frame}[label=long]
\frametitle{Frametitle}
Some content for a long presentation
\end{frame}
\begin{frame}[label=long]
\frametitle{Frametitle}
Some more content for a long presentation
\end{frame}
\begin{frame}[allowframebreaks,label=both]
\frametitle{References}
%\tiny
\nocite{*}
\bibliographystyle{apalike}
%\bibliography{references} \bibliography{xampl}
\end{frame}
\end{document}

You can use a similar approach as in https://tex.stackexchange.com/a/289637 and update it to use the current implementation of \beamer####frame:
\documentclass{beamer}
\makeatletter
\def\beamer####frame<#1>[#2]{%
\framewidth\textwidth
\beamer#savemode%
\gdef\beamer#mode{\mode<all>}%
\def\beamer#frametemplate{}%
\def\beamer#againname{}%
\def\beamer#undolabels{}%
\def\beamer#cramped{}%
\def\beamer#displaybreak{}%
\setbox\beamer#footins=\box\voidb#x%
\beamer#autobreakcount=0\relax%
\beamer#autobreaklastheight=16000pt%
\beamer#zoomcount=0\relax%
\beamer#noframenumberingfalse%
\beamer#containsverbatimfalse%
\beamer#isfragilefalse%
\beamer#autobreakfalse%
\beamer#shrinkfalse%
\beamer#plainframefalse%
\global\advance\beamer#zoomframecount by1\relax%
\csname beamer#dosecondmode\beamer#defaultdosecondmode\endcsname%
\ifbeamer#centered\setkeys{beamerframe}{c}\else\setkeys{beamerframe}{t}\fi%
\setkeys{beamerframe}{environment=frame}%
\setkeys{beamerframe}{#2}%
\beamer#frametemplate%
\ifbeamer#noframenumbering%
\ifbeamer#isfragile%Fragile frames will be processed twice
\stepcounter{framenumber}%
\fi%
\else%
\stepcounter{framenumber}%do not set \label here - it interferes with AtBegin*
\fi%
{\let\#elt\beamer#savecounter\beamer#overlaycounterresets}
\gdef\beamer#framestartpage{}%
\gdef\beamer#whichframes{#1}%
\ifx\beamer#framerestriction\#undefined\else% restriction stuff
\expandafter\beamer#checkifinlist\beamer#framerestriction\relax%
\fi%
\ifbeamer#inlecture%
\else%
\gdef\beamer#whichframes{all:0}%
\fi%
\ifx\beamer#againname\#empty%
\beamer#slideinframe=0\relax%
\beamer#anotherslidefalse%
\beamer#masterdecode{\beamer#whichframes}%
\ifbeamer#anotherslide%
\let\beamer#howtotreatframe\beamer#doseveralframes%
\ifbeamer#containsverbatim%
\let\beamer#howtotreatframe\beamer#dosingleframe%
\fi%
\ifbeamer#autobreak%
\let\beamer#howtotreatframe\beamer#autobreakframe%
\fi%
\ifbeamer#isfragile%
\let\beamer#howtotreatframe\beamer#doexternalframe%
\fi%
\else% no slides in frame
\let\beamer#howtotreatframe\beamer#donoframe%
\fi%
\else% again mode
\let\beamer#howtotreatframe\beamer#doseveralframes%
\ifbeamer#isfragile%
\let\beamer#howtotreatframe\beamer#doexternalframe%
\fi%
\ifbeamer#containsverbatim
\let\beamer#howtotreatframe\beamer#dosingleframe
\fi
\beamer#slideinframe=0\relax%
\beamer#anotherslidefalse%
{\beamer#masterdecode{\beamer#whichframes}}%
\message{^^J^^J \beamer#againname:\beamer#whichframes ^^J^^J}
\ifbeamer#anotherslide%
\message{^^J^^J \beamer#againname:I am Here ^^J^^J}
\ifbeamer#autobreak%
\let\beamer#howtotreatframe\beamer#autobreakframe%
\fi%
\fi
\fi%
\beamer#howtotreatframe}
\makeatother
\includeonlyframes{both,long}
\begin{document}
\begin{frame}[allowframebreaks,label=both]
\nocite{*}
\frametitle{References}
%\tiny
\bibliographystyle{apalike}
\bibliography{\jobname}
\end{frame}
\begin{frame}[label=long]
content...
\end{frame}
\end{document}

Related

How could I change the numeration style in table of contens in beamer (Latex)?

Hello I am new at beamer (overleaf), so I have learned very much, so I would like to change the design of the numeration in table of contents. I mean with that (see picture attached):
I would like to change to a square, or simply the number. Anyone knows others styles? I am using the \usetheme{CambridgeUS}.
You can set the sections/subsections in toc template to change to e.g. a square or plain numbered sections:
\documentclass{beamer}
\usetheme{CambridgeUS}
\setbeamertemplate{sections/subsections in toc}[square]
%\setbeamertemplate{sections/subsections in toc}[sections numbered]
\begin{document}
\section{title}
\begin{frame}
\tableofcontents
\end{frame}
\end{document}

Moving navigation bar to the bottom of the frame - Beamer latex, Frankfurt theme

I would like to move the black navigation bar at the bottom of the frame.
How can I do that ?
Here is a screenshot of how it is right now :
I'm using the Frankfurt theme in overleaf :
\documentclass[11pt]{beamer}
\usetheme{Frankfurt}
Frankfurt uses the smootbars outer theme. You can copy the definition of the smoothbars headline and use it as footline:
(make sure your beamer version is reasonable up to date, I recently changed the code of the shading a bit to make them transparent, so the code below might not work correctly with old beamer versions)
\documentclass[11pt]{beamer}
\usetheme{Frankfurt}
\setbeamertemplate{headline}{}
\makeatletter
\setbeamertemplate{footline}{
\pgfuseshading{beamer#barshade}%
\vskip-0.05ex%
\begin{beamercolorbox}[wd=\paperwidth,ht=1ex,dp=0ex]{empty}
\begin{pgfpicture}
\begin{pgfscope}%
\ifbeamer#sb#subsection%
\pgfsetfillcolor{subsection in head/foot.bg}%
\else%
\pgfsetfillcolor{section in head/foot.bg}%
\fi%
\pgfpathrectangle{\pgfpoint{-.5\paperwidth}{-0.5ex}}{\pgfpoint{\paperwidth}{1ex}}%
\pgfsetfading{beamer#belowframetitlemask}{}%
\pgfusepath{fill}%
\end{pgfscope}%
\end{pgfpicture}%
\end{beamercolorbox}%
\ifbeamer#sb#subsection%
\vskip-9.75ex%
\else%
\vskip-6.85ex%
\fi%
\begin{beamercolorbox}[ignorebg,ht=2.25ex,dp=3.75ex]{section in head/foot}
\insertnavigation{\paperwidth}
\end{beamercolorbox}%
\ifbeamer#sb#subsection%
\begin{beamercolorbox}[ignorebg,ht=2.125ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\usebeamerfont{subsection in head/foot}\insertsubsectionhead
\end{beamercolorbox}%
\fi%
}
\makeatother
\begin{document}
\section{title}
\begin{frame}
abc
\end{frame}
\end{document}

Changing Margin in LaTeX

I'm new to LaTex and I wanted to know how I can change the Margins of my scrreport so that the chapter title, text and basically everythin starts a bit higher and ends a bit lower. In my opinion there is too much empty space before anything starts.
If I use this simple example:
\documentclass[12pt,a4paper,twoside]{scrreport}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blindtext
\end{document}
I think the margins from top and bottom are too big. So i want everything to move up a little bit.
Thanks!
Method 1:
Choose one of the predefined layouts. You'll find a list of available options in the koma script documentation.
\documentclass[12pt,a4paper,twoside,DIV=15]{scrreport}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blinddocument
\end{document}
Method 2:
Setting up the text area manually. You should be really sure that you know what you are doing to get an aesthetically pleasant result.
\documentclass[12pt,a4paper,twoside]{scrreport}
\areaset[current]{168.00mm}{250mm}
\usepackage{blindtext}
\begin{document}
\chapter{First Chapter}
\blinddocument
\end{document}

Control white space of section locally on latex

is there a way to control the white space above just one specific section in latex? Most solutions I've found rely on the titlesec package, but as far as I know that would change every section.
Thanks for the help!
Use \vspace*{length} command, just before your section begins. For example:
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum
\section{Section 1}
\lipsum
\vspace*{1cm}
\section{Section moved down}
\lipsum
\end{document}
moves the second section 1cm down.

Beamer Headline setup

I'm currently working on an own beamer template (actually I'm trying to remodell an existing power point design so I can do my presentations using Latex).
The existing template has a titlebar which shows a logo on the right and a small colored bar below the bar. This titlebar is shown for the titlepage, as well as for the text slides. Within the textslides the titlebar also contains the current frames title and subtitle, each in i its own font size and color.
Using the beamer user guide and other templates, I figured that every frame has a headline, which is sometimes used to show the current section, and a frame title where usually the frametitle and subtitle are shown. The headline is shown topmost, followed by the frame title. The frame title however, is not shown on the titlepage.
A (I hope as minimal as possible) working example of my setup is:
\setbeamercolor*{frametitle}{fg=white,bg=blue}
\setbeamercolor*{framesubtitle}{fg=gray,bg=blue}
\defbeamertemplate*{headline}{formusic}
\ifx\insertframetitle\#empty%
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\hfill
\includegraphics[scale=0.15]{logo.png}
\end{beamercolorbox}
\else%
\fi%
\defbeamertemplate*{frametitle}{formusic}
\ifx\insertframetitle\#empty%
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\end{beamercolorbox}
\else%
\ifx\insertframesubtitle\#empty%
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\raisebox{0.55cm}{\insertframetitle}
\hfill
\includegraphics[scale=0.15]{logo.png}
\end{beamercolorbox}
\else%
\hbox{
\vbox{
\begin{beamercolorbox}[wd=\paperwidth, ht=0.7cm]{frametitle}
\insertframetitle
\end{beamercolorbox}
\begin{beamercolorbox}[wd=\paperwidth, ht=0.7cm]{framesubtitle}
\insertframesubtitle
\end{beamercolorbox}}
\includegraphics[scale=0.15]{logo.png}}
\fi
\fi%
The results of this can be seen in these slide headers. For the first, the titlepage this looks fine (I used the blue background color in order to visualize my problems), however for the other slides it does not look that good.
The headline does not seem to support the '\insertframe(sub)title' commands. Therefore I use a workaround where I display the empty titlebar within the headline for the first page with ifnum\c#framenumber=1, and for all other pages an empty headline. On these slides, the titlebar is displayed by the frametitle. This works - almost - as there is still a small white line visible between the frametitle and the top border of the slide.
My second problem is: How do I ideally arange the frametitle, -subtitle and logo in my titlebar? I played around a lot with beamercolorboxes, however I'm not 100% satisfied with what I have achieved so far. My attempt would be to have the frametitle and the subtitle in separate beamercolorboxes (this seems to be the most clean attempt, since I can use separately defined layouts for each, instead of switching font size and color), which are below each other. However now I don't know how to position the logo.
Edit: Added code example and images according to Werners suggestion and edited the text acordingly.
A quick workaround: not use a headline at all, but make sure that the frametitle will be shown on all frames, even those without frametitle:
\documentclass{beamer}
\setbeamertemplate{headline}{}
\setbeamercolor{frametitle}{fg=white,bg=blue}
\setbeamercolor{framesubtitle}{fg=gray,bg=blue}
\makeatletter
\patchcmd{\endbeamer#frameslide}{\ifx\beamer#frametitle\#empty}{\iffalse}{}{\errmessage{failed to patch}}
\makeatother
\makeatletter
\setbeamertemplate{frametitle}{%
\ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
\#tempdima=\textwidth%
\advance\#tempdima by\beamer#leftmargin%
\advance\#tempdima by\beamer#rightmargin%
\begin{beamercolorbox}[sep=0.3cm,left,wd=\the\#tempdima]{frametitle}
\begin{minipage}{.81\paperwidth}
\usebeamerfont{frametitle}%
\vbox{}\vskip-1ex%
\if#tempswa\else\csname beamer#fteleft\endcsname\fi%
\strut\insertframetitle\par%
{%
\ifx\insertframesubtitle\#empty%
\else%
{\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\strut\insertframesubtitle\par}%
\fi
}%
\end{minipage}%
\quad\raisebox{-0.3cm}{\includegraphics[width=.1\paperwidth]{example-image-duck}}
\if#tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
\end{beamercolorbox}%
}
\makeatother
\begin{document}
\begin{frame}
abc
\end{frame}
\begin{frame}
\frametitle{title}
abc
\end{frame}
\begin{frame}
\frametitle{very long title which possible spans over multiples lines...}
abc
\end{frame}
\begin{frame}
\frametitle{title}
\framesubtitle{subtitle}
abc
\end{frame}
\begin{frame}
abc
\end{frame}
\end{document}

Resources