我想使用 Latex KOMA 演示模板 [1] 進行演示。但我想更換跑步頭在(子)部分標題的頂部。
目前 Latex KOMA 示範模板 [1] 如下圖所示:
\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}
我嘗試更換跑步頭透過以下自訂\currtitle
命令:
\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
但是如何隱藏投影片中的章節標題呢? (綠色標題列下方)或如何將(子)部分標題移至跑步頭位置?
謝謝!
[1]http://www.latextemplates.com/template/koma-script-presentation
答案1
我在評論中詢問您是否需要產生目錄,並且非常堅持我的答案請求。這是有充分理由的。
現在,(使用此解決方案/解決方法)根本沒有列印任何章節標題(在經典意義上使用\@startsection
)。每次呼叫新命令時,sectiona
頁面都會被清除(即新頁面/幻燈片開始),運行頭會更新並建立目錄條目。人們可以只更新部分定義,但這意味著弄亂 的定義\tableofcontents
,可能也可能弄亂圖表/表格列表或參考書目。
馬庫斯的原始論文已有幾年歷史,很多事情都改變了。例如,KOMA 現在因titlesec
使用而發出巨大警告。一個名為 的新軟體包scrlayer-scrpage
已加入 KOMA 捆綁包,為運行頭做出了巨大貢獻。
總而言之,本文提出了一個使用 KOMA-article 類別進行演示的原型。有一些粗糙的邊緣需要拋光。對於原型來說,幾年前它已經相當不錯了,但現在,尤其是在提供的模板中,我會說:“別把手拿開!”
回到主題,我做了什麼?我使用 xparse 套件來檢查加星標的版本。帶有星號的版本更新了運行標題(類似於框架標題),但不放置目錄條目。此外, section
(無論如何都沒有使用)的計數器前進一。
如果您不使用 的加星號指令sectiona
,您可以為目錄項目選擇一個可選標題。這在某種程度上等同於section命令的標準行為。
subsectiona
更新標題,稍微小一點,並在目錄中新增一個小節條目。
免責聲明:提供的模板有一些尖銳的邊緣,特別是如果您認為覆蓋和類似的漂亮東西很棒,請切換到專門為此設計的類別。
不要誤會我的意思,使用 scrartcl 進行演示是一個好主意,但您永遠無法獲得它提供的所有附加功能
beamer
。
老實說,對 MWE 來說重要的只是以下幾點,不多,但仍然...
\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}%
}%
%
現在是完整的範例,準備複製/貼上/編譯:
\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}