Theses, Books, Title pagesTitle page of beamer presentation

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Post Reply
almudish
Posts: 4
Joined: Tue Jan 11, 2022 10:01 am

Title page of beamer presentation

Post by almudish »

Hi guys,

I have one query: How can I visualise code (with the package minted) in a title page definition (ie. within

Code: Select all

\defbeamertemplate*{title page}{ZurichLaTeXTheme}[1][]
) of a beamer presentation?

Here is the MVE:

Code: Select all

\documentclass{beamer}
\usepackage{tikz}
\usepackage[fixed]{fontawesome5}
\usepackage{listings}
\usepackage{minted}
\usemintedstyle{vbnet}

% Define colour properties
\definecolor{ZurichBlue}{RGB}{33,103,174}
\definecolor{Black}{RGB}{160,0,0}

% Set theme colour properties
% fg = foreground colour, bg = background colour
\setbeamercolor{palette primary}{fg=ZurichBlue,bg=white}
\setbeamercolor{palette secondary}{fg=ZurichBlue,bg=white}
\setbeamercolor{structure}{fg=ZurichBlue,bg=white}
\setbeamercolor{title in head/foot}{fg=black,bg=white}
\setbeamercolor{date in head/foot}{fg=gray,bg=white}

% Set footnote properties
% dp = depth
\defbeamertemplate*{footline}{ZurichLaTeXTheme}{%
  \leavevmode%
  \hbox{\begin{beamercolorbox}[wd=.6\paperwidth,ht=3.5ex,dp=3.5ex,leftskip=3.5ex,rightskip=3.5ex]{title in head/foot}%
    \makebox[3.5ex][l]{{\usebeamerfont{title in head/foot}\textcolor{ZurichBlue}{\insertframenumber}}}%
    {\usebeamercolor{title in head/foot}\insertshorttitle}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.375\paperwidth,ht=2.5ex,dp=3.5ex,leftskip=3.5ex,rightskip=3.5ex,right]{date in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate%
  \end{beamercolorbox}}%
  \vskip0pt%
}

% Set title page properties
\defbeamertemplate*{title page}{ZurichLaTeXTheme}[1][]
{%
  \begin{tikzpicture}[remember picture,overlay]
  \filldraw[ZurichBlue]
    (current page.north west) --
    ([yshift=-2cm]current page.north west) --
    ([xshift=-2cm,yshift=-2cm]current page.north east) {[rounded corners=15pt]--
    ([xshift=-2cm,yshift=3cm]current page.south east)} --
    ([yshift=3cm]current page.south west) --
    (current page.south west) --
    (current page.south east) --
    (current page.north east) -- cycle
    ;
  \node[text=ZurichBlue,anchor=south west,font=\sffamily\LARGE,text width=.55\paperwidth] 
  at ([xshift=15pt,yshift=-1cm]current page.west)
  (title)
  {\raggedright\inserttitle};   
  \node[text=white,font=\large\sffamily,anchor=south west]
  at ([xshift=15pt,yshift=0.5cm]current page.south west)
  (date)
  {\insertdate};
  \node[text=white,font=\large\sffamily,anchor=south west]
  at ([yshift=5pt]date.north west)
  (author)
  {\insertauthor};
  \end{tikzpicture}%
}

% remove navigation symbols
\setbeamertemplate{navigation symbols}{}

% definition of the symbols used in itemize
\newcommand\mysymbol{%
  \begin{tikzpicture}[xscale=0.85]
  \fill[ZurichBlue]
  (-1ex,1ex) to[out=-60,in=240,looseness=1.2]
  (1ex,1ex) to[out=240,in=120,looseness=1.2]
  (1ex,-1ex) to[out=120,in=60,looseness=1.2]
  (-1ex,-1ex) to[out=60,in=-60,looseness=1.2]
  cycle;  
  \end{tikzpicture}%
  }

% definition of the itemize templates
\defbeamertemplate*{itemize item}{mysymbol}{\small\raise0.5pt\hbox{\mysymbol}}
\defbeamertemplate*{itemize subitem}{mysymbol}{\footnotesize\raise0.5pt\hbox{\mysymbol}}
\defbeamertemplate*{itemize subsubitem}{mysymbol}{\footnotesize\raise0.5pt\hbox{\mysymbol}}

