2

I would like to use the Latex KOMA presentation template [1] for my presentation. But I want to replace the running head at the top by the (sub)section title.

Currently the Latex KOMA presentation template [1] looks as follows:

\documentclass[
paper=128mm:96mm, % The same paper size as used in the beamer class
fontsize=11pt, % Font size
pagesize, % Write page size to dvi or pdf
parskip=half-, % Paragraphs separated by half a line
]{scrartcl} % KOMA script (article)

\linespread{1.12} % Increase line spacing for readability

%------------------------------------------------
% Colors
\usepackage{xcolor}  % Required for custom colors
% Define a few colors for making text stand out within the presentation
\definecolor{mygreen}{RGB}{44,85,17}
\definecolor{myblue}{RGB}{34,31,217}
\definecolor{mybrown}{RGB}{194,164,113}
\definecolor{myred}{RGB}{255,66,56}
% Use these colors within the presentation by enclosing text in the commands below
\newcommand*{\mygreen}[1]{\textcolor{mygreen}{#1}}
\newcommand*{\myblue}[1]{\textcolor{myblue}{#1}}
\newcommand*{\mybrown}[1]{\textcolor{mybrown}{#1}}
\newcommand*{\myred}[1]{\textcolor{myred}{#1}}
%------------------------------------------------

%------------------------------------------------
% Margins
\usepackage[ % Page margins settings
includeheadfoot,
top=3.5mm,
bottom=3.5mm,
left=5.5mm,
right=5.5mm,
headsep=6.5mm,
footskip=8.5mm
]{geometry}
%------------------------------------------------

%------------------------------------------------
% Fonts
\usepackage[T1]{fontenc}     % For correct hyphenation and T1 encoding
\usepackage{lmodern} % Default font: latin modern font
%\usepackage{fourier} % Alternative font: utopia
%\usepackage{charter} % Alternative font: low-resolution roman font
\renewcommand{\familydefault}{\sfdefault} % Sans serif - this may need to be commented to see the alternative fonts
%------------------------------------------------

%------------------------------------------------
% Various required packages
\usepackage{amsthm} % Required for theorem environments
\usepackage{bm} % Required for bold math symbols (used in the footer of the slides)
\usepackage{graphicx} % Required for including images in figures
\usepackage{tikz} % Required for colored boxes
\usepackage{booktabs} % Required for horizontal rules in tables
\usepackage{multicol} % Required for creating multiple columns in slides
\usepackage{lastpage} % For printing the total number of pages at the bottom of each slide
\usepackage[english]{babel} % Document language - required for customizing section titles
\usepackage{microtype} % Better typography
\usepackage{tocstyle} % Required for customizing the table of contents
%------------------------------------------------

%------------------------------------------------
% Slide layout configuration
\usepackage{scrpage2} % Required for customization of the header and footer
\pagestyle{scrheadings} % Activates the pagestyle from scrpage2 for custom headers and footers
\clearscrheadfoot % Remove the default header and footer
\setkomafont{pageheadfoot}{\normalfont\color{black}\sffamily} % Font settings for the header and footer

% Sets vertical centering of slide contents with increased space between paragraphs/lists
\makeatletter
\renewcommand*{\@textbottom}{\vskip \z@ \@plus 1fil}
\newcommand*{\@texttop}{\vskip \z@ \@plus .5fil}
\addtolength{\parskip}{\z@\@plus .25fil}
\makeatother

% Remove page numbers and the dots leading to them from the outline slide
\makeatletter
\newtocstyle[noonewithdot]{nodotnopagenumber}{\settocfeature{pagenumberbox}{\@gobble}}
\makeatother
\usetocstyle{nodotnopagenumber}

\AtBeginDocument{\renewcaptionname{english}{\contentsname}{\Large Outline}} % Change the name of the table of contents
%------------------------------------------------

%------------------------------------------------
% Header configuration - if you don't want a header remove this block
\ihead{
\hspace{-2mm}
\begin{tikzpicture}[remember picture,overlay]
\node [xshift=\paperwidth/2,yshift=-\headheight] (mybar) at (current page.north west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=2\headheight,top color=mygreen!64,bottom color=mygreen]{}; % Colored bar
\node[below of=mybar,yshift=3.3mm,rectangle,shade,inner sep=0pt,minimum width=128mm,minimum height =1.5mm,top color=black!50,bottom color=white]{}; % Shadow under the colored bar
shadow
\end{tikzpicture}
\color{white}\runninghead} % Header text defined by the \runninghead command below and colored white for contrast
%------------------------------------------------

%------------------------------------------------
% Footer configuration
%\newlength{\footheight}
\setlength{\footheight}{8mm} % Height of the footer
\addtokomafont{pagefoot}{\footnotesize} % Small font size for the footnote

\ifoot{% Left side
\hspace{-2mm}
\begin{tikzpicture}[remember picture,overlay]
\node [xshift=\paperwidth/2,yshift=\footheight] at (current page.south west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=3pt,top color=mygreen,bottom color=mygreen]{}; % Green bar
\end{tikzpicture}
\myauthor\ \raisebox{0.2mm}{$\bm{\vert}$}\ \myuni % Left side text
}

\ofoot[\pagemark/\pageref{LastPage}\hspace{-2mm}]{\pagemark/\pageref{LastPage}\hspace{-2mm}} % Right side
%------------------------------------------------

%------------------------------------------------
% Section spacing - deeper section titles are given less space due to lesser importance
\usepackage{titlesec} % Required for customizing section spacing
\titlespacing{\section}{0mm}{0mm}{0mm} % Lengths are: left, before, after
\titlespacing{\subsection}{0mm}{0mm}{-1mm} % Lengths are: left, before, after
\titlespacing{\subsubsection}{0mm}{0mm}{-2mm} % Lengths are: left, before, after
\setcounter{secnumdepth}{0} % How deep sections are numbered, set to no numbering by default - change to 1 for numbering sections, 2 for numbering sections and subsections, etc
%------------------------------------------------

%----------------------------------------------------------------------------------------
%   PRESENTATION INFORMATION
%----------------------------------------------------------------------------------------
\newcommand*{\mytitle}{Presentation Title} % Title
\newcommand*{\runninghead}{Running Head} % Running head displayed on almost all slides
\newcommand*{\myauthor}{John Smith} % Presenters name(s)
\newcommand*{\mydate}{\today} % Presentation date
\newcommand*{\myuni}{University of California --- Department of Statistics} % University or department
%----------------------------------------------------------------------------------------

\begin{document}

%----------------------------------------------------------------------------------------
\section{Displaying Text}
\clearpage
%----------------------------------------------------------------------------------------

\end{document}

I have tried to replace the running head by the following custom \currtitle command:

\makeatletter
\newcommand{\currtitle}{\ttl@savetitle}
\makeatother

%------------------------------------------------
% Header configuration - if you don't want a header remove this block
\ihead{
\hspace{-2mm}
\begin{tikzpicture}[remember picture,overlay]
\node [xshift=\paperwidth/2,yshift=-\headheight] (mybar) at (current page.north west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=2\headheight,top color=mygreen!64,bottom color=mygreen]{}; % Colored bar
\node[below of=mybar,yshift=3.3mm,rectangle,shade,inner sep=0pt,minimum width=128mm,minimum height =1.5mm,top color=black!50,bottom color=white]{}; % Shadow under the colored bar
shadow
\end{tikzpicture}
\color{white}\currtitle} % Header text defined by the \runninghead command below and colored white for contrast

But how can I hide the section title within the slide? (below the green header bar) Or how can I move the (sub)section title to the running head position?

Thanks!

[1] http://www.latextemplates.com/template/koma-script-presentation

Martin
  • 23
  • 4
  • Please edit your question and add a minimal working example. And I don't get it: which kind of heading do you desire? – Keks Dose Oct 01 '14 at 09:26
  • I've included a minimal working example in the question. I want to have the section title at the running head position at the top. So no running head at all, but the section or subsection title should appear within the green header bar. – Martin Oct 02 '14 at 07:52
  • The problem is not to get the current section name but to hide the actual \section{Displaying Text} output. The section name (e.g., "Displaying Text") should only appear in the green header bar. – Martin Oct 02 '14 at 08:14
  • @Martin Make sure to ping people by adding an At-sign (@) in front of their name. – Johannes_B Oct 02 '14 at 12:39
  • Do you need a toc? If you don't it is quite simple and it suffices to do \renewcommand{\runninghead}{your title}. – Johannes_B Oct 02 '14 at 12:40
  • @Johannes_B I don't want to have a fixed running head title. I want to have the current section title instead of a constant running head. – Martin Oct 02 '14 at 13:25
  • You can use renewcommandas often as you like. Do you need an automatically generated toc? – Johannes_B Oct 02 '14 at 13:26
  • @Johannes_B You don't understand my problem. I would like to use the KOMA presentation template [1] but instead of a static running head, which is normally defined by \newcommand*{\runninghead}{Running Head}, I want to have the current section title within the green header bar at the top. Therefore I tried to use \newcommand{\currtitle}{\ttl@savetitle} within the header \ihead{...\color{white}\currtitle}, which prints the current section title within the green header bar at the top. But I also want to remove the section title within the slide (below the green header bar). – Martin Oct 02 '14 at 13:42
  • I understand the problem pretty well, but the question remains: Do you need a generated TOC? – Johannes_B Oct 02 '14 at 13:48
  • @Johannes_B Yes, I would like to generate a TOC by \thispagestyle{empty} % No slide header and footer \small\tableofcontents \clearpage – Martin Oct 02 '14 at 13:49
  • Would something like the following be enough? \newcommand\sectiona[1]{% \clearpage% \refstepcounter{section}% \renewcommand{\runninghead}{#1}% \addsectiontocentry{}{#1}% } – Johannes_B Oct 02 '14 at 14:51
  • @Johannes_B One last question. How can I define the commands \sectiona* and \subsectiona? Thanks again. – Martin Oct 02 '14 at 15:45

1 Answers1

2

I asked you in the comments, if you need to genereate a TOC and was pretty persistent with my request for an answer. There is a pretty good reason for that.

Right now, (with this solution/workaround) there are no section titles printed at all (in the classical sense using \@startsection). Everytime you call the new command sectiona the page ist cleared (i.e. a new page/slide starting), the running head is updated and a toc entry is created. One could just renew the section definition, but that would mean messing up the definition of \tableofcontents, and maybe a list of figures/tables or a bibliography.

The orignal paper by Markus is a few years old and many things changed. For example, KOMA now initiates a huge warning because titlesec is used. A new package called scrlayer-scrpage has joined the KOMA bundle making a great contribution to the running head thing.

To sum it up, the article presented a prototype to use the KOMA-article class for presentatins. There are some rough edges that need to be polished. For a prototype, it was quite good a few years ago, but right now, and especially in the provided template, I would say: »Keep your hands off it!«

Back to topic, what did i do? I used package xparse to check for a starred version. The starred version updates the running header (which is something like a frametitle), but does not place a toc-entry. Also, the counter of section (which isn't used anyway) is advanced by one.
If you don't use the starred command of sectiona, you can choose an optional title for the toc-entry. This is somehow equivalent to the standard behaviour of the section command.
subsectionas update the header, tough a bit smaller, and add a subsectionentry in the TOC.

DISCLAIMER: The template provided has some sharp edges, especially if you think overlays and nifty stuff like that are great, switch to a class that was designed to do this.
Don't get me wrong, using scrartcl for presentations is a great idea, but you will never get all the bells and whistles that beamer provides.

What is important to the MWE is just the following to be honest, not much, but still ...

\usepackage{xparse}
%
\DeclareDocumentCommand\sectiona{s o m}{%
    \clearpage%
    \IfBooleanTF{#1}{%
        \renewcommand{\runninghead}{#3}%
    }{%
        \refstepcounter{section}%JB: Please don't aske mw, %
%why i am doing this, as they aren't printed anyway%
        \renewcommand{\runninghead}{#3}%always use the%
%       mandatory argument for the runninghead%
        \IfNoValueTF{#2}{%
            \addsectiontocentry{}{#3}%
        }{%
            \addsectiontocentry{}{#2}%
        }%
    }%
}%
\newcommand\subsectiona[1]{%
    \clearpage%
    \refstepcounter{subsection}%
    \renewcommand{\runninghead}{\small #1\par}%
    \addsubsectiontocentry{}{#1}%
}%
%

And now the full example, ready to copy/paste/compile:

\documentclass[
paper=128mm:96mm, 
fontsize=11pt, 
pagesize, 
parskip=half-, 
]{scrartcl} 

\linespread{1.12} 

\usepackage{bm}  
\usepackage{xcolor}  

\definecolor{mygreen}{RGB}{44,85,17}
\definecolor{myblue}{RGB}{34,31,217}
\definecolor{mybrown}{RGB}{194,164,113}
\definecolor{myred}{RGB}{255,66,56}

\newcommand*{\mygreen}[1]{\textcolor{mygreen}{#1}}
\newcommand*{\myblue}[1]{\textcolor{myblue}{#1}}
\newcommand*{\mybrown}[1]{\textcolor{mybrown}{#1}}
\newcommand*{\myred}[1]{\textcolor{myred}{#1}}




\usepackage[ 
includeheadfoot,
top=3.5mm,
bottom=3.5mm,
left=5.5mm,
right=5.5mm,
headsep=6.5mm,
footskip=8.5mm
]{geometry}




\usepackage[T1]{fontenc}     
\usepackage{lmodern} 


\renewcommand{\familydefault}{\sfdefault} 




\usepackage{tikz} 
\usepackage{lastpage} 
\usepackage[english]{babel} 
\usepackage{microtype} 
\usepackage{tocstyle} 
\usepackage{scrpage2} 
\pagestyle{scrheadings} 
\clearscrheadfoot 
\setkomafont{pageheadfoot}{\normalfont\color{black}\sffamily} 

\makeatletter
\renewcommand*{\@textbottom}{\vskip \z@ \@plus 1fil}
\newcommand*{\@texttop}{\vskip \z@ \@plus .5fil}
\addtolength{\parskip}{\z@\@plus .25fil}
\makeatother

\makeatletter
\newtocstyle[noonewithdot]{nodotnopagenumber}{\settocfeature{pagenumberbox}{\@gobble}}
\makeatother
\usetocstyle{nodotnopagenumber}

\AtBeginDocument{\renewcaptionname{english}{\contentsname}{Outline}} 




\ihead{
\hspace{-2mm}
\begin{tikzpicture}[remember picture,overlay]
\node [xshift=\paperwidth/2,yshift=-\headheight] (mybar) at (current page.north west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=2\headheight,top color=mygreen!64,bottom color=mygreen]{}; 
\node[below of=mybar,yshift=3.3mm,rectangle,shade,inner sep=0pt,minimum width=128mm,minimum height =1.5mm,top color=black!50,bottom color=white]{}; 
shadow
\end{tikzpicture}
\color{white}\runninghead} 





\setlength{\footheight}{8mm} 
\addtokomafont{pagefoot}{\footnotesize} 

\ifoot{
\hspace{-2mm}
\begin{tikzpicture}[remember picture,overlay]
\node [xshift=\paperwidth/2,yshift=\footheight] at (current page.south west)[rectangle,fill,inner sep=0pt,minimum width=\paperwidth,minimum height=3pt,top color=mygreen,bottom color=mygreen]{}; 
\end{tikzpicture}
\myauthor\ \raisebox{0.2mm}{$\bm{\vert}$}\ \myuni 
}

\ofoot[\pagemark/\pageref{LastPage}\hspace{-2mm}]{\pagemark/\pageref{LastPage}\hspace{-2mm}} 




\usepackage{titlesec} 
\titlespacing{\section}{0mm}{0mm}{0mm} 
\titlespacing{\subsection}{0mm}{0mm}{-1mm} 
\titlespacing{\subsubsection}{0mm}{0mm}{-2mm} 
\setcounter{secnumdepth}{0} 





\newcommand*{\mytitle}{Presentation Title} 
\usepackage{nameref}
\newcommand*{\runninghead}{}
\newcommand*{\myauthor}{John Smith} 
\newcommand*{\mydate}{\today} 
\newcommand*{\myuni}{University of California --- Department of Statistics} 


\usepackage{xparse}
%
\DeclareDocumentCommand\sectiona{s o m}{%
    \clearpage%
    \IfBooleanTF{#1}{%
        \renewcommand{\runninghead}{#3}%
    }{%
        \refstepcounter{section}%JB: Please don't aske mw, %
%why i am doing this, as they aren't printed anyway%
        \renewcommand{\runninghead}{#3}%always use the%
%       mandatory argument for the runninghead%
        \IfNoValueTF{#2}{%
            \addsectiontocentry{}{#3}%
        }{%
            \addsectiontocentry{}{#2}%
        }%
    }%
}%
\newcommand\subsectiona[1]{%
    \clearpage%
    \refstepcounter{subsection}%
    \renewcommand{\runninghead}{\small #1\par}%
    \addsubsectiontocentry{}{#1}%
}%
%




\begin{document}
\tableofcontents
\sectiona{a section}
Text in a section, runninghead updated

\sectiona{a different section}
Text in another section, runninghead updated
\subsectiona{a subsection}
The runninghead is now smaller, to distiguish it a bit from a
section
\sectiona*{a starred section}
Text in a starred section, runninghead updated, but no toc entry

\sectiona[toc entry]{running head}
an optional argument? REALLY?
\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • I just saw that you want your toc-page empty. You can do it now using this[agestyl{empty}. Out of curiousity, is this what you want the page to look like? If not, i already mentioned package scrlayer-scrpage, capable of placing stuff at the background. – Johannes_B Oct 02 '14 at 21:20