Beamer Headline setup - latex

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}

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}

Text out of margin in latex multicols environment

I'm setting the margin configurations for multiple environments. For instances firstenvironment sets the margins using \setlength, then I make use of the multicols package inside the new environment. The problem is that the text doesn't seem to respect the bottom margin in the first page where the environment is just being used, but the text in the next pages do respect the margins. The same happens when I create a second environment with its own margin configurations. Not sure why the margins are not activated immediately when the environment begins. Any suggestions would be welcome, thanks!
PD. PDF compiled with Xelatex
\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{showframe} % show the frame margins
\usepackage{multicol}
\newenvironment{firstenvironment}{
\setlength{\hoffset}{0mm}
\setlength{\voffset}{0mm}
\setlength{\headsep}{20pt}
\setlength{\headheight}{4em}
\setlength{\textheight}{6in}
\setlength{\footskip}{10mm}}{}
\newenvironment{secondenvironment}{
\setlength{\hoffset}{0mm}
\setlength{\voffset}{0mm}
\setlength{\headsep}{5pt}
\setlength{\headheight}{2em}
\setlength{\textheight}{5in}
\setlength{\footskip}{20mm}}{}
\begin{document}
\begin{firstenvironment}
\setlength\columnsep{30pt}
\begin{multicols}{2}
{\Large\bf 1ST LIPSUM}\\
\lipsum[1-10]
\end{multicols}
\end{firstenvironment}
\newpage
\begin{secondenvironment}
\begin{multicols}{2}
{\Large\bf 2ND LIPSUM}\\
\lipsum[1-10]
\end{multicols}
\end{secondenvironment}
\end{document}
Photo, text out of bottom margin: image
I just figure out how to fix it. I made use of the package changepage. The idea is to include in the parameters of this command, the differences between the new margins and old margins. There is no need to use environments to set pages with different margins (which considers header, footer and margin notes), but to keep the same structure of the original post, I provide a solution that can be easily compared with.
\documentclass[12pt]{article}
\usepackage[paperheight=11in,paperwidth=8.5in,includeheadfoot]{geometry}
\usepackage{lipsum}
\usepackage{showframe}
\usepackage{multicol}
\usepackage{changepage}
\usepackage{calc}
\newenvironment{firstenvironment}{}{}
\newenvironment{secondenvironment}{}{}
\begin{document}
\setlength{\textheight}{7in}
\setlength{\headsep}{20pt}
\setlength{\headheight}{4em}
\setlength{\footskip}{10mm}
\begin{firstenvironment}
\begin{multicols}{2}
{\Large 1ST LIPSUM}\\
\lipsum[1-10]
\end{multicols}
\end{firstenvironment}
\newpage
\changepage{-2in}{}{}{}{}{}{2em-4em}{5pt-20pt}{20mm-10mm}
%\changepage{textheight}{textwidth}{evensidemargin}{oddsidemargin}{columnsep}{topmargin}{headheight}{headsep}{footskip}
\begin{secondenvironment}
\begin{multicols}{2}
{\Large 2ND LIPSUM}\\
\lipsum[1-10]
\end{multicols}
\end{secondenvironment}
\restoregeometry
\begin{firstenvironment}
\begin{multicols}{2}
{\Large 3rd LIPSUM}\\
\lipsum[1-10]
\end{multicols}
\end{firstenvironment}
\end{document}
The command \changepage considers the following parameters:
\changepage{textheight}{textwidth}{evensidemargin}{oddsidemargin}{columnsep}{topmargin}{headheight}{headsep}{footskip}
The margins that are left in blank under the \changepage command consider the default margins of the article class. If you want to restore the margins after setting a new one, just use the command \restoregeometry

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}

Combine labels and allowframebreaks in beamer class

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}

Defining a header with background color in Latex

For a small project I'm trying something that feels as if it should be peanut, but au contraire (Hey, that's french, never thought I'd remember some parts of that. anyway...).
The thing is, I want a latex layout where the header and footer span the entire pagewidth and have a background color, and also can have some elements on the left, center, or right (like with fancyhdr). The thing is, I simply cannot get this to work without screwing up the rest of the layout.
edit: added example.
Here's an example of what I have tried. The header is shown incorrectly since the background doesn't span the whole width of the page. The footer is not shown at all.
\documentclass[10pt,a4paper,notitlepage]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames]{color}
\usepackage{fancyhdr}
\usepackage{calc}
\usepackage{tikz}
\usepackage[landscape, top=0cm, bottom=3cm]{geometry}
\definecolor{logoGreen}{RGB}{218,226,87}
\newcommand{\HBG}{
\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-2cm] at (current page.north west)
{
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=logoGreen] (0,0) rectangle (\paperwidth,2cm);
\end{tikzpicture}
};
\end{tikzpicture}
}
\fancyhead{}
\fancyhead[L]{\HBG}
\fancyhead[C]{\includegraphics[height=1.2cm]{"img/headerimg"}}
\fancyfoot[C]{\includegraphics[height=1.2cm]{"img/footerimg"}}
\fancyhfoffset[]{1in+\hoffset+\oddsidemargin}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\headheight 3cm
\footskip -2cm
\pagestyle{fancy}
\begin{document}
\section{first section}
content
\end{document}
You can use TikZ to position coloured boxes absolutely on the page. See an example here.
This example includes usage of \thechapter, so you can probably go on from there.

Resources