1
0
forked from upb/FancyBeamerUPB

Merge branch '2-replace-mycolumns-by-fancycolumns'

This commit is contained in:
Benno2000 2024-03-06 10:00:53 +01:00
commit 1011785d8f
2 changed files with 76 additions and 76 deletions

View File

@ -35,7 +35,7 @@
\subsection{Lists and Numbered Lists} \subsection{Lists and Numbered Lists}
\begin{frame}{\insertsubsection} \begin{frame}{\insertsubsection}
\begin{mycolumns} \begin{fancycolumns}
Lists can be nested to a depth of three: Lists can be nested to a depth of three:
\begin{itemize} \begin{itemize}
\item Item on the first level \item Item on the first level
@ -49,7 +49,7 @@
\end{itemize} \end{itemize}
\end{itemize} \end{itemize}
\end{itemize} \end{itemize}
\mynextcolumn \nextcolumn
Numbered lists can be nested to a depth of three: Numbered lists can be nested to a depth of three:
\begin{enumerate} \begin{enumerate}
\item Item on the first level \item Item on the first level
@ -63,64 +63,64 @@
\end{enumerate} \end{enumerate}
\end{enumerate} \end{enumerate}
\end{enumerate} \end{enumerate}
\end{mycolumns} \end{fancycolumns}
\end{frame} \end{frame}
\subsection{Colored Boxes} \subsection{Colored Boxes}
\begin{frame}{\insertsubsection} \begin{frame}{\insertsubsection}
Normal versions: Normal versions:
\begin{mycolumns}[columns=3] \begin{fancycolumns}[columns=3]
\begin{definition}{A {\color{orange} Definition}} \begin{definition}{A Definition}
This is a definition. This is a definition.
\end{definition} \end{definition}
\mynextcolumn \nextcolumn
\begin{example}{An {\color{blue} Example}} \begin{example}{An {\color{blue} Example}}
This is an example. This is an example.
\end{example} \end{example}
\mynextcolumn \nextcolumn
\begin{note}{A {\color{red} Note}} \begin{note}{A {\color{red} Note}}
This is a note. This is a note.
\end{note} \end{note}
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
Versions without captions: Versions without captions:
\begin{mycolumns}[columns=3] \begin{fancycolumns}[columns=3]
\begin{definition}{} \begin{definition}{}
This is a {\color{orange} definition}. This is a {\color{orange} definition}.
\end{definition} \end{definition}
\mynextcolumn \nextcolumn
\begin{example}{} \begin{example}{}
This is an {\color{blue} example}. This is an {\color{blue} example}.
\end{example} \end{example}
\mynextcolumn \nextcolumn
\begin{note}{} \begin{note}{}
This is a {\color{red} note}. This is a {\color{red} note}.
\end{note} \end{note}
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
Tight versions with {\color{green} white background} (e.g., for use with pictures): Tight versions with white background (e.g., for use with pictures):
\begin{mycolumns}[columns=3] \begin{fancycolumns}[columns=3]
\begin{definitiontight}{A Definition} \begin{definitiontight}{A Definition}
\centering\includegraphics[width=.75\linewidth]{example-image} \centering\includegraphics[width=.75\linewidth]{example-image}
\end{definitiontight} \end{definitiontight}
\mynextcolumn \nextcolumn
\begin{exampletight}{An Example} \begin{exampletight}{An Example}
\centering\includegraphics[width=.75\linewidth]{example-image} \centering\includegraphics[width=.75\linewidth]{example-image}
\end{exampletight} \end{exampletight}
\mynextcolumn \nextcolumn
\begin{notetight}{A Note} \begin{notetight}{A Note}
\centering\includegraphics[width=.75\linewidth]{example-image} \centering\includegraphics[width=.75\linewidth]{example-image}
\end{notetight} \end{notetight}
\end{mycolumns} \end{fancycolumns}
\end{frame} \end{frame}
{\MakeNewBox{amazing}{purple} {\MakeNewBox{amazing}{purple}
\begin{frame}{Create New and Modify Existing Boxes} \begin{frame}{Create New and Modify Existing Boxes}
\begin{mycolumns} \begin{fancycolumns}
\begin{amazing}{An Amazing Box} \begin{amazing}{An Amazing Box}
You can create new boxes with \texttt{\textbackslash MakeNewBox\{name\}\{color\}} (which will check if any of the new box commands is already taken) or \texttt{\textbackslash DeclareBox\{name\}\{color\}} (which may overwrite existing commands). This box was created by \texttt{\textbackslash MakeNewBox\{amazing\}\{purple\}}. You can create new boxes with \texttt{\textbackslash MakeNewBox\{name\}\{color\}} (which will check if any of the new box commands is already taken) or \texttt{\textbackslash DeclareBox\{name\}\{color\}} (which may overwrite existing commands). This box was created by \texttt{\textbackslash MakeNewBox\{amazing\}\{purple\}}.
\end{amazing} \end{amazing}
\mynextcolumn \nextcolumn
{\UpdateBoxColor{definition}{teal} {\UpdateBoxColor{definition}{teal}
\begin{definition}{This is a Definition} \begin{definition}{This is a Definition}
With \texttt{\textbackslash UpdateBoxColor\{name\}\{color\}} you can change the color of a box (locally to the current group). This definition was changed with \texttt{\textbackslash UpdateBoxColor\{definition\}\{teal\}}. With \texttt{\textbackslash UpdateBoxColor\{name\}\{color\}} you can change the color of a box (locally to the current group). This definition was changed with \texttt{\textbackslash UpdateBoxColor\{definition\}\{teal\}}.
@ -129,7 +129,7 @@
\begin{definition}{Another Definition} \begin{definition}{Another Definition}
This definition appears outside of the group, so \texttt{\textbackslash UpdateBoxColor\{definition\}\{teal\}} is no longer active. This definition appears outside of the group, so \texttt{\textbackslash UpdateBoxColor\{definition\}\{teal\}} is no longer active.
\end{definition} \end{definition}
\end{mycolumns} \end{fancycolumns}
\end{frame} \end{frame}
} }
@ -158,17 +158,17 @@
\subsection{Automatic Dark-Mode for Pictures} \subsection{Automatic Dark-Mode for Pictures}
\begin{frame}{\insertsubsection} \begin{frame}{\insertsubsection}
\begin{mycolumns} \begin{fancycolumns}
\begin{notetight}{Normal Image with \texttt{\textbackslash pic}} \begin{notetight}{Normal Image with \texttt{\textbackslash pic}}
\centering \centering
\pic[width=.7\textwidth]{example-image} \pic[width=.7\textwidth]{example-image}
\end{notetight} \end{notetight}
\mynextcolumn \nextcolumn
\begin{notetight}{Inverted Image with \texttt{\textbackslash picDark} (in dark-mode only)} \begin{notetight}{Inverted Image with \texttt{\textbackslash picDark} (in dark-mode only)}
\centering \centering
\picDark[width=.7\textwidth]{example-image.jpg} % does only work for bitmap images so far \picDark[width=.7\textwidth]{example-image.jpg} % does only work for bitmap images so far
\end{notetight} \end{notetight}
\end{mycolumns} \end{fancycolumns}
\begin{note}{Explanation} \begin{note}{Explanation}
Using \texttt{\textbackslash picDark} instead of \texttt{\textbackslash pic}, the dark version of an image that is saved as \texttt{<image-name>-dark} automatically gets used when dark-mode is enabled. Using \texttt{\textbackslash picDark} instead of \texttt{\textbackslash pic}, the dark version of an image that is saved as \texttt{<image-name>-dark} automatically gets used when dark-mode is enabled.
@ -180,18 +180,18 @@
\subsection{Multiple Columns} \subsection{Multiple Columns}
\begin{frame}{\insertsubsection} \begin{frame}{\insertsubsection}
\begin{mycolumns}[columns=4] % default: 2 columns \begin{fancycolumns}[columns=4] % default: 2 columns
This is an example text that is shown in the \textbf{first column}. This is an example text that is shown in the \textbf{first column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{second column}. This is an example text that is shown in the \textbf{second column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{third column}. This is an example text that is shown in the \textbf{third column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{last column}. This is an example text that is shown in the \textbf{last column}.
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
\begin{note}{Explanation} \begin{note}{Explanation}
Columns are separated by the command \texttt{\textbackslash mynextcolumn}. Columns are separated by the command \texttt{\textbackslash nextcolumn}.
The option \texttt{columns} specifies the number of columns that should be generated. The default number of columns is two. The option \texttt{columns} specifies the number of columns that should be generated. The default number of columns is two.
\end{note} \end{note}
@ -199,19 +199,19 @@
\subsection{Columns with Custom Width} \subsection{Columns with Custom Width}
\begin{frame}{\insertsubsection} \begin{frame}{\insertsubsection}
\begin{mycolumns}[columns=3,widths={20,30}] \begin{fancycolumns}[columns=3,widths={20,30}]
\begin{example}{} \begin{example}{}
The \textbf{first column} takes 20\,\% of the width of the slide. The \textbf{first column} takes 20\,\% of the width of the slide.
\end{example} \end{example}
\mynextcolumn \nextcolumn
\begin{example}{} \begin{example}{}
The \textbf{second column} takes 30\,\% of the width of the slide. The \textbf{second column} takes 30\,\% of the width of the slide.
\end{example} \end{example}
\mynextcolumn \nextcolumn
\begin{example}{} \begin{example}{}
The \textbf{third column} takes the remaining 50\,\% of the width of the slide. The \textbf{third column} takes the remaining 50\,\% of the width of the slide.
\end{example} \end{example}
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
\begin{note}{Explanation} \begin{note}{Explanation}
The widths of the single columns can also be manually specified by a list of percentages given to the option \texttt{widths}. The widths of the single columns can also be manually specified by a list of percentages given to the option \texttt{widths}.
@ -222,64 +222,64 @@
\subsection{Columns with Custom Height} \subsection{Columns with Custom Height}
\begin{frame}{\insertsubsection} \begin{frame}{\insertsubsection}
\begin{mycolumns}[height=6cm] \begin{fancycolumns}[height=6cm]
\begin{example}{} \begin{example}{}
This is the content of the first column. This is the content of the first column.
\end{example} \end{example}
\begin{note}{Explanation} \begin{note}{Explanation}
If the content of a column exceeds a certain height, the common centering of all columns will not work anymore because beamer does not define the height of a slide. In this case, you can set the height of the columns manually by adding the option \texttt{height=<height>}. If the content of a column exceeds a certain height, the common centering of all columns will not work anymore because beamer does not define the height of a slide. In this case, you can set the height of the columns manually by adding the option \texttt{height=<height>}.
\end{note} \end{note}
\mynextcolumn \nextcolumn
\begin{example}{} \begin{example}{}
This is the content of the second column. It is too high and would make the first column move downwards without additional options. This is the content of the second column. It is too high and would make the first column move downwards without additional options.
\vspace{80mm} \vspace{80mm}
\end{example} \end{example}
\end{mycolumns} \end{fancycolumns}
\end{frame} \end{frame}
\subsection{Nested Columns} \subsection{Nested Columns}
\begin{frame}{\insertsubsection} \begin{frame}{\insertsubsection}
\begin{mycolumns}[T] \begin{fancycolumns}[T]
\begin{example}{} \begin{example}{}
This is the content of the first column. This is the content of the first column.
\end{example} \end{example}
\begin{mycolumns}[columns=4] \begin{fancycolumns}[columns=4]
\mynote{}{1.1} \mynote{}{1.1}
\mynextcolumn \nextcolumn
\mynote{}{1.2} \mynote{}{1.2}
\mynextcolumn \nextcolumn
\mynote{}{1.3} \mynote{}{1.3}
\mynextcolumn \nextcolumn
\mynote{}{1.4} \mynote{}{1.4}
\end{mycolumns} \end{fancycolumns}
\mynextcolumn \nextcolumn
\begin{example}{} \begin{example}{}
A column on the right side A column on the right side
\end{example} \end{example}
\begin{mycolumns}[T] \begin{fancycolumns}[T]
\mynote{}{2.1} \mynote{}{2.1}
\begin{mycolumns}[columns=3] \begin{fancycolumns}[columns=3]
\mynote{}{2.1.1} \mynote{}{2.1.1}
\mynextcolumn \nextcolumn
\mynote{}{2.1.2} \mynote{}{2.1.2}
\mynextcolumn \nextcolumn
\mynote{}{2.1.3} \mynote{}{2.1.3}
\end{mycolumns} \end{fancycolumns}
\mynextcolumn \nextcolumn
\mynote{}{2.2} \mynote{}{2.2}
\end{mycolumns} \end{fancycolumns}
\end{mycolumns} \end{fancycolumns}
\end{frame} \end{frame}
\subsection{Column Animations} \subsection{Column Animations}
\begin{frame}{\insertsubsection\ -- Option keep} \begin{frame}{\insertsubsection\ -- Option keep}
\begin{mycolumns}[columns=3,keep] % short for animation=keep \begin{fancycolumns}[columns=3,keep] % short for animation=keep
This is an example text that is shown in the \textbf{first column}. This is an example text that is shown in the \textbf{first column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{second column}. This is an example text that is shown in the \textbf{second column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{third column}. This is an example text that is shown in the \textbf{third column}.
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
\begin{note}{Explanation} \begin{note}{Explanation}
The option \texttt{keep} (short for \texttt{animation=keep}) introduces an animation which lets the columns appear one after another. The option \texttt{keep} (short for \texttt{animation=keep}) introduces an animation which lets the columns appear one after another.
@ -291,13 +291,13 @@
\end{frame} \end{frame}
\begin{frame}{\insertsubsection\ -- Option forget} \begin{frame}{\insertsubsection\ -- Option forget}
\begin{mycolumns}[columns=3,forget] % short for animation=forget \begin{fancycolumns}[columns=3,forget] % short for animation=forget
This is an example text that is shown in the \textbf{first column}. This is an example text that is shown in the \textbf{first column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{second column}. This is an example text that is shown in the \textbf{second column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{third column}. This is an example text that is shown in the \textbf{third column}.
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
\begin{note}{Explanation} \begin{note}{Explanation}
The option \texttt{forget} (short for \texttt{animation=forget}) introduces an animation which lets the columns appear one after another. The option \texttt{forget} (short for \texttt{animation=forget}) introduces an animation which lets the columns appear one after another.
@ -309,29 +309,29 @@
\end{frame} \end{frame}
\begin{frame}{\insertsubsection\ -- Option animation=none} \begin{frame}{\insertsubsection\ -- Option animation=none}
\begin{mycolumns}[columns=3,animation=none] \begin{fancycolumns}[columns=3,animation=none]
This is an example text that is shown in the \textbf{first column}. This is an example text that is shown in the \textbf{first column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{second column}. This is an example text that is shown in the \textbf{second column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{third column}. This is an example text that is shown in the \textbf{third column}.
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
\begin{note}{Explanation} \begin{note}{Explanation}
The option \texttt{animation=none} deactivates the animation of the columns. The option \texttt{animation=none} deactivates the animation of the columns.
In the template, this is the default. However, you can overwrite the defaults to animate all slides easily (see \texttt{setmycolumnsdefault} in the source code). Then, it might be necessary to deactivate those animations for some slides. In the template, this is the default. However, you can overwrite the defaults to animate all slides easily (see \texttt{setfancycolumnsdefault} in the source code). Then, it might be necessary to deactivate those animations for some slides.
\end{note} \end{note}
\end{frame} \end{frame}
\begin{frame}[label=current]{\insertsubsection\ -- Option reverse} \begin{frame}[label=current]{\insertsubsection\ -- Option reverse}
\begin{mycolumns}[columns=3,forget,reverse] \begin{fancycolumns}[columns=3,forget,reverse]
This is an example text that is shown in the \textbf{first column}. This is an example text that is shown in the \textbf{first column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{second column}. This is an example text that is shown in the \textbf{second column}.
\mynextcolumn \nextcolumn
This is an example text that is shown in the \textbf{third column}. This is an example text that is shown in the \textbf{third column}.
\end{mycolumns} \end{fancycolumns}
\vfill \vfill
\begin{note}{Explanation} \begin{note}{Explanation}
The option \texttt{reverse} inverts the order of any animation that is specified (i.e., using \texttt{keep} or \texttt{forget}). The option \texttt{reverse} inverts the order of any animation that is specified (i.e., using \texttt{keep} or \texttt{forget}).

View File

@ -373,7 +373,7 @@
\newdimen\fancy@cols@height % holds the target height of the columns environment (negative for auto) \newdimen\fancy@cols@height % holds the target height of the columns environment (negative for auto)
\def\fancy@cols@widths@max{100} % the maximum number to be used for widths \def\fancy@cols@widths@max{100} % the maximum number to be used for widths
% with this, we define the keys that are usable within the optional argument of '\mycolumns' % with this, we define the keys that are usable within the optional argument of '\fancycolumns'
\def\@fancy@animation@none{\fancy@cols@animation{0}{-}} \def\@fancy@animation@none{\fancy@cols@animation{0}{-}}
\def\@fancy@animation@keep{\fancy@cols@animation{1}{-}} \def\@fancy@animation@keep{\fancy@cols@animation{1}{-}}
@ -430,7 +430,7 @@
} }
% allows to user to overwrite the defaults % allows to user to overwrite the defaults
\newcommand\setmycolumnsdefault[1]{\pgfqkeys{/fancy columns}{@defaults/.append style={#1}}} \newcommand\setfancycolumnsdefault[1]{\pgfqkeys{/fancy columns}{@defaults/.append style={#1}}}
% we need two counters % we need two counters
% 'fancy@cols@current' holds the column we are currently in (starts with 0) % 'fancy@cols@current' holds the column we are currently in (starts with 0)
@ -452,13 +452,13 @@
% due to the way beamer calculates the columns, we remove the margin from the width % due to the way beamer calculates the columns, we remove the margin from the width
% see etoolbox for an explanation of '\dimdef' (basically allows for calculations with dimensions) % see etoolbox for an explanation of '\dimdef' (basically allows for calculations with dimensions)
\dimdef{\fancy@cols@total@width}{\linewidth-\fancy@cols@margin*\fancy@cols@count+\fancy@cols@margin}% \dimdef{\fancy@cols@total@width}{\linewidth-\fancy@cols@margin*\fancy@cols@count+\fancy@cols@margin}%
% activate(/overwrite) the '\mynextcolumn' macro within the environment % activate(/overwrite) the '\nextcolumn' macro within the environment
\let\mynextcolumn\fancy@mynextcolumn \let\nextcolumn\fancy@nextcolumn
% a rather complicated macro, which sets/calculates the widths for all columns % a rather complicated macro, which sets/calculates the widths for all columns
\fancy@cols@initialize@widths \fancy@cols@initialize@widths
% issue the first column % issue the first column
% NOTE: we don't guard if 'columns' is below 1 (e.g. we always assume, there is 1 column) % NOTE: we don't guard if 'columns' is below 1 (e.g. we always assume, there is 1 column)
\mynextcolumn \nextcolumn
} }
% a temporary counter so we do not need to use low-level tex counters (like @tempcnta) % a temporary counter so we do not need to use low-level tex counters (like @tempcnta)
@ -544,8 +544,8 @@
\fi \fi
} }
% this is the macro, that will become '\mynextcolumn' within the 'mycolumns' environment % this is the macro, that will become '\nextcolumn' within the 'fancycolumns' environment
\newcommand\fancy@mynextcolumn{% \newcommand\fancy@nextcolumn{%
% issue a warning if too many columns % issue a warning if too many columns
\ifnum\value{fancy@cols@current}<\fancy@cols@count\else \ifnum\value{fancy@cols@current}<\fancy@cols@count\else
% this mus be an error, we calculate widths etc. only for the given columns % this mus be an error, we calculate widths etc. only for the given columns
@ -581,7 +581,7 @@
} }
% #1: arguments like 'columns=3, keep, reverse' % #1: arguments like 'columns=3, keep, reverse'
\newenvironment{mycolumns}[1][]{\begingroup \newenvironment{fancycolumns}[1][]{\begingroup
\pgfqkeys{/fancy columns}{@defaults, #1}% \pgfqkeys{/fancy columns}{@defaults, #1}%
\edef\fancy@previous@fancy@cols{\thefancy@cols@current}% store the current column counter \edef\fancy@previous@fancy@cols{\thefancy@cols@current}% store the current column counter
\ifdim\fancy@cols@height<0pt\begin{minipage}{\fancy@cols@target@width}\else\begin{minipage}[\fancy@cols@valign][\fancy@cols@height]{\fancy@cols@target@width}\fi% \ifdim\fancy@cols@height<0pt\begin{minipage}{\fancy@cols@target@width}\else\begin{minipage}[\fancy@cols@valign][\fancy@cols@height]{\fancy@cols@target@width}\fi%