[Tex/LaTex] Overline in text mode, Background Color

colormath-mode

I've got the following code below to mimic a TI83 Calculator screen, but I'm stuck on adding a couple of things I'd like to add.

  1. I'd like to make the \overline{x} in text mode. I tried \={x}, and although that works in LaTeX, it doesn't work on our system. Any other ideas on how I can produce an overline over x in text mode?

  2. I'd also like to try to take this:

     \def\input{\calcinput{\ Inpt:Data\ Stats}}
    

    and put the word Stats in the color white with a solid black background behind it.

Any thoughts?

\documentclass[11pt]{scrartcl} 
\usepackage{tikz}
\usepackage{xparse}
\newcommand\tsurd{\ensuremath{\sqrt{\phantom{i}}}}
\newcommand\txbar{\ensuremath{\overline{x}}}
\ExplSyntaxOn
\NewDocumentCommand{\calcinput}{m}
{
 \tl_map_inline:nn { #1 } { ##1 \hspace{0pt} }
}
\ExplSyntaxOff

\begin{document}

\def\tinterval{\calcinput{TInterval}}
\def\input{\calcinput{\ Inpt:Data\ Stats}}
\def\xbar{\calcinput{\ \txbar:10}}
\def\s{\calcinput{\ Sx:2.345678}}
\def\n{\calcinput{\ n:12}}
\def\cl{\calcinput{\ C-Level:0.95}}
\def\calc{\calcinput{\ Calculate}}


\begin{center}
\begin{tikzpicture}[font=\large\ttfamily]
\draw (0,0) rectangle (5,-4);
\node[align=flush left,text width =5cm,
     anchor=north west,inner sep=1pt] (tinterval) {\tinterval};
\node[align=flush left,text width =5cm,
     anchor=north west,inner sep=1pt] (input) at (tinterval.south west) {\input};
\node[align=flush left,text width =5cm,
     anchor=north west,inner sep=1pt] (xbar) at (input.south west) {\xbar};
\node[align=flush left,text width =5cm,
     anchor=north west,inner sep=1pt] (s) at (xbar.south west) {\s};
\node[align=flush left,text width =5cm,
     anchor=north west,inner sep=1pt] (n) at (s.south west) {\n};
\node[align=flush left,text width =5cm,
     anchor=north west,inner sep=1pt] (cl) at (n.south west) {\cl};
\node[align=flush left,text width =5cm,
     anchor=north west,inner sep=1pt] (calc) at (cl.south west) {\calc};
\end{tikzpicture}
\end{center}
\end{document} 

Best Answer

You can use \text{x} from the amsmath package to typeset the x in text mode, and \colorbox{black}{\textcolor{white}{Stats}} to obtain the white text, with a black background:

enter image description here

Notes:

  • I would recommend you not use \input as a macro name. That is a predefined LaTeX macro. So to minimize those kinds of errors I would recommend you use LaTeX's \newcommand rather than TeX's \def. I have updated the MWE below to reflect this.
  • Also, if you use \tikzset to define a style as:

    \tikzset{My Node Style/.style={
       align=flush left,text width =5cm, anchor=north west,inner sep=1pt}
    }
    

    you can greatly simplify your code as I have done below.

Code:

\documentclass[11pt]{scrartcl} 
\usepackage{tikz}
\usepackage{xparse}
\usepackage{xcolor}
\usepackage{amsmath}

\newcommand\tsurd{\ensuremath{\sqrt{\phantom{i}}}}
\newcommand\txbar{\ensuremath{\overline{\text{x}}}}
\ExplSyntaxOn
\NewDocumentCommand{\calcinput}{m}
{
 \tl_map_inline:nn { #1 } { ##1 \hspace{0pt} }
}
\ExplSyntaxOff

\begin{document}

\newcommand*{\tinterval}{\calcinput{TInterval}}
\newcommand*{\Inpt}{\calcinput{\ Inpt:Data\ {\colorbox{black}{\textcolor{white}{Stats}}}}}

\newcommand*{\InptData}{\calcinput{\ Inpt:Data\ }}
\newcommand*{\Stat}{\calcinput{Stats}}

\newcommand*{\xbar}{\calcinput{\ \txbar:10}}
\newcommand*{\s}{\calcinput{\ Sx:2.345678}}
\newcommand*{\n}{\calcinput{\ n:12}}
\newcommand*{\cl}{\calcinput{\ C-Level:0.95}}
\newcommand*{\calc}{\calcinput{\ Calculate}}

\tikzset{My Node Style/.style={
    align=flush left,text width =5cm,
    anchor=north west,inner sep=1pt}
}

\begin{center}
\begin{tikzpicture}[font=\large\ttfamily]
    \fboxsep=0.5pt
    \coordinate (Origin) at (0,0);
    \draw (Origin) rectangle (5,-4);
    \node[My Node Style] (tinterval) at (Origin)               {\tinterval};
    \node[My Node Style] (Inpt)      at (tinterval.south west) {\Inpt};
    \node[My Node Style] (xbar)      at (Inpt.south west)      {\xbar};
    \node[My Node Style] (s)         at (xbar.south west)      {\s};
    \node[My Node Style] (n)         at (s.south west)         {\n};
    \node[My Node Style] (cl)        at (n.south west)         {\cl};
    \node[My Node Style] (calc)      at (cl.south west)        {\calc};
\end{tikzpicture}
\end{center}
\end{document}