我寫了一個基於「metropolis」beamer 主題 + fontspec + Fira 字體的簡單 .sty 檔案。我喜歡在扉頁中出現像 MWE 中那樣的作者和機構的想法,即每個作者/機構一行。這個佈局的缺點是,如果我想使用 \author 和 \institution 宏,我必須透過\\
同一inst中的單獨共同作者傳遞參數。align=left
照顧這個。問題是新段落使用預設顏色,即黑色,不再有\usebeamercolor[fg]{author}
.color = \usebeamercolor[fg]{author}
在節點定義中使用會Missing \endcsname inserted
出錯。color = white
有效,這就是我現在正在做的事情,但這意味著對顏色進行硬編碼,最好避免這種情況。解決方案可能是拆分作者列表,例如將 \@authors 列表拆分為 \and並遍歷作者,但這對我正在做的事情來說似乎有點矯枉過正。有沒有更簡單的方法適用\usebeamercolor[fg]{author}
於所有作者?
微量元素:
\documentclass[11pt, aspectratio=169]{beamer} %
\usetheme[]{metropolis}
% Requirement
\usepackage{tikz}
\usepackage{fontspec}
% colors
\definecolor{BGlightBlu}{HTML}{3461AA}
% Fonts
\newfontfamily{\RuLight}{Rubik Light}
% Settings
\setbeamercolor*{author}{fg = white}
% innertheme
\defbeamertemplate*{title page}{thisStyle}[1][]
{%
\begin{tikzpicture}[remember picture,overlay]
\draw[fill=BGlightBlu, BGlightBlu] (current page.south west) rectangle
(current page.north east);
% Title
\node
[ align=left,
xshift=.6cm,
yshift = 1cm,
minimum width=0.8\textwidth,
text width=0.7\textwidth,
anchor = west,
font = {\RuLight \LARGE},
text = white,
execute at begin node=\setlength{\baselineskip}{0.7\baselineskip}
] (title) at (current page.west)
{
\inserttitle
};
% Author
\node
[
below=0.6cm,
align=left,
anchor = north west,
xshift=.6cm,
font={\RuLight \footnotesize},
align=left,
% color=white, %works
% color = \usebeamercolor[fg]{author}, % 'Missing \endcsname' error
execute at begin node=\setlength{\baselineskip}{01.2\baselineskip}
] (author) at (title.south west){ \usebeamercolor[fg]{author} \insertauthor
};
% Inst
\node
[
xshift = 0.5\textwidth,
below=0.6cm,
align=left,
anchor = north west,
font={\RuLight \footnotesize},
align=left,
color=white,
execute at begin node=\setlength{\baselineskip}{1.2\baselineskip}
] (inst) at (title.south west){ \insertinstitute };
\end{tikzpicture}
}
\title[]{The title is so long that it needs two lines}
\author[]{Me Myself \\ My First Coauthor, My Second Coauthor}
\institute[]{My Place alone (MPA) \\ Their place, together (TPT)}
\begin{document}
\begin{frame}[plain]
\maketitle
\end{frame}
\end{document}
現在,我將程式碼拆分到 BgMWE.tex 和 beamerthemeMWE.sty 中以重現該錯誤。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% beamerthemeMWE.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>
\usetheme[]{metropolis}
% Requirement
\usepackage{tikz}
% Settings
\setbeamercolor*{author}{fg = red}
% innertheme
\setbeamertemplate{background}{
\begin{tikzpicture}
\draw[fill=BGlightBlu, BGlightBlu] (current page.south west) rectangle
(current page.north east);
\ifnum\thepage>1\relax%
\fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fi
\end{tikzpicture}
}
\defbeamertemplate*{title page}{MWE}[1][]
{%
\begin{tikzpicture}[remember picture,overlay]
% Title
\node
[ align=left,
xshift=.6cm,
yshift = 1cm,
minimum width=0.8\textwidth,
text width=0.7\textwidth,
anchor = west,
font = { \LARGE},
text = white,
execute at begin node=\setlength{\baselineskip}{0.7\baselineskip}
] (title) at (current page.west)
{
\inserttitle
};
% Author
\node
[
below=0.6cm,
align=left,
anchor = north west,
xshift=.6cm,
font={ \footnotesize},
align=left,
color = author.fg, % Here is the source of the error
execute at begin node=\setlength{\baselineskip}{0.8\baselineskip}
] (author) at (title.south west){ \insertauthor
};
% Inst
\node
[
xshift = 0.5\textwidth,
below=0.6cm,
align=left,
anchor = north west,
font={ \footnotesize},
align=left,
color=white,
execute at begin node=\setlength{\baselineskip}{0.8\baselineskip}
] (inst) at (title.south west){ \insertinstitute };
\node[below=0.5cm,
align=left,
anchor = north west,
font={ \large},
color=white,
] (date) at (author.south west){ \insertdate};
\end{tikzpicture}[action]{%
{\usebeamercolor[fg]{author}}% just to initialize the colour
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BgMWE.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[11pt, aspectratio=169]{beamer} %
\usetheme{MWE}
\title[]{The title is so long that it needs two lines}
\author[]{Me Myself \\ My First Coauthor, My Second Coauthor}
\institute[]{My Place alone (MPA) \\ Their place, together (TPT)}
\begin{document}
\begin{frame}[plain]
\maketitle
\end{frame}
\end{document}
如果我編譯 MWE.tex 我得到MWE.tex:14: Package xcolor Error: Undefined color `author.fg'.
Type H <return> for immediate help.```
答案1
只要您之前使用過作者顏色(一個簡單的{\usebeamercolor[fg]{author}}
即可),您就可以透過以下方式存取前景組件author.fg
:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BgMWE.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[11pt, aspectratio=169]{beamer}%
\begin{filecontents*}[overwrite]{beamerthemeMWE.sty}
\mode<presentation>
\usetheme{moloch}% modern fork of the metropolis theme
% Requirement
\usepackage{tikz}
\definecolor{BGlightBlu}{HTML}{3461AA}
% Settings
\setbeamercolor*{author}{fg = red}
% innertheme
\setbeamertemplate{background}{
\begin{tikzpicture}
\draw[fill=BGlightBlu, BGlightBlu] (current page.south west) rectangle
(current page.north east);
\ifnum\thepage>1\relax%
\fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fi
\end{tikzpicture}
}
\defbeamertemplate*{title page}{MWE}[1][]
{%
\begin{tikzpicture}[remember picture,overlay]
% Title
\node
[ align=left,
xshift=.6cm,
yshift = 1cm,
minimum width=0.8\textwidth,
text width=0.7\textwidth,
anchor = west,
font = {\LARGE},
text = white,
execute at begin node=\setlength{\baselineskip}{0.7\baselineskip}
] (title) at (current page.west)
{\inserttitle};
% Author
\node
[
below=0.6cm,
align=left,
anchor = north west,
xshift=.6cm,
font={\footnotesize},
align=left,
color = author.fg, % Here is the source of the error
execute at begin node=\setlength{\baselineskip}{0.8\baselineskip}
] (author) at (title.south west){\insertauthor};
% Inst
\node
[
xshift = 0.5\textwidth,
below=0.6cm,
align=left,
anchor = north west,
font={\footnotesize},
align=left,
color=white,
execute at begin node=\setlength{\baselineskip}{0.8\baselineskip}
] (inst) at (title.south west){\insertinstitute};
\node[below=0.5cm,
align=left,
anchor = north west,
font={\large},
color=white,
] (date) at (author.south west){\insertdate};
\end{tikzpicture}
}
{\usebeamercolor[fg]{author}}
\end{filecontents*}
\usetheme{MWE}
\title[]{The title is so long that it needs two lines}
\author[]{Me Myself \\ My First Coauthor, My Second Coauthor}
\institute[]{My Place alone (MPA) \\ Their place, together (TPT)}
\begin{document}
\begin{frame}[plain]
\maketitle
\end{frame}
\end{document}