\title[MS VBA]{Microsoft Visual Basic for Applications (MS VBA)}
\author{Alexander Kallay}
\date{February 10, 2022}

\begin{document}

\begin{frame}[plain]
  \titlepage
\end{frame}

\begin{frame}
\frametitle{A test frame title}
\framesubtitle{A test frame subtitle}
\begin{itemize}
  \item This is some item.
  \item Another item.
  \begin{itemize}
    \item A subitem.
    \item Another subitem.
  \end{itemize}
  \item Yet another item.
\end{itemize}

\end{frame}

\end{document}
If anyone has an idea, you are invited to put it forward.

Cheers,
Alexander

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Title page of beamer presentation

Post by Ijon Tichy »

Unfortunately you've not shown (or I do not find/understand), where you want insert which code. And unfortunately I do not have the minted style vbnet, so I cannot show a complete example, how to do it. However, usually you cannot use environment minted inside the argument of another command. This is, because the environment has to change catcodes before the environment body is read, but the argument of a macro is already read, when the code is executed. The same problem is with \mint. Nevertheless, sometimes it works, depending on the code.

However, you can use, e.g. the lrbox environment to make a box containing the code, e.g.

Code: Select all

\newsavebox\titlecodebox
\begin{filecontents}{\jobname-titlecode.tex}
\begin{lrbox}{\titlecodebox}
\begin{minipage}[b]{5cm}
\begin{minted}{c}
int main() {
printf("hello, world");
return 0;
}
\end{minted}
\end{minipage}
\end{lrbox}
\end{filecontents}
\AtBeginDocument{\input{\jobname-titlecode.tex}}
should even work in the document preamble. After this, the box \titlecodebox can be set using \usebox\titlecodebox everywhere you want. Usage of a box has also the advantage, that minted has to be run only once, but you can use the result as often as you want.

As an alternative, usage of \inputminted does mostly work, where \minted, \mintinline or environment minted fail. \inputminted also has the advantage, that minted called only once. But the result has to be interpreted by LaTeX each time it is used. So using a box would be faster.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
almudish
Posts: 4
Joined: Tue Jan 11, 2022 10:01 am

Title page of beamer presentation

Post by almudish »

Ijon, cheers and thanks. Your code works perfectly. Now let me try and and make things more visually attractive. According to https://pygments.org/languages/ and the official minted package documentation, the style VBScript exists (somehow I thought yesterday I also saw vbnet). Anyway, I am sure you already know this.
almudish
Posts: 4
Joined: Tue Jan 11, 2022 10:01 am

Title page of beamer presentation

Post by almudish »

Ijon or someone else, seems really like what I have written is wrong. However, I have found out that I can "create a VBA style" as per:
class pygments.lexers.dotnet.VbNetLexer
Short names
vb.net, vbnet

Filenames
*.vb, *.bas

MIME types
text/x-vbnet, text/x-vba

For Visual Basic.NET source code.
Source: https://pygments.org/docs/lexers/

Anyone has experience?
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Title page of beamer presentation

Post by Ijon Tichy »

almudish wrote:Ijon or someone else, seems really like what I have written is wrong.
I never said that. I only said that I do not have vbnet style. I just do not have everything. I also said that in your example the attempt of a code call is missing and also little else is given about which code should be shown where per minted. I mentioned this as the reason why I could only show a solution instead of a complete example. If this is unwanted, I can leave it in the future.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
almudish
Posts: 4
Joined: Tue Jan 11, 2022 10:01 am

Title page of beamer presentation

Post by almudish »

No please, there is a misunderstanding. I really appreciate what you have written. I wrote "According to https://pygments.org/languages/ and the official minted package documentation, the style VBScript exists (somehow I thought yesterday I also saw vbnet).", which is a statement that I now consider to be false.

Anyway, here is some MS VBA code that I would like to see in the white part of the title page. MVE:

Code: Select all

\documentclass{beamer}
\usepackage{tikz}
\usepackage[fixed]{fontawesome5}
\usepackage{listings}
\usepackage{minted}
%\usemintedstyle{vbnet}

% Set code colour properties
\newsavebox\titlecodebox
\begin{filecontents}{\jobname-titlecode.tex}
\begin{lrbox}{\titlecodebox}
\begin{minipage}[b]{5cm}
\begin{minted}{c}

    Sub InspiredLearningSession ()
    
        Dim IfYouCanReadThis as Boolean
        IfYouCanReadThis = False
        
        Do While IfYouCanReadThis
        
            TBD
            
        Loop
    
    End Sub

