JeT
**Context**
After thousands of slides written, I am getting lazy.
I'd like to have a more minimal typing.
I keep repeating pretty much the same syntax with the basic reshuffle of `frame,text,block,list`(a presentation !).
![TAcapsule1.png](/image?hash=af3618d7aba2fda4e9e5783ed26a864673f36a7d1769d26cedbf897af19a88e9)
Probably a generational thing, but students react much better to content when I indicate an icon (no kidding) like below. `\fontawsome` are pretty nice since they automatically match the font of the text. Convenient when you change your theme. A feature I'd like to better integrate too.
![TAcapsule2.png](/image?hash=75f8686d70f883bb92b1a1f90bc20d15fbbdef11cb108fa02426aa9909f86442)
**What I've reached so far**
Quite naively I build `\capsule` to automate the job
`\capsule` is intented to simplifying the wording
```
\newcommand{\capsule}[5][itemize]{
\begin{#2}{#3}
#4 % <- Some text
\begin{#1} % <- It has to be a list here
#5
\end{#1}
\end{#2}
}
```
And it works well.
`\capsule` can wrap a `frame` directly, as above.
It also gives me flexibility to wrap more `\capsule`s in a `frame`.
![TAcapsule3.png](/image?hash=483965dfb660d4ae6781acc98cc0ac92a95f04a618413948186d3d9f927d4995)
I sometimes add explanations in my `block` and this `block` has (it becomes too long) to be turned to a `frame`.
On the countrary, I sometimes simplify the content of `frame` that ends up as a `block` in another `frame`.
I can easily upgrade text (to `frame`) or downgrade it (to `block`).
![TAcapsule4a.png](/image?hash=8e6c45557e0a0a3ab4ea6368900525e4ad5a0659b042394d04e41abb615dd5be)
![TAcapsule4b.png](/image?hash=a5b2cb2a82cda1123718d6585f1b9d32af4c0971877594ed7a26bc7847691fbf)
I can also simply toggle to `exampleblock`, `alertblock`, etc.
**Where I am stuck**
`\capsule` is based on a rigid rule that I would need to wrap
- first some text and
- then a list.
I'd like to have more flexibility. For instance, to have the list as first argument and text as second if I need to.
Keys, probably, and it could look like
```
\capsule[
block={alertblock}, % frame,block,exampleblock, theorem, etc
list={enumerate}, % itemize, enumeration, etc
title ={my title}, %
icon = {\faKey}, % in the fontawesome list
]
{ % the list could come first
\item alternative 1
\item alternative 2
}
{% the text could come after
\lipsum[1][1-2] }
```
**MWE**
```
\documentclass{beamer}
\usepackage{ragged2e}
\usepackage{transparent} %
\usepackage{fontawesome}
\usepackage{lipsum}
\usecolortheme{crane}
\newcommand{\capsule}[5][enumerate]{
\begin{#2}{#3}
#4 % I'd need some flexibility here
\begin{#1} %
#5 %
\end{#1} %
\end{#2}
}
%\faGears
%\faBomb
%\faLinkedinSquare
\begin{document}
%--------- Long version
\begin{frame}{\faKey{} Key concept}
\begin{block}{My block}
Explication sentence that could be longer.
\lipsum[1][1-2]
\begin{itemize}
\item my point
\item alternative 1
\item alternative 2
\item alternative 3
\end{itemize}
\end{block}
\end{frame}
%--------- shorter version with capsule
\begin{frame}{\faKey{} Key concept}
\capsule[itemize]{block}{My block}
{
Explication sentence that could be longer. \par \lipsum[1][1-2]
}
{
\item my point
\item alternative 1
\item alternative 2
\item alternative 3
}
\end{frame}
%--------- Two capsules in a frame
\begin{frame}{\faKey{} Key concept}
\capsule[enumerate]{block}{My block}
{
\lipsum[1][1-1]
\lipsum[1][1-2]}
{
\item my point
\item alternative 1
}
\capsule[itemize]{alertblock}{Important}
{\lipsum[1][1-2]}
{
\item my point
\item alternative 1
}
\end{frame}
% From block ...
\begin{frame}{My frame}
\capsule[itemize]{block}{\faKey{} Key concept}
{ \lipsum[1][1-2] }
{
\item my point
\item alternative 1
\item alternative 2
\item alternative 3
}
\end{frame}
% ... to frame
\capsule[itemize]{frame}{\faKey{} Key concept}
{\lipsum[1][1-2] }
{
\item my point
\item alternative 1
\item alternative 2
\item alternative 3
}
\capsule[enumerate]{frame}{\faGears{} Concept mecanics}
{\lipsum[1][1-3]}
{
\item my point
\item \lipsum[1][1]
\item \lipsum[1][2]
\item \lipsum[1][3]
}
\begin{frame}
\capsule[itemize]{exampleblock}{\faGears{} to illustrate}
{\lipsum[1][1-3]}
{
\item my point
\item \lipsum[1][1]
\item \lipsum[1][2]
\item \lipsum[1][3]
}
\end{frame}
\begin{frame}
\capsule[itemize]{alertblock}{\faKey{} Key concept}
{\lipsum[1][1-3]}
{
\item my point
\item \lipsum[1][1]
\item \lipsum[1][2]
\item \lipsum[1][3]
}
\end{frame}
\begin{frame}
\capsule[itemize]{alertblock}{\faBomb{} Be careful}
{\lipsum[1][1-1]}
{
\item my point
\item \lipsum[1][2]
}
\end{frame}
\end{document}
```
Top Answer
user 3.14159
This is a zeroth version of an answer. I did not have the patience of looking through all the examples and to detect what the qualitative changes are, but here is something that is hopefully a bit more flexible and reproduces the first explicit long version (except that I also added an icon). As you suggest, this uses some (pgf) keys. They can be used to detect whether there is really an icon, and only insert the space if there is, and so on.
```
\documentclass{beamer}
\usepackage{ragged2e}
\usepackage{transparent} %
\usepackage{fontawesome}
\usepackage{lipsum}
\usecolortheme{crane}
\newif\ifcapsulehastitle
\pgfkeys{/beamer/capsule/.cd,
block/.code={\pgfkeys{/beamer/capsule/block-env=#1}},block-env/.initial=block,
list/.code={\pgfkeys{/beamer/capsule/list-env=#1}},list-env/.initial=enumerate,
title/.code={\pgfkeys{/beamer/capsule/title-content/.code={#1}}},title=,
icon/.code={\ifx#1\relax
\capsulehastitlefalse
\else
\capsulehastitletrue
\pgfkeys{/beamer/capsule/icon-content/.code={#1}}%
\fi},icon=\relax,
}
\newcommand{\capsule}[3][]{%
\pgfkeys{/beamer/capsule/.cd,#1}
\begin{\pgfkeysvalueof{/beamer/capsule/block-env}}{\ifcapsulehastitle
\pgfkeys{/beamer/capsule/icon-content}\ \fi\pgfkeys{/beamer/capsule/title-content}}
#3 % I'd need some flexibility here
\begin{\pgfkeysvalueof{/beamer/capsule/list-env}} %
#2 %
\end{\pgfkeysvalueof{/beamer/capsule/list-env}} %
\end{\pgfkeysvalueof{/beamer/capsule/block-env}}
}
\begin{document}
%--------- Long version
\begin{frame}{\faKey{} Key concept}
\begin{block}{My block}
Explication sentence that could be longer.
\lipsum[1][1-2]
\begin{itemize}
\item my point
\item alternative 1
\item alternative 2
\item alternative 3
\end{itemize}
\end{block}
\end{frame}
%--------- shorter version with capsule
\begin{frame}{\faKey{} Key concept}
\capsule[
% block={alertblock}, % frame,block,exampleblock, theorem, etc
list={itemize}, % itemize, enumeration, etc
title ={My block}, %
icon ={\faKey}, % in the fontawesome list
]
{ % the list could come first
\item my point
\item alternative 1
\item alternative 2
\item alternative 3
}
{% the text could come after
\lipsum[1][1-2]}
\end{frame}
\end{document}
```