![节点中采用投影仪样式的文本颜色](https://linux22.com/image/472598/%E8%8A%82%E7%82%B9%E4%B8%AD%E9%87%87%E7%94%A8%E6%8A%95%E5%BD%B1%E4%BB%AA%E6%A0%B7%E5%BC%8F%E7%9A%84%E6%96%87%E6%9C%AC%E9%A2%9C%E8%89%B2.png)
我基于“metropolis”beamer 主题 + fontspec + Fira 字体编写了一个简单的 .sty 文件。我喜欢在标题页中像 MWE 中那样显示作者和机构的想法,即每个作者/机构一行。这种布局的缺点是,如果我想使用 \author 和 \institution 宏,我必须传递带有\\
分隔合著者表格的参数,该表格来自同一个 inst。align=left
处理这个问题。问题是新段落使用默认颜色,即黑色,没有更多\usebeamercolor[fg]{author}
。color = \usebeamercolor[fg]{author}
在节点定义中使用会产生Missing \endcsname inserted
错误。color = white
有效,这就是我现在正在做的,但这意味着对颜色进行硬编码,最好避免这种情况。一种解决方案可能是像在 \and 处拆分 \@authors 列表并循环遍历作者,但对于我所做的来说,这似乎有点过度了。有没有更简单的方法可以应用于\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}