[Tex/LaTex] How to make a fixed height-width box with custom padding

boxesheightwidth

I am new to latex, I am trying to include output of TI84 calculator in my document.

It is supposed to look like this:

actual TI 84

Following is what I am able to make.

my texas calculator

My output's height and width arrange itself, I want fixed height/width, with custom padding and text wrapping around inside the box. Any help will be greatly appreciated.

My code is

{\scriptsize
\setmainfont{Texas Instruments TI-84 series}
\tabulinesep=0.05 in
\begin{tabu} to 1 in {|c |}
\hline
normalcdf(-1.5,2)\\
\hfill .9104427093
\\\hline
\end{tabu}
}

Best Answer

The \vbox to... primitive construction is the answer to your question. You can try the following code:

\def\tifont{\setmainfont{Texas Instruments TI-84 series}}
\setbox0=\hbox{\tifont 12345678901234567\kern2pt}\edef\tiwidth{\wd0}
\def\ticalc#1{\hbox{\vrule\vbox to2cm{\hrule\kern1pt
   \def\l##1|{\hbox to\tiwidth{\kern1pt##1\kern1pt\hss}}\tifont #1\vss\hrule}\vrule}}

\ticalc{
\l normalcdf(-1.5,2)|
\l\hfill .9104427093|
}

Edit: My second version of the macro \ticalc implements the auto-wrapping. The width of the box has to be set by setbox. See the line with \setbox0 where 16 characters is supposed. The text with more length than this dimension is wrapped. The wrapping is possible between each pair of characters.

The optional \result followed by text can be included in the parameter of the \ticalc macro. Such text is printed at next line aligned to right.

\def\titext{\hsize=\tiwidth \leftskip=1pt\rightskip=1pt plus1fil \tifont \noindent \titextA}
\def\titextA{\futurelet\next\titextB}
\def\titextB{\ifx\next\result \else \null\next \penalty0 \expandafter\titextC \fi}
\def\titextC{\afterassignment\titextA \let\next= }

\newfontfamily\tifont{Texas Instruments TI-84 series}
\setbox0=\hbox{\tifont 1234567890123456\kern2pt}\edef\tiwidth{\wd0}
\def\ticalc#1{\hbox{\vrule\vbox to2cm{\hrule\kern1pt\titext#1\result\relax\vss\hrule}\vrule}}
\def\result#1\relax{\par\let\result=\relax \hbox to\tiwidth{\hss#1\kern1pt}}

\ticalc{normalcdf(-1.5,2)\result .9104427093}

\ticalc{abcdefghijklmnopqrsyuyu}