1

I would like the first number in the multiplication to include a dollar sign or Pound sign. The question, for example, would be $12.34 x 56. In some cases, I would like the $ sign at the end of the number as in 12,34$

\documentclass[twoside,12pt]{article}
\usepackage[hmargin=0.75in,vmargin=0.5in,includeheadfoot,headheight=10mm,headsep=4mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{xlop}
\newcommand\gobble[1]{}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.0pt}
\begin{document}
\fontsize{14pt}{24pt}
\begin{minipage}[t][4.2cm][t]{0.5\textwidth} \textcolor{gray}{1. }
\opmul[voperation=top,voperator=bottom]{12.34}{56} \quad
\opmul[voperation=top,voperator=bottom,resultstyle=gobble,displayintermediary=None]{12.34}{56}
\end{minipage}
\clearpage
\end{document}

1 Answer 1

1

I do the add-ons separate to the xlop macros itself. I introduce a setup macro \opsignsetup{<symbol>}{<l or r positioning>} (defaults \$ with left positioning). Then one employs it with \signopmul[]{}{} using the standard argument format for \opmul.

This answer is currently hardwired so that voperation=top,voperator=bottom options are selected.

\documentclass[landscape,twoside,12pt]{article}
\usepackage[hmargin=0.75in,vmargin=0.5in,includeheadfoot,headheight=10mm,headsep=4mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{xlop}
\usepackage{stackengine}
\newcommand\gobble[1]{}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.0pt}
\newcommand\opsign{\$}
\newcommand\opsignpos{l}
\newcommand\opsignsetup[2]{\def\opsign{#1}\def\opsignpos{#2}}
\newcommand\signopmul[3][\relax]{%
  \def\tmparg{}%
  \ifx\relax#1\else\def\tmparg{#1,}\fi%
  \savestack\tmp{\expandafter\opmul\expandafter[\tmparg %
    voperation=top,voperator=bottom]{#2}{#3}}%
  \def\stacktype{L}%
  \if l\opsignpos%
  {\belowbaseline[0pt]{%
    \stackunder[\dimexpr\dp\tmpcontent-.4\ht\strutbox\relax]{%
    \small\opsign}{\small\opsign}}%
  }%
  \belowbaseline[0pt]{\tmp}%
  \else\if r\opsignpos
  \belowbaseline[0pt]{\tmp}%
  {\belowbaseline[0pt]{%
    \stackunder[\dimexpr\dp\tmpcontent-.4\ht\strutbox\relax]{%
    \small\opsign}{\small\opsign}}%
  }%
  \fi\fi
}
\begin{document}
\fontsize{14pt}{24pt}
\begin{minipage}[t][4.2cm][t]{0.5\textwidth} \textcolor{gray}{1. }
\opmul[voperation=top,voperator=bottom]{12.34}{56} \quad
\opmul[voperation=top,voperator=bottom,resultstyle=\gobble,displayintermediary=None]{12.34}{56}
\end{minipage}

\begin{minipage}[t][4.2cm][t]{0.5\textwidth} \textcolor{gray}{2. }
\signopmul{12.34}{56} \quad
\signopmul[resultstyle=\gobble,displayintermediary=None]{12.34}{56}
\end{minipage}

\opsignsetup{\pounds}{r}
\begin{minipage}[t][4.2cm][t]{0.5\textwidth} \textcolor{gray}{3. }
\signopmul{12.34}{56} \quad
\signopmul[resultstyle=\gobble,displayintermediary=None]{12.34}{56}
\end{minipage}

\end{document}

enter image description here

For a bottom-aligned version of the problems, here is the alternative (with the same invocation syntax)

\documentclass[landscape,twoside,12pt]{article}
\usepackage[hmargin=0.75in,vmargin=0.5in,includeheadfoot,headheight=10mm,headsep=4mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{xlop}
\usepackage{stackengine}
\newcommand\gobble[1]{}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.0pt}
\newcommand\opsign{\$}
\newcommand\opsignpos{l}
\newcommand\opsignsetup[2]{\def\opsign{#1}\def\opsignpos{#2}}
\newcommand\signopmul[3][\relax]{%
  \def\tmparg{}%
  \ifx\relax#1\else\def\tmparg{#1,}\fi%
  \savestack\tmp{\expandafter\opmul\expandafter[\tmparg %
    voperation=bottom,voperator=bottom]{#2}{#3}}%
  \def\stacktype{L}%
  \if l\opsignpos%
  {\abovebaseline[0pt]{%
    \stackon[\dimexpr\dp\tmpcontent+\ht\tmpcontent-1.4\ht\strutbox\relax]{%
    \small\opsign}{\small\opsign}}%
  }%
  \abovebaseline[0pt]{\tmp}%
  \else\if r\opsignpos
  \abovebaseline[0pt]{\tmp}%
  {\abovebaseline[0pt]{%
    \stackon[\dimexpr\dp\tmpcontent+\ht\tmpcontent-1.4\ht\strutbox\relax]{%
    \small\opsign}{\small\opsign}}%
  }%
  \fi\fi
}
\begin{document}
\fontsize{14pt}{24pt}
\begin{minipage}[t][4.2cm][t]{0.5\textwidth} \textcolor{gray}{1. }
\opmul[voperation=top,voperator=bottom]{12.34}{56} \quad
\opmul[voperation=top,voperator=bottom,resultstyle=\gobble,displayintermediary=None]{12.34}{56}
\end{minipage}

\begin{minipage}[t][4.2cm][t]{0.5\textwidth} \textcolor{gray}{2. }
\signopmul{12.34}{56} \quad
\signopmul[resultstyle=\gobble,displayintermediary=None]{12.34}{56}
\end{minipage}

\opsignsetup{\pounds}{r}
\begin{minipage}[t][4.2cm][t]{0.5\textwidth} \textcolor{gray}{3. }
\signopmul{12.34}{56} \quad
\signopmul[resultstyle=\gobble,displayintermediary=None]{12.34}{56}
\end{minipage}

\end{document}

You must log in to answer this question.

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