6

Consider the following code (see here for the original code):

\documentclass[
  a4paper,
  11pt
]{article}

\usepackage[varg]{newpxmath}
\usepackage[
  hmargin = 2.4cm,
  vmargin = 3cm
]{geometry}

\usepackage[most]{tcolorbox}
  \colorlet{blackened}{black!90!white}
  \colorlet{blackish}{black!70!white}
  \colorlet{greyish}{black!60!white}
  \colorlet{lightgreyish}{black!10!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.15cm,
    beforeafter skip = 0pt,
    toptitle = 0mm,
    bottomtitle = 0mm,
    right = 3pt,
    left = 3pt,
    top = 3pt,
    bottom = 3pt,
    boxsep = 0pt,
    boxrule = 0mm,
    sharp corners,
    sidebyside,
    sidebyside gap = 6pt,
    lefthand ratio = 0.622,
    bicolor,
    colback = lightgreyish,
    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.15mm,
  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,
  before upper = \vrule width 0pt height 2ex depth 1ex\relax,
}

\newtcbox{\KN}{
  enhanced,
  on line,
  arc = 2pt, outer arc = 2pt,
  boxrule = 0pt,
  bottomrule = 0.15mm,
  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 = whiteish,
  before upper = \vrule width 0pt height 2ex depth 1ex\relax,
}

\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}
\usepackage{xfrac}

\begin{document}

\begin{calx}{}{}
  \KY{$(-)$}
  \KY{8}
  \KN{$+$}
  \KY{6}
  \KY{enter}
  \tcblower
  {\Large
   \textLCD[0]{19}|-8+6|
   \textLCD[0]{18}|                 -2|
  }
\end{calx}

\end{document}

output

How do I raise the minus signs in both lines in the green box by a couple of ex or thereabout?

3
  • Maybe you could actually define a escape-command so that you can just use \resizebox{LENGTH}{!}{-} oder something similar to it … ?
    – user165228
    Commented Jun 19, 2018 at 21:46
  • @NikolaDjordjevic How can I do that? A fully MWE would be nice. Commented Jun 19, 2018 at 21:48
  • I just know how to escape commands in \lstset (it is escapeinside={CHAR1}{CHAR1}), but not how in tcolorbox
    – user165228
    Commented Jun 19, 2018 at 21:53

1 Answer 1

9

You can define a raised minus sign with

\DefineLCDchar{rm}{00000000001111100000000000000000000}

(which raises the minus by one pixel) and use it like this

\textLCD[0]{19}|{rm}8+6|

Or, if you want the minus sign to be always raised, you can just redefine it with

\DefineLCDchar{-}{00000000001111100000000000000000000}

and use it normally (\textLCD[0]{19}|-8+6|). In both cases the result is

enter image description here

The code:

\documentclass[
  a4paper,
  11pt
]{article}

%\usepackage[varg]{newpxmath}
\usepackage[
  hmargin = 2.4cm,
  vmargin = 3cm
]{geometry}

\usepackage[most]{tcolorbox}
  \colorlet{blackened}{black!90!white}
  \colorlet{blackish}{black!70!white}
  \colorlet{greyish}{black!60!white}
  \colorlet{lightgreyish}{black!10!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.15cm,
    beforeafter skip = 0pt,
    toptitle = 0mm,
    bottomtitle = 0mm,
    right = 3pt,
    left = 3pt,
    top = 3pt,
    bottom = 3pt,
    boxsep = 0pt,
    boxrule = 0mm,
    sharp corners,
    sidebyside,
    sidebyside gap = 6pt,
    lefthand ratio = 0.622,
    bicolor,
    colback = lightgreyish,
    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.15mm,
  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,
  before upper = \vrule width 0pt height 2ex depth 1ex\relax,
}

\newtcbox{\KN}{
  enhanced,
  on line,
  arc = 2pt, outer arc = 2pt,
  boxrule = 0pt,
  bottomrule = 0.15mm,
  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 = whiteish,
  before upper = \vrule width 0pt height 2ex depth 1ex\relax,
}

\usepackage{lcd}
  \LCDcolors{black}{greenish}
  \DefineLCDchar{sq}{11100001000100011100000000000000000}
  \DefineLCDchar{tm}{00000100010101000100010101000100000}
  \DefineLCDchar{dv}{00000001000000011111000000010000000}
  \DefineLCDchar{mu}{00011000011110100001000000000000000}
  \DefineLCDchar{sc}{11011010011001000000000000000000000}
  % raised minus
  \DefineLCDchar{rm}{00000000001111100000000000000000000}
  % alternative: redefine the minus sign
  %\DefineLCDchar{-}{00000000001111100000000000000000000}

\DeclareMathOperator{\ee}{\textrm{e}}

%\usepackage{MnSymbol}
\usepackage{xfrac}

\begin{document}

\begin{calx}{}{}
  \KY{$(-)$}
  \KY{8}
  \KN{$+$}
  \KY{6}
  \KY{enter}
  \tcblower
  {\Large
   \textLCD[0]{19}|{rm}8+6|
   \textLCD[0]{18}|                 {rm}2|
  }
\end{calx}

\end{document}

Edit:

With \DefineLCDchar the pixels in the 5x7 matrix are set. A 0 is "pixel off" and a 1 is "pixel on". The pixels are given from left to right and top to bottom. The picture from the manual shows this:

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .