Skip to content

Commit

Permalink
feat: reinstate support for block option
Browse files Browse the repository at this point in the history
Closes #6. Thanks @samcarter.
  • Loading branch information
jolars committed Mar 3, 2024
1 parent 54e0fce commit bf63dcd
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 16 deletions.
5 changes: 5 additions & 0 deletions doc/moloch.tex
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ \subsubsection{Outer theme}

\subsubsection{Color theme}

\DescribeOption{block}{transparent, fill}{transparent}{
Optionally adds a light grey background to block environments like |theorem|
and |example|.
}

\DescribeOption{background}{dark, light}{light}{
Provides the option to have a dark background and light foreground instead
of the reverse.
Expand Down
52 changes: 37 additions & 15 deletions examples/demo/demo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,43 @@ \section{Elements}
\end{tabular}
\end{table}
\end{frame}
\begin{frame}{Blocks}
Three different block environments are pre-defined.

\begin{block}{Default}
Block content.
\end{block}

\begin{alertblock}{Alert}
Block content.
\end{alertblock}

\begin{exampleblock}{Example}
Block content.
\end{exampleblock}

\begin{frame}[fragile]{Blocks}
Three different block environments are pre-defined: \verb|block|, \verb|alertblock|,
and \verb|exampleblock|. They can be styled using the option
\verb|block|, which takes values \verb|transparent| (default, left column) and \verb|fill| (right column).

\begin{columns}[T]
\begin{column}{0.45\textwidth}
\begin{block}{Default}
Block content.
\end{block}

\begin{alertblock}{Alert}
Block content.
\end{alertblock}

\begin{exampleblock}{Example}
Block content.
\end{exampleblock}
\end{column}
\begin{column}{0.45\textwidth}
{
\molochset{block=fill}

\begin{block}{Default}
Block content.
\end{block}

\begin{alertblock}{Alert}
Block content.
\end{alertblock}

\begin{exampleblock}{Example}
Block content.
\end{exampleblock}
}
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Math}
Expand Down
52 changes: 51 additions & 1 deletion src/beamercolorthememoloch.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
%
% \subsubsection{Options}
%
% \begin{macro}{block}
% Optionally adds a light grey background to block environments like
% |theorem| and |example|.
% \begin{macrocode}
\pgfkeys{
/moloch/color/block/.cd,
.is choice,
transparent/.code=\moloch@block@transparent,
fill/.code=\moloch@block@fill,
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{colors}
% Provides the option to have a dark background and light foreground instead
Expand Down Expand Up @@ -161,9 +173,37 @@
}
% \end{macrocode}
%
% Block environments use alerted tex and example text for the title
% Block environments such as |theorem| and |example| have no background color
% by default. The option |block=fill| sets a background color based on the
% background and foreground of |normal text|. The option |block=transparent|
% reverts the block environments to an empty background, which can be useful
% if changing colors mid-presentation.
%
% \begin{macrocode}
\newcommand{\moloch@block@transparent}{
\setbeamercolor{block title}{bg=}
\setbeamercolor{block body}{bg=}
\setbeamercolor{block title alerted}{bg=}
\setbeamercolor{block title example}{bg=}
}
\newcommand{\moloch@block@fill}{
\setbeamercolor{block title}{%
bg=normal text.bg!80!fg
}
\setbeamercolor{block body}{%
bg=block title.bg!50!normal text.bg
}
\setbeamercolor{block title alerted}{%
bg=block title.bg,
}
\setbeamercolor{block title example}{%
bg=block title.bg,
}
}
\setbeamercolor{block title}{%
use=normal text,
fg=normal text.fg
}
\setbeamercolor{block title alerted}{%
use={block title, alerted text},
fg=alerted text.fg
Expand All @@ -172,6 +212,8 @@
use={block title, example text},
fg=example text.fg
}
\setbeamercolor{block body alerted}{use=block body, parent=block body}
\setbeamercolor{block body example}{use=block body, parent=block body}
% \end{macrocode}
%
% Footnotes
Expand All @@ -181,6 +223,14 @@
\setbeamercolor{footnote mark}{fg=.}
% \end{macrocode}
%
%
% Footnotes
%
% \begin{macrocode}
\setbeamercolor{footnote}{fg=normal text.fg!90}
\setbeamercolor{footnote mark}{fg=.}
% \end{macrocode}
%
% We also reset the bibliography colors in order to pick up the surrounding
% colors at the time of use. This prevents us having to set the correct color in
% normal and standout mode.
Expand Down
37 changes: 37 additions & 0 deletions testfiles/support/molochexample.tex
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,43 @@ \subsection{Proof of the Main Theorem}
\end{itemize}
\end{frame}

\begin{frame}{Blocks}
\begin{columns}
\begin{column}{0.45\textwidth}
\begin{block}{Default}
Block content.
\end{block}

\begin{alertblock}{Alert}
Block content.
\end{alertblock}

\begin{exampleblock}{Example}
Block content.
\end{exampleblock}
\end{column}
\begin{column}{0.45\textwidth}
{
\molochset{block=fill}

\begin{block}{Default}
Block content.
\end{block}

\begin{alertblock}{Alert}
Block content.
\end{alertblock}

\begin{exampleblock}{Example}
Block content.
\end{exampleblock}
}
\end{column}
\end{columns}


\end{frame}

\appendix

\begin{frame}{Backup slides}
Expand Down

0 comments on commit bf63dcd

Please sign in to comment.