add tag
JeT
**My question**

Use pgfkeys to map a `logo` and `tcolorbox` format.

([this answer's](https://topanswers.xyz/tex?q=1638) little cousin I believe)


**Context**

I got bored with the basic block/alertblock.  They're too generic and I needed to connect more the content and the meaning.

For that, I tried the `tcolorboxes` with (`fontawesome`) logo.


![image.png](/image?hash=519bd57ea872c8c750484915a990f9c132f866e9361429f304f03cf3d38f67c4)

Casual `\begin{alertblock}` above and  `\begin{important}` below, as defined in :

```
\newtcolorbox{important}[1][]{
			enhanced,
			arc=5mm,
			drop lifted shadow=blue!50,
			colback=orange!20,
			colframe=red!20,
			detach title,
			overlay unbroken and first ={
				\node[red,anchor=north east,scale=1.4] 
                at (frame.north west) {\faExclamationTriangle};
			}        
		}

```

The logo on the side has the obvious advantage to take less space than a standard beamerbox with just a logo (and so much empty space), and also explains more visually the reason of the alert. 

![image.png](/image?hash=e901999df745cd95f0960476cf1028b21d4f055c7a5873b86152b8dee4d3a413)

My students reacted very positively to presentations with more flags.


**More flags for more context**

`alertblock` is too generic. The "alert" could be more meaningful.
- It can mean "be careful" 
![image.png](/image?hash=9f14b5e6a8df20940698cf75a722b7ee3ef3d63ead6a0a1ae9815b48e32b87ef)

- it's an important date
![image.png](/image?hash=70a61342ee2b1711f792bd562d08c7c674a10161879f613a40f06dbc4bd5f548)

- as much as "tip for a fomula" 
![image.png](/image?hash=2b1f61f65637e2a3c5c3e1230f1fe6821d2f2f88ad03930d7c77f9bfb4d8aabc)

- as much as "important idea"
![image.png](/image?hash=8d3ae3b638dea6ad45c5b3b0832f53df9f1c3ad9082eb235f395bc589e5d005c)

- or important formula 
![image.png](/image?hash=029b6e3d9a5e9900445789c655a46b1bc2d821e8aef9987325f7de83edbb4e9c)
...

**My question more precisely**

I'd like the logo to inherit the color of the environment based on a key that I intend to make grow over time.


List of keys I have in mind with their corresponding fontawesome logo
	theme			key			mapping logo
	question 		[question] 	\faQuestionCircle
	internet link 	[net]		\faLink
	idea 			[idea]		\faLightbulbO
	formula 		[formula]	\faFlask
	...

I tested the ideas on 2 environments

- `important` is the new `alertblock`
- `information` is a more... informational than alert

information is a an almost copy cat of important but in blue (no innovation here...)

![image.png](/image?hash=7658aca2f55e0be041989b3f68c0bbb5a5c3c98aaec70441dbf0e04277055ff3)

```
		\newtcolorbox{information}[1][]{
			enhanced,
			arc=5mm,
			drop lifted shadow=myuniversity!50,
			colback=blue!5,
			colframe=blue!15,
			leftrule=0mm,%
			detach title,
			overlay unbroken and first ={
			\node[myuniversity,anchor=north east,scale=1.3] 
			at (frame.north west) {\faInfoCircle};% 
			}        
		}
```
**Example of cross between `env` and `logo key`**

`\begin{information}[question]`	%\faQuestionCircle
`\begin{important}[question]`	%\faQuestionCircle
`\begin{information}[net]`		%\faLink
`\begin{information}[idea]`		%\faLightbulbO
`\begin{important}[idea]`		%\faLightbulbO
`\begin{important}[formula]` 	%\faFlask
`\begin{information}[job]`	 	%\faLinkedinSquare




NB : The discussions today about colorblinbness made me think of my own beamer presentations. A little logo could help.


MWE
```
\documentclass{beamer}

\usepackage{tikz,tcolorbox}
\usetikzlibrary{shapes,calc}
\usepackage{fontawesome}
\tcbuselibrary{skins}
\usecolortheme{crane}

  \newtcolorbox{information}[1][]{
  	enhanced,
  	arc=5mm,
  	drop lifted shadow=blue!50,
  	colback=blue!5,
  	colframe=white,
  	leftrule=0mm,%
  	detach title,
  	overlay unbroken and first ={
  	\node[blue,anchor=north east,scale=1.3] 
  	at (frame.north west) {\faInfoCircle};
  	}        
  }
  
  \newtcolorbox{important}[1][]{
  	enhanced,
  	arc=5mm,
  	drop lifted shadow=red!50,
  	colback=red!5,
  	colframe=white,
  	leftrule=0mm,%
  	detach title,
  	overlay unbroken and first ={
  	\node[red,anchor=north east,scale=1.3] 
  	at (frame.north west) {\faInfoCircle};
  	}        
  }


\begin{document}

\begin{frame}
	\begin{alertblock}{\faInfoCircle}
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
	\end{alertblock}  


	\begin{important}%[information]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
	\end{important}  
\end{frame}

% you'll notice the tcolorbox is a bit shorter, i'd like to have it as wide as the alertblock

\begin{frame}
	\begin{information}%[formula]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
	\end{information}
\end{frame}


\end{document}
```

Top Answer
marmot
If this is merely to change some colors, this might be a bit excessive, but you can define very different boxes, and then this solution may be appropriate. First we define some choices with the `/.is choice` handler.
```
\pgfkeys{/JeT/fa/.is choice,
/JeT/fa/faquestion/.code=\pgfkeys{/JeT/fa-code/.code={\faQuestionCircle}},
/JeT/fa/fainformation/.code=\pgfkeys{/JeT/fa-code/.code={\faInfoCircle}},
/JeT/fa/fanet/.code=\pgfkeys{/JeT/fa-code/.code={\faLink}},
/JeT/fa/faidea/.code=\pgfkeys{/JeT/fa-code/.code={\faLightbulbO}},
/JeT/fa/faformula/.code=\pgfkeys{/JeT/fa-code/.code={\faFlask}},
/JeT/fa/.unknown/.code={},
/JeT/fa/faquestion
}
```
The last line sets some initial value, and the next-to-last line makes the story a bit immune to typos, i.e. unknown option will just be ignored. The reason why the symbols are stored in codes is that this way you can also add combinations of symbols etc. It should be clear how one can add more symbols to this "dictionary". 

We forward the option from the `tcolorbox` to the choice handler. The `/.try` key handler is used so that you can implement other keys in parallel, and the box is able to "guess" what it is meant for. Or e.g. `net` can trigger more than one action in a given box. (I am not 100% sure if this is a good idea, this is also to show that it is possible, similarly to what happens when you give `\draw[red] ...` in Ti*k*Z, Ti*k*Z is able to "guess" that red is a color.)
```
\documentclass{beamer}

\usepackage{tikz,tcolorbox}
\usetikzlibrary{shapes,calc}
\usepackage{fontawesome}
\tcbuselibrary{skins}
\usecolortheme{crane}
\pgfkeys{/JeT/fa/.is choice,
/JeT/fa/faquestion/.code=\pgfkeys{/JeT/fa-code/.code={\faQuestionCircle}},
/JeT/fa/fainformation/.code=\pgfkeys{/JeT/fa-code/.code={\faInfoCircle}},
/JeT/fa/fanet/.code=\pgfkeys{/JeT/fa-code/.code={\faLink}},
/JeT/fa/faidea/.code=\pgfkeys{/JeT/fa-code/.code={\faLightbulbO}},
/JeT/fa/faformula/.code=\pgfkeys{/JeT/fa-code/.code={\faFlask}},
/JeT/fa/.unknown/.code={},
/JeT/fa/faquestion
}

  \newtcolorbox{information}[1][]{%
  	enhanced,
  	arc=5mm,
  	drop lifted shadow=blue!50,
  	colback=blue!5,
  	colframe=white,
  	leftrule=0mm,%
  	detach title,
	/JeT/fa/fa#1/.try,
  	overlay unbroken and first ={
  	\node[blue,anchor=north east,scale=1.3] 
  	at (frame.north west) {\pgfkeys{/JeT/fa-code}};
  	}        
  }
  
  \newtcolorbox{important}[1][]{%
  	enhanced,
  	arc=5mm,
  	drop lifted shadow=red!50,
  	colback=red!5,
  	colframe=white,
  	leftrule=0mm,%
  	detach title,
	/JeT/fa/fa#1/.try,
  	overlay unbroken and first ={
  	\node[red,anchor=north east,scale=1.3] 
  	at (frame.north west) {\pgfkeys{/JeT/fa-code}};
  	}        
  }


\begin{document}

\begin{frame}
\begin{important}%[information]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
\end{important}  
\medskip
\begin{important}[information]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
\end{important}  
\end{frame}

\begin{frame}
\begin{information}%[formula]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
\end{information}
\medskip
\begin{information}[formula]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
\end{information}

\end{frame}
\end{document}
```
![ani.gif](/image?hash=68f46a4ccd769509793c569d963657cdc4e7a24d53646e2fb6c03d1843688b7d)
Answer #2
samcarter
You could test for the optional argument and select the icon accordingly. As beamer anyway loads the `etoolbox` package, you can use `\ifstrequal` for this test:

```
\documentclass{beamer}

\usepackage{tikz,tcolorbox}
\usetikzlibrary{shapes,calc}
\usepackage{fontawesome}
\tcbuselibrary{skins}
\usecolortheme{crane}

\newcommand{\inserticon}[1]{%
  \ifstrequal{#1}{formula}{\faFlask}{}%
  \ifstrequal{#1}{net}{\faLink}{}%
  \ifstrequal{#1}{question}{\faQuestionCircle}{}%
  \ifstrequal{#1}{idea}{\faLightbulbO}{}%
  \ifstrequal{#1}{information}{\faInfoCircle}{}%    
}

  \newtcolorbox{information}[1][information]{
  	enhanced,
  	arc=5mm,
  	drop lifted shadow=blue!50,
  	colback=blue!5,
  	colframe=white,
  	leftrule=0mm,%
  	detach title,
  	overlay unbroken and first ={
  	\node[blue,anchor=north east,scale=1.3] 
  	at (frame.north west) {\inserticon{#1}};
  	}        
  }
 
  \newtcolorbox{important}[1][information]{
  	enhanced,
  	arc=5mm,
  	drop lifted shadow=red!50,
  	colback=red!5,
  	colframe=white,
  	leftrule=0mm,%
  	detach title,
  	overlay unbroken and first ={
  	\node[red,anchor=north east,scale=1.3] 
  	at (frame.north west) {\inserticon{#1}};
  	}        
  }

\begin{document}

\begin{frame}

	\begin{important}[information]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
	\end{important}  

	\begin{information}[formula]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
	\end{information}
  
 	\begin{information}[net]
  \textit{If $_{\chi PP}(M)=2$ a haplotype matrix M we can find an optimal pp-partition in polynomial time}
 	\end{information}
\end{frame}


\end{document}
```

![Screen Shot 2021-05-02 at 22.40.35.png](/image?hash=1cb41211d6bb2782e2d7d2b807c4bb6efb961d851c54b6ad33671cf66daba6b2)

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.