I want to mimic a calculator inputs and display with latex, after looking at several packages like tipfr
and ticollege
and finding them unsatisfactory to my needs I decided to do it myself with tcolorbox
, and piecing together a few answers from here. Here's a MWE:
\documentclass[openany,10pt]{book}
\usepackage{newpxtext}
\usepackage[varg]{newpxmath} %font package
\usepackage[letterpaper,margin=0.75in,bindingoffset=0.5in]{geometry}
\usepackage[most]{tcolorbox}
\colorlet{blackened}{black!90!white}
\colorlet{blackish}{black!70!white}
\colorlet{greyish}{black!60!white}
\colorlet{whiteish}{white}
\colorlet{orangeish}{yellow!90!red}
\colorlet{greenish}{green!16!gray}
\colorlet{redish}{red!80!black}
\tcbset{calbackground/.style={
enhanced,
leftright skip=0.25cm,beforeafter skip=0pt,
toptitle=0mm,bottomtitle=0mm,
right=2mm,left=2mm,
top=1pt,
bottom=0.25cm,
boxsep=0pt,
boxrule=0mm,
sharp corners,
sidebyside,
sidebyside gap=2mm,
lefthand ratio=0.6,
bicolor,
colback=black!10!white,
colbacklower=greenish,
colframe=white,
autoparskip,
}}
\newtcbtheorem[no counter]{calx}{Calculator}{calbackground}{cax}
\newtcbox{\KY}[1][]{
enhanced,
on line,
arc=2pt,outer arc=2pt,
boxrule=0pt,bottomrule=0.25mm,rightrule=0.2mm,
boxsep=0pt,left=0pt,right=0pt,top=1pt,bottom=1pt,
interior style={top color=blackish,bottom color=blackened},
colframe=greyish,
width=2.5em,
tcbox width=forced center,
equal height group=K,
valign=center,
fontupper=\footnotesize\sffamily,
coltext=orangeish,}
% coltitle=redish,colbacktitle=white,fonttitle=\footnotesize\sffamily,squeezed title=#1,center title,}
\newtcbox{\KN}{
enhanced,
on line,
arc=2pt,outer arc=2pt,
boxrule=0pt,bottomrule=0.25mm,rightrule=0.2mm,
boxsep=0pt,left=0pt,right=0pt,top=1pt,bottom=1pt,
interior style={top color=blackish,bottom color=blackened},
colframe=greyish,
width=1.5em,
tcbox width=forced center,
equal height group=K,
valign=center,
fontupper=\footnotesize\sffamily,
coltext=whiteish,}
\usepackage{lcd}
\LCDcolors{black}{greenish}
\DefineLCDchar{sq}{11100001000100011100000000000000000}
\DefineLCDchar{tm}{00000100010101000100010101000100000}
\DefineLCDchar{dv}{00000001000000011111000000010000000}
\DefineLCDchar{mu}{00011000011110100001000000000000000}
\DefineLCDchar{sc}{11011010011001000000000000000000000}
\DeclareMathOperator{\ee}{\textrm{e}}
\usepackage{MnSymbol} %boxes
\usepackage{xfrac} %sfrac
\usepackage{lipsum} %for textwidth comparison
\setlipsumdefault{1-2}
\begin{document}
\begin{calx}{}{}
\KY{$($}\KN{3}\KY{$x^2$}\KN{-}\KN{4}\KY{$x^2$}\KN{-}\KN{6}\KY{$x^2$}\KY{$)$}\KN{$=$}
\tcblower
{\Large\textLCD[0]{20}|(3{sq}-4{sq}-6{sq})|}
{\LARGE\textLCD[0]{16}| -43|}
\end{calx}
%
\begin{calx}{}{}
\KN{$\div$}\KY{$($}\KY{$(-)$}\KN{2}\KN{$\times$}\KN{4}\KN{$\times$}\KN{6}\KY{$)$}\KN{$=$}
\tcblower
{\Large\textLCD[0]{20}|ANS{dv}(-2{tm}4{tm}6)|}
{\LARGE\textLCD[0]{16}| 0.8958333333|}
\end{calx}
%
\begin{calx}{}{}
\KY{$\cos^{-1}$}\KY{ANS}\KN{$=$}
\tcblower
{\Large\textLCD[0]{20}|cos{mu}(ANS|}
{\LARGE\textLCD[0]{16}| 26.38432975|}
\end{calx}
%
\begin{calx}{}{}
\KY{$\circ\,\prime\,\prime\prime$}
\tcblower
{\Large\textLCD[0]{20}|cos{mu}(ANS|}
{\LARGE\textLCD[0]{16}| 26°23'3.59{sc} |}
\end{calx}
\lipsum
\KY{$x^2$}%
\KY{$x^3$}%
\KY{$x^{-1}$}%
\KY{$x^{\filledsquare}$}%
\KY{$\sqrt{\filledmedsquare}$}%
\KY{$\sqrt[3]{\filledmedsquare}$}%
\KY{$\sqrt[\filledsquare]{\medsquare}$}\\
\KY{$\ln$}%
\KY{$\log$}%
\KY{$\log_{\filledsquare}\medsquare$}%
\KY{$10^{\filledsquare}$}%
\KY{$\ee^{\filledsquare}$}\\
\KY{$(-)$}%
\KY{$\frac{\filledmedsquare}{\medsquare}$}%
\KY{$\sfrac{\filledmedsquare}{\medsquare}$}%
\KY{$\tfrac{\filledmedsquare}{\medsquare}$}\\
\KY{$\circ\,\prime\,\prime\prime$}%
\KY{$\sin$}%
\KY{$\sin^{-1}$}%
\KY{$\cos$}%
\KY{$\cos^{-1}$}%
\KY{$\tan$}%
\KY{$\tan^{-1}$}\\
\KY{$($}%
\KY{$)$}%
\KN{$\times$}%
\KN{$\div$}%
\KN{$+$}%
\KN{$-$}%
\KN{$=$}\\
\KN{$1$}%
\KN{$2$}%
\KN{$3$}%
\KN{$4$}%
\KN{$5$}%
\KN{$6$}%
\KN{$7$}%
\KN{$8$}%
\KN{$9$}%
\KN{$0$}\\
\KN{1}%
\KN{2}%
\KN{3}%
\KN{4}%
\KN{5}%
\KN{6}%
\KN{7}%
\KN{8}%
\KN{9}%
\KN{0}\\
\end{document}
This looks and works almost exactly the way I need it to, but I've a few difficulties:
1) The keys don't all align on the same line
2) The text inside different keys doesn't align on the same line
3) I can't figure out how to add a second function over a key, like sin^{-1}
over the sin
key, while also solving the first two problems.
Any help would be appreciated.