2

I am making a latex template for presentation slides using beamer class.

I want to allow people to enter their email address and employee_id in the main tex file, before the line of \begin{document}.

I know the following codes, but it shows \newcommand in the preamble. I think it is not a clean template.

\documentclass{beamer}
\title{Latex Template for Presentation Slides}
\date{7 February 2018}
\author{My Name}
\newcommand{\email}{my.name@email.com}
\newcommand{\employeeid}{ID: 123456}

\begin{document}

\begin{frame}
    \insertauthor
    \email
    \employeeid
\end{frame}

\end{document}

I want the following way. And the definition of \newcommand{\email}{} and \newcommand{\employeeid} should be added in beamerinnerthememytheme.sty file, and the users should only give their info in the main .tex file.

\documentclass{beamer}
\title{Latex Template for Presentation Slides}
\date{7 February 2018}
\author{My Name}
\email{my.name@email.com}
\employeeid{12345678}

\begin{document}

\begin{frame}
    \insertauthor
    \email
    \employeeid
\end{frame}

\end{document}

I have seen post Email field in beamer class?, but it is not what I want. I want:

  1. more than email address (e.g. employee id)
  2. email address, employee id can be shown in different location/slides than the author name.

Do you know how to define such commands \email and \employeeid?

Thanks!

aura
  • 139
  • 1
  • 7

2 Answers2

2

Define some wrapper macros that store the email and the employeeid to some place. If it is internal, use some @ in the macro names and place them without \makeatletter...\makeatother in the .sty file.

\newcommand{\email}[1]{\gdef\email@internal{#1}}

defines \email@internal to be the content of #1 -- this is the way how it is done with \@title and \@author in LaTeX's core.

I suggest to use \insertemail and \insertemployeeid as names similar to \insertauthor.

\documentclass{beamer}
\title{Latex Template for Presentation Slides}
\date{7 February 2018}
\author{My Name}

\makeatletter
%First empty definitions
\def\email@internal{}
\def\employeeid@internal{}
\newcommand{\email}[1]{\gdef\email@internal{#1}}
\newcommand{\employeeid}[1]{\gdef\employeeid@internal{#1}}
\newcommand{\insertemail}{\email@internal}
\newcommand{\insertemployeeid}{\employeeid@internal}
\makeatother 

\email{gandalf@mordor}
\employeeid{ID: 123456}

\begin{document}

\begin{frame}
    \insertauthor

    \insertemail

    \insertemployeeid
\end{frame}

\end{document}

enter image description here

2

The standard would be something like this:

\makeatletter
\newcommand{\email}[1]{\gdef\@email{#1}}
\makeatother

Then the macro \@email keeps the value one gives to \email

Skillmon
  • 60,462