\end{minted}
\end{minipage}
\end{lrbox}
\end{filecontents}
\AtBeginDocument{\input{\jobname-titlecode.tex}}

% Define colour properties
\definecolor{ZurichBlue}{RGB}{33,103,174}
\definecolor{Black}{RGB}{160,0,0}

% Set theme colour properties
% fg = foreground colour, bg = background colour
\setbeamercolor{palette primary}{fg=ZurichBlue,bg=white}
\setbeamercolor{palette secondary}{fg=ZurichBlue,bg=white}
\setbeamercolor{structure}{fg=ZurichBlue,bg=white}
\setbeamercolor{title in head/foot}{fg=black,bg=white}
\setbeamercolor{date in head/foot}{fg=gray,bg=white}

% Set footnote properties
% dp = depth
\defbeamertemplate*{footline}{ZurichLaTeXTheme}{%
  \leavevmode%
  \hbox{\begin{beamercolorbox}[wd=.6\paperwidth,ht=3.5ex,dp=3.5ex,leftskip=3.5ex,rightskip=3.5ex]{title in head/foot}%
    \makebox[3.5ex][l]{{\usebeamerfont{title in head/foot}\textcolor{ZurichBlue}{\insertframenumber}}}%
    {\usebeamercolor{title in head/foot}\insertshorttitle}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.375\paperwidth,ht=2.5ex,dp=3.5ex,leftskip=3.5ex,rightskip=3.5ex,right]{date in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate%
  \end{beamercolorbox}}%
  \vskip0pt%
}

% Set title page properties
\defbeamertemplate*{title page}{ZurichLaTeXTheme}[1][]
{%
  \begin{tikzpicture}[remember picture,overlay]
  \usebox\titlecodebox
  \filldraw[ZurichBlue]
    (current page.north west) --
    ([yshift=-2cm]current page.north west) --
    ([xshift=-2cm,yshift=-2cm]current page.north east) {[rounded corners=15pt]--
    ([xshift=-2cm,yshift=3cm]current page.south east)} --
    ([yshift=3cm]current page.south west) --
    (current page.south west) --
    (current page.south east) --
    (current page.north east) -- cycle
    ;
  \node[text=white,font=\large\sffamily,anchor=south west]
  at ([xshift=15pt,yshift=0.5cm]current page.south west)
  (date)
  {\insertdate};
  \node[text=white,font=\large\sffamily,anchor=south west]
  at ([yshift=5pt]date.north west)
  (author)
  {\insertauthor};
  \end{tikzpicture}%
}

% remove navigation symbols
\setbeamertemplate{navigation symbols}{}

% definition of the symbols used in itemize
\newcommand\mysymbol{%
  \begin{tikzpicture}[xscale=0.85]
  \fill[ZurichBlue]
  (-1ex,1ex) to[out=-60,in=240,looseness=1.2]
  (1ex,1ex) to[out=240,in=120,looseness=1.2]
  (1ex,-1ex) to[out=120,in=60,looseness=1.2]
  (-1ex,-1ex) to[out=60,in=-60,looseness=1.2]
  cycle;  
  \end{tikzpicture}%
  }

% definition of the itemize templates
\defbeamertemplate*{itemize item}{mysymbol}{\small\raise0.5pt\hbox{\mysymbol}}
\defbeamertemplate*{itemize subitem}{mysymbol}{\footnotesize\raise0.5pt\hbox{\mysymbol}}
\defbeamertemplate*{itemize subsubitem}{mysymbol}{\footnotesize\raise0.5pt\hbox{\mysymbol}}

\title[MS VBA]{Microsoft Visual Basic for Applications (MS VBA)}
\author{Alexander Kallay}
\date{February 10, 2022}

\begin{document}

\begin{frame}[plain]
  \titlepage
\end{frame}

\begin{frame}
\frametitle{A test frame title}
\framesubtitle{A test frame subtitle}
\begin{itemize}
  \item This is some item.
  \item Another item.
  \begin{itemize}
    \item A subitem.
    \item Another subitem.
  \end{itemize}
  \item Yet another item.
\end{itemize}

\end{frame}

\end{document}
Post Reply