
я использовалэтот ответ на вопрос о том, как разработать тему для Beamer с нулядля разработки темы Beamer, которая будет выглядеть как шаблон университетской презентации (Powerpoint). Для шаблона Powerpoint есть 3 варианта цвета (синий, зеленый, сланцевый). Я знаю, что одним из вариантов решения было бы создание 3 отдельных цветовых тем и просто вызов их с помощью;
\usecolortheme{mythemeblue}
\usecolortheme{mythemegreen}
\usecolortheme{mythemeslate}
Однако мне бы хотелось определить все различные цвета в одном файле colortheme, а затем иметь возможность использовать опцию для их вызова следующим образом:
\usetheme[blue]{mytheme} %or green or slate
Я видел вопросы на сайте, которые, кажется, используют \DeclareOption
(на этот вопрос, но не смог приступить к работе) или \DeclareOptionBeamer
(Этот вопрос&Этот вопрос- не совсем понял эти решения)
В идеале я хотел бы решение, в котором я мог бы определять по-разному в тех beamercolorthememytheme.sty
же самых названиях цветов в зависимости от того, какой вариант был выбран. Например, если был выбран вариант синий, Beamer будет знать это, \definecolor{col1}{RGB}{104,7,90}
но если был выбран вариант зеленый, он будет знать это \definecolor{col1}{RGB}{81,139,36}
и т. д.
Надеюсь, этой информации достаточно, но если нет, дайте мне знать в комментариях.
Это то, что у меня есть в моемbeamercolorthememytheme.sty
\mode<presentation>
% define colours from NUIG stylesheet
\definecolor{col1}{RGB}{104,7,90}
\definecolor{col2}{RGB}{27,65,99}
\definecolor{col3}{RGB}{138,167,147}
\definecolor{col4}{RGB}{143,183,195}
\definecolor{col5}{RGB}{194,230,242}
% set colours for different elements
\setbeamercolor{structure}{fg=col3!100!col4}
\setbeamercolor{frametitle}{bg=col4,fg=col2}
\setbeamercolor*{title page header}{fg=col5}
\setbeamercolor*{subtitle}{fg=col5}
\setbeamercolor*{author}{fg=col5}
\setbeamercolor*{date}{fg=col5}
\setbeamercolor*{item}{fg=col5}
\setbeamercolor{block title}{bg=col1,fg=col5}
\mode
<all>
решение1
В следующем примере показано, как изменить цвет заголовка фрейма условно. blue
будет использоваться как цвет по умолчанию, если не указана никакая опция.
Рассмотрим следующий MWE:
\documentclass{beamer}
\usetheme[style=blue]{mytheme}
\begin{document}
\begin{frame}
\frametitle{test}
abc
\end{frame}
\end{document}
с соответствующим beamerthememytheme.sty
, который делает немного больше, чем просто передает параметр цвета в цветовую тему.
\mode<presentation>
\DeclareOptionBeamer{style}{
\PassOptionsToPackage{style=#1}{beamercolorthememytheme}
}
\ExecuteOptionsBeamer{style=blue}
\ProcessOptionsBeamer
\usecolortheme{mytheme}
\mode
<all>
и цветовая тема beamercolorthememytheme.sty
:
\mode<presentation>
\DeclareOptionBeamer{style}{\def\beamer@mytheme@style{#1}}
\ExecuteOptionsBeamer{style=blue} % blue will be default if nothing is given
\ProcessOptionsBeamer
\def\beamer@mytheme@stylegreen{green}%
\def\beamer@mytheme@styleblue{blue}%
\def\beamer@mytheme@stylered{red}%
\ifx\beamer@mytheme@style\beamer@mytheme@stylegreen%
\definecolor{col1}{RGB}{0,255,0} % green
\else%
\ifx\beamer@mytheme@style\beamer@mytheme@stylered%
\definecolor{col1}{RGB}{255,0,0} % red
\else%
\definecolor{col1}{RGB}{0,0,255} % blue
\fi%
\fi%
\setbeamercolor{frametitle}{bg=white,fg=col1}
\mode
<all>