Tran Le Nam
Please help me draw two kinds of calculator keyboards as the below figure. How is it used for LaTeX code?
Many thanks!
![HinhMayTinh.png](/image?hash=7b2868052ec6541159c627ace9a924e4f1e7afedbeb886d8e6e058c9d4da5d76)
Top Answer
samcarter
There are several packages which provide calculator keys, for example the [`tipfr` package](https://www.ctan.org/pkg/tipfr) which
```
\documentclass{article}
\usepackage{tipfr}
\begin{document}
\centering
\Touche[principal={on}]
\hrule
\Touche[principal={shift}] \Touche[principal={on}]
\hrule
\Touche[style=number, principal=0]
\Touche[style=number, principal=1]
\Touche[style=number, principal=2]
\Touche[style=number, principal=3]
\Touche[style=number, principal=4]
\Touche[style=number, principal=5]
\Touche[style=number, principal=6]
\Touche[style=number, principal=7]
\Touche[style=number, principal=8]
\Touche[style=number, principal=9]
\end{document}
```
![Screenshot 2021-08-02 at 11.17.28.png](/image?hash=5d678a743324c12a2ea4a7c3543fe7b75f57e824335b48335dbc9b61511b21d5)
Or if you prefer a more Casio-like look, you could use the [`graph35` package](https://ctan.org/pkg/graph35)
```
\documentclass{article}
\usepackage[
%color=blackandwhite
]{graph35}
\begin{document}
\centering
\key{ACON}
\key{SHIFT}\key{ACON}
\key{zero}\key{1}\key{2}\key{3}
\key{4}\key{5}\key{6}\key{7}
\key{8}\key{9}
\end{document}
```
![Screenshot 2021-08-02 at 11.28.34.png](/image?hash=e7debb37816f7d6d40eb4558b787c4cc10b9e270534cf01b947df8f45ca8adc2)
Or you could use `tikz` and give the buttons whatever look you want:
```
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows,shapes.geometric}
\newcommand{\key}[2][]{\begin{tikzpicture}
\node[shade,top color=black, bottom color=gray!90!black,text=white,minimum width=3em,minimum height=2em,drop shadow,rounded corners,font=\sffamily,#1] at (0,0) {#2};
\end{tikzpicture}}
\begin{document}
\centering
\key[ellipse]{ON}
\key[ellipse]{ON}
\key[ellipse]{SHIFT}
\key{0}
\key{1}
\key{2}
\key{3}
\key{4}
\key{5}
\key{6}
\key{7}
\key{8}
\key{9}
\end{document}
```
![Screenshot 2021-08-02 at 16.25.34.png](/image?hash=c8d1ee1aad0cda0e03775265ae90027d8bd9e4255a7781a33842522b1fb15f5c)
```
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows,shapes.geometric}
\newcommand{\key}[2][]{\begin{tikzpicture}
\node[shade,ball color=black,text=white,minimum width=3em,minimum height=2em,drop shadow,rounded corners,font=\sffamily,#1] at (0,0) {#2};
\end{tikzpicture}}
\begin{document}
\centering
\key[ellipse]{ON}
\key[ellipse]{ON}
\key[ellipse]{SHIFT}
\key{0}
\key{1}
\key{2}
\key{3}
\key{4}
\key{5}
\key{6}
\key{7}
\key{8}
\key{9}
\end{document}
```
![Screenshot 2021-08-02 at 16.28.00.png](/image?hash=764dc6b72b8ab98418e175b2acaa3c109db639ce344c0dfd65b4f78354052971)
Answer #2
Skillmon
An option missing from [@samcarter's wonderful answer](https://topanswers.xyz/tex?q=1872#a2102) is `menukeys`[^1].
Though originally written for computer keyboards (and so there are a few special key names like `\shift` and so on). Placement would have to be done by some other means (~~either via Ti*k*Z~~[^2] or via `tabular`s):
```
\documentclass[]{article}
\usepackage{menukeys}
\usetikzlibrary{shapes.geometric}
% change the used style for the keys to have a shadow and the delimiter
% character between multiple keys for key combinations (the package default is
% `+` which seems unhandy for calculator keys).
\renewmenumacro\keys[;]{shadowedroundedkeys}
\newmenustylesimple{shadowedovalkeys}
{% set the TikZ style which should be applied for each key
tw@set@tikz@colors, % evil menukeys-internal key
,minimum width=2em
,font=\relsize{-1}\sffamily
,general shadow=%
{shadow xshift=.2ex, shadow yshift=-.15ex, fill=\usemenucolor{c}}
,ellipse
,inner ysep=0pt
}
[% set the separator between multiple keys
\hspace{0.2ex}\hspace{0.1em plus 0.1em minus 0.05em}%
\textcolor{\usemenucolor{b}}{\raisebox{0.25ex}{\sffamily\relsize{-2}+}}%
\hspace{0.1em plus 0.1em minus 0.05em}%
]
{gray}
\newmenumacro\okeys[;]{shadowedovalkeys}
\usepackage{collcell} % will also load `array`
\usepackage{expkv-cs}
% define a new column type which typesets the column contents using the `\keys`
% macro. The column type will be called `k` and accept an optional argument
% which has a small key value interface (powered by expkv-cs so we don't have to
% add some expansion chain here to get the column type)
\newcolumntype{k}[1]{}
\makeatletter
\ekvcSplit\keys@col@parse
{
type=\keys
,align=c
}
{%
\@temptokena\expandafter
{\the\@temptokena>{\let\keys@col@#1\collectcell\keys@col}#2<{\endcollectcell}}%
}
\ekvcSecondaryKeys\keys@col@parse
{%
nmeta oval=type=\okeys
,nmeta rect=type=\keys
,nmeta c=align=c
,nmeta l=align=l
,nmeta r=align=r
}
\renewcommand*\NC@rewrite@k[1][]
{%
\keys@col@parse{#1}%
\NC@find
}
\newcommand\keys@col[1]{\if\relax\detokenize{#1}\relax\else\keys@col@{#1}\fi}
\makeatother
\usepackage{booktabs}
\begin{document}
\keys{\shift}\keys{ON}
\okeys{\shift;1}
\bigskip
\begingroup
\tabcolsep=1pt
\extrarowheight=1pt
\begin{tabular}{*4k}
\toprule
\multicolumn{4}{k[oval]}{ON} \\
\midrule
& \shift & ON \\
\midrule
0 & 1 & 2 & 3 \\
4 & 5 & 6 & 7 \\
& 8 & 9 \\
\bottomrule
\end{tabular}
\endgroup
\end{document}
```
![menukeyskeys.png](/image?hash=a50db871d6472721ed7cd9689840c107c86d878a5fc98da3e3af744093b14a85)
[^1]: Disclaimer: I somehow ended up being one of the maintainers.
[^2]: `menukeys` uses Ti*k*Z internally, and since `tikzpicture`s aren't nestable (it doesn't throw an error, and sometimes works, but isn't really supported) you shouldn't do the placement with Ti*k*Z. What you could do is box the keys you need up using TeX-boxes and place those boxes with Ti*k*Z.