add tag
JeT
**Context**

I generally use `\def` to define general variables I apply to my settings in beamer or in any other class. But https://topanswers.xyz/tex?q=1348 was an eye-opener. My method is not relevant. The use of pgfkeys is actually more elegant and flexible.

In the previous reference, @Marmot created a "course" family and enabled me to  concatenate contents.

**My question**

I need to create more of these keys to parameter my `beamer` version and my `beamerarticle` version and replace my ugly `\def`.

For instance I use 

`
\def\Theme{CambridgeUS}
\def\Colortheme{crane}
`

to load 

`
\usetheme{\Theme}	
\usecolortheme{\Colortheme}
`

I'd definitely prefer something like a `beamersettings` family where I can elegantly (and comprenhensively) define

`
theme = {CambridgeUS},
color theme = {crane}
`

or 

`booksettings` where again I can elegantly  define
`font={fourier}`
that would load

```
\usepackage{fourier} % math & rm
\usepackage[scaled=0.875]{helvet} % ss
\renewcommand{\ttdefault}{lmtt} %tt
```


or `font = {Latin Modern}`

that would load

`\usepackage{lmodern} % math, rm, ss, tt
\usepackage[T1]{fontenc}`

`TOCsettings`
`toc depth = {section}`, to load \setcounter{tocdepth}{1}   

etc.

I understand pgfkeys once I read them, it all makes sense. But I get stuck at the starting point.

**My target**

Get a file with all these pgfkeys at the beginning of my document to finetune the type of content I want to create.

Top Answer
marmot
I think it is a very good idea to use pgf keys for that. Basically you are asking to create your own theme such that the options get processed via pgf. The following is a prototype. It writes your theme file via `filecontents` but obviously you can just create a separate file. In particular, you won't need the preamble in every document, just copy the `beamerthemeJeT.sty` somewhere where LaTeX finds it. You can then say
```
\usetheme[options={theme={CambridgeUS},color theme=crane,font=fourier}]{JeT}
```
(One could presumably get rid of the `options=` at the expense of a hack.) This example illustrates the `/.code` key for the theme and color, and the `/.is choice` key for the  fonts. There are more keys for other purposes.  I also added (but commented) an example for the usage of styles as collection of keys,
```
\usetheme[options=standard]{JeT}
```
and
```
\usetheme[options={standard,font=Latin Modern}]{JeT}
```
which yield the same output (except for the font in the last example). You can add more keys to `beamerthemeJeT.sty` over the time, i.e. grow your theme over the time without losing backwards compatibility.

```
\documentclass{beamer}
% you will not need this in every document
% this is just to keep the example self-contained
% copy the file `beamerthemeJeT.sty` somewhere where LaTeX finds it
\begin{filecontents}[overwrite]{beamerthemeJeT.sty}
\DeclareOptionBeamer{options}{\pgfkeys{/JeT/beamer/.cd,#1}}
\pgfkeys{/JeT/.cd,beamer/.cd,
	theme/.code={\usetheme{#1}},
	color theme/.code={\usecolortheme{#1}},
	font/.is choice,
	font/fourier/.code={\usepackage{fourier}
		\usepackage[scaled=0.875]{helvet} 
		\renewcommand{\ttdefault}{lmtt}},
	font/Latin Modern/.code={\usepackage{lmodern}
	\usepackage[T1]{fontenc}},
	standard/.style={theme={CambridgeUS},color theme=crane,font=fourier}	 
	}
\ProcessOptionsBeamer
\end{filecontents}
% end of "one time only" preamble
% usage example
\usetheme[options={theme={CambridgeUS},color theme=crane,font=fourier}]{JeT}
% example using a style for a collection of keys
% \usetheme[options=standard]{JeT}
% or combine styles with single keys
% \usetheme[options={standard,font=Latin Modern}]{JeT}
\begin{document}
\begin{frame}[t]
\frametitle{Pft}
This is a test.
\end{frame}
\end{document}
```

![Screen Shot 2020-10-03 at 3.44.38 PM.png](/image?hash=8b09b613f316151a74c388cc9955b56832ec5dad96707528ed0819760e064c5d)

A non-hacky way to get rid of `options=` is to use `pgfopts`. A downside is that it does not allow spaces in the keys.
```
\documentclass{beamer}
% you will not need this in every document
% this is just to keep the example self-contained
% copy the file `beamerthemeJeT.sty` somewhere where LaTeX finds it
\begin{filecontents}[overwrite]{beamerpreambleJeT.sty}
\RequirePackage{pgfopts}
\pgfkeys{/JeT/.cd,beamer/.cd,
	theme/.code={\usetheme{#1}},
	colortheme/.code={\usecolortheme{#1}},
	font/.is choice,
	font/fourier/.code={\usepackage{fourier}
		\usepackage[scaled=0.875]{helvet} 
		\renewcommand{\ttdefault}{lmtt}},
	font/Latin-Modern/.code={\usepackage{lmodern}
	\usepackage[T1]{fontenc}},
	standard/.style={theme={CambridgeUS},colortheme=crane,font=fourier}	 
	}
\ProcessPgfOptions{/JeT/beamer}
\end{filecontents}
% end of "one time only" preamble
% usage example
% \usepackage[theme={CambridgeUS},colortheme=crane,font=fourier]{beamerpreambleJeT}
% example using a style for a collection of keys
\usepackage[standard]{beamerpreambleJeT}
% or combine styles with single keys
% \usepackage[standard,font=Latin-Modern]{beamerpreambleJeT}
\begin{document}
\begin{frame}[t]
\frametitle{Pft}
This is a test.
\end{frame}
\end{document}
```

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.