我的计算器模仿数学颜色

我的计算器模仿数学颜色

全部,

我正在制作另一个计算器屏幕。这将产生我目前所拥有的内容。请注意红色的一行,其中有一个红色的 mu 字符。我需要该行显示为:

\mu:\ne\mu_0  <\mu_0  >\mu_0

我还需要从三者中选择一个,放置黑色背景并用白色输入字符。

有什么建议么?

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\usepackage{booktabs}
\usepackage{xparse}
\newcommand\tsurd{\ensuremath{\sqrt{\phantom{i}}}}
\newcommand\txbar{\ensuremath{\overline{\text{x}}}}
\newcommand\sumx{\ensuremath{\Sigma{\text{x}}}}
\newcommand\sumxsq{\ensuremath{\Sigma{\text{x}}^2}}
\newcommand\sigmax{\ensuremath{\sigma{\text{x}}}}
\newcommand\muzero{\ensuremath{\mu_0}}
\newcommand\muzerone{\ensuremath{\ne\mu_0}}
\newcommand\mymu{\ensuremath{\color{red}{\mu}}}
\ExplSyntaxOn
\NewDocumentCommand{\calcinput}{m}
{
 \tl_map_inline:nn { #1 } { ##1 \hspace{0pt} }
}
\ExplSyntaxOff


\begin{document}

\def\ttest{\calcinput{T-Test}}
\def\inpt{\calcinput{\ Inpt:{\colorbox{black}{\textcolor{white}{Data}}\ Stats}}}
\def\mymuzero{\calcinput{\ \muzero:0}}
\def\mylist{\calcinput{\ List:L1}}
\def\myfreq{\calcinput{\ Freq:1}}
\def\myalt{\calcinput{\ \mymu:}}
\def\mycalc{\calcinput{\ {\colorbox{black}{\textcolor{white}{Calculate}}\ Draw}}}


\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] (ttest) {\ttest};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (inpt) at (ttest.south west) {\inpt};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (mymuzero) at (inpt.south west) {\mymuzero};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (mylist) at (mymuzero.south west) {\mylist};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (myfreq) at (mylist.south west) {\myfreq};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (myalt) at (myfreq.south west) {\myalt};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (mycalc) at (myalt.south west) {\mycalc};
\end{tikzpicture}
\end{center}

\end{document}

答案1

以下是您要寻找的两个选项。在这里,我定义了\WhiteText将文本放在黑框内的宏。这还会调整黑框的水平间距,这样就不会导致文本发生任何移动。

在此处输入图片描述

进一步增强:

  • 最好定义一个\mymumu接受参数 (0,1,2,3) 的宏,该参数定义三个术语中的哪一个要使用该\WhiteText宏。

代码:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\newcommand*{\WhiteText}[1]{%
    \colorbox{black}{\kern-\fboxsep\textcolor{white}{#1}\kern-\fboxsep}%
}%

\usepackage{booktabs}
\usepackage{xparse}
\newcommand\tsurd{\ensuremath{\sqrt{\phantom{i}}}}
\newcommand\txbar{\ensuremath{\overline{\text{x}}}}
\newcommand\sumx{\ensuremath{\Sigma{\text{x}}}}
\newcommand\sumxsq{\ensuremath{\Sigma{\text{x}}^2}}
\newcommand\sigmax{\ensuremath{\sigma{\text{x}}}}
\newcommand\muzero{\ensuremath{\mu_0}}
\newcommand\muzerone{\ensuremath{\ne\mu_0}}
\newcommand\mymu{\ensuremath{\color{red}{\mu}}}

\newcommand\mymumuA{\ensuremath{\color{red}\mu:\ne\mu_0 <\mu_0 >\mu_0}}
\newcommand\mymumuB{\ensuremath{\color{red}\mu:\ne\mu_0 < \WhiteText{$\mu_0$} >\mu_0}}

\ExplSyntaxOn
\NewDocumentCommand{\calcinput}{m}
{
 \tl_map_inline:nn { #1 } { ##1 \hspace{0pt} }
}
\ExplSyntaxOff


\begin{document}

\def\ttest{\calcinput{T-Test}}
\def\inpt{\calcinput{\ Inpt:{\colorbox{black}{\textcolor{white}{Data}}\ Stats}}}
\def\mymuzero{\calcinput{\ \muzero:0}}
\def\mylist{\calcinput{\ List:L1}}
\def\myfreq{\calcinput{\ Freq:1}}
\def\myaltA{\calcinput{\ \mymumuA:}}
\def\myaltB{\calcinput{\ \mymumuB:}}
\def\mycalc{\calcinput{\ {\colorbox{black}{\textcolor{white}{Calculate}}\ Draw}}}


\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] (ttest) {\ttest};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (inpt) at (ttest.south west) {\inpt};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (mymuzero) at (inpt.south west) {\mymuzero};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (mylist) at (mymuzero.south west) {\mylist};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (myfreq) at (mylist.south west) {\myfreq};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (myaltA) at (myfreq.south west) {\myaltA};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (myaltB) at (myaltA.south west) {\myaltB};
\node[align=flush left,text width =5cm,
 anchor=north west,inner sep=1pt] (mycalc) at (myaltB.south west) {\mycalc};
\end{tikzpicture}
\end{center}

\end{document}

相关内容