2

I wrote a simple .sty file building on the 'metropolis' beamer theme + fontspec + Fira fonts. I like in the title page the idea of authors and institutions appearing like in the MWE, i.e., one line per author(s)/institution. The drawback with this layout is that, if I want to use the \author and \institution macros, I have to pass the arguments with a \\ separating coauthors form the same inst. align=left takes care of that. The problem is that the new paragraph uses the default color, which is black, and no more \usebeamercolor[fg]{author}. Using color = \usebeamercolor[fg]{author}in the node definition gives a Missing \endcsname inserted error. color = white works, which is what I am doing now, but that means hard coding the color, which should be better avoided. A solution could be to split the list of authors like in Split the \@authors list at \and and loop over the the authors, but it looks like overkill for what I am doing. Is there a simpler way to apply \usebeamercolor[fg]{author} to all authors?

MWE:

\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}

Title frame

Now I split the code in a BgMWE.tex and a beamerthemeMWE.sty to reproduce the error.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  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}

If I compile MWE.tex I get MWE.tex:14: Package xcolor Error: Undefined color `author.fg'.

Type  H <return>  for immediate help.```

millo
  • 45

1 Answers1

3

As long as you've used the author colour before (a simple {\usebeamercolor[fg]{author}} will do), you can access the foreground component as 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}

enter image description here

  • Thanks a lot! Works fine in the MWE. But if I put both \setbeamercolor*{author}{fg = white}and the \defbeamertemplate*{title page}{thisStyle}[1][] {% ... } in a sty file, I get Package xcolor Error: Undefined color `author.fg'. – millo Jan 07 '24 at 16:00
  • @millo Please create a minimal reproducible example. – samcarter_is_at_topanswers.xyz Jan 07 '24 at 16:04
  • I don't know exactly how to go. I have edited the original post to split the code into sty and tex, but the two parts of the question are not consistent. – millo Jan 07 '24 at 17:16
  • Anyway, thanks for looking into this. I will accept your answer, since you addressed the original question – millo Jan 07 '24 at 17:17
  • @millo Please see my updated answer. Please also note that you need be a bit careful with spaces, e.g. font = { \LARGE}, would actually add a space before the title and misalign it with the second line. – samcarter_is_at_topanswers.xyz Jan 07 '24 at 18:59
  • Thanks samcarter, everything seems to work, and I prefer it like this, I did not understand the [action]part... The extra space is an unwanted side effect of reducing the original file to a MWE. Before \LARGE there are the font related commands, but I left all the fontspec part out. – millo Jan 07 '24 at 20:52
  • @millo The [action]{...} syntax meant that the code in {...} is executed when the template is actually defined. For your use case of \defbeamertemplate* that's not actually necessary as it is always defined, but if you had different title page templates in your theme, it might have been necessary. So in your case, not using it seems a good way to avoid the problem :) – samcarter_is_at_topanswers.xyz Jan 07 '24 at 20:59