# Keep at all times, the minus sign above aligned with minus sign below

How can I change the frg command such that I can create and maintain at all times the minus sign above aligned with minus sign below? PS: If you can show how to include a font setting for the whole macro, I'll consider it a good additional contribution to this answer.

\documentclass{article}
\newcommand{\minus}{\raisebox{.1in}{$-$ \ }}
\newcommand{\eq}{\textbf{\fontsize{45}{6}\selectfont\raisebox{-.16in}{\scalebox{.5}[1.1]{= \vspace{.03in}}}}}
\usepackage{stackengine,scalerel}
\def\over{\abovewithdelims...32em}
\makeatletter
\newcommand*{\frg}[1]{%
\frg@aux#1,,\@nil
}
\def\frg@aux#1,#2,#3\@nil{%
\ensuremath{ \eq {{\raisebox{.069in}{ \ \centering \mbox{\fontsize{45}{6}\selectfont\textbf{#1}} \ }}
\over {\raisebox{-.275in}{ \ \centering\mbox{\fontsize{45}{6}\selectfont\textbf{#2}}}} \ }}
}
\makeatother

\begin{document}
\frg{4 \minus 3, \ 3 \minus 1  \ }
\end{document}

• These are not minus signs, but hyphen dashes. I don't see what exactly you're trying to achieve. – Bernard Apr 21 at 21:05
• you don't give many hints of the intention of this construct, it looks like math but you are using text mode constructs, \centering is doing nothing in a \raisebox as that is set in horizontal mode, you have redefined \over so this will change \frac and \buildrel which are defined in terms of \over. – David Carlisle Apr 21 at 21:22
• your example uses single digits so everything aligns naturally, but does your question mean you want \frac{123-1}{1-123} with the - aligned? – David Carlisle Apr 21 at 21:24
• Exactly @DavidCarlisle, I imagine it is a sufficient condition to keep the two minus signs aligned. As for mixing text mode with mathematical mode in addition to the likely inefficient use of \ centering is by lack of experience, I would be grateful for your answer to this my adding issue to the fixes and enhancements to fix what was unnecessary to use in my code so that I can learn. – Diego Bnei Noah Apr 21 at 21:34
• I think marmot's answer does what you want. Not sure what else I could add. – David Carlisle Apr 21 at 21:36

I do not know what the purpose of this exercise is but alignment can e.g. achieved with an array. Notice that I didn't pay any attention to spacing, bold and etc. because I do not know the purpose.

\documentclass{article}
\makeatletter
\def\frg@aux#1-#2,#3-#4\@nil{\begin{array}{@{\,}r@{}c@{}l@{\,}}
#1&-&#2\\
\hline
#3&-&#4
\end{array}}
\def\frg#1{\frg@aux#1\@nil}
\makeatother

\begin{document}
$a=\frg{4 - 3, 3 - 1 }$
\end{document}


• Really @marmot, for academic use it is indifferent most often the alignment of operators within a fraction. But the need to specify the position of the operators in this case refers to the fate that I intend to give inside in the education of very small children in order to facilitate the visual reading. I have used very little array command, I have tried a few different modes such as \ begin {align *} ... \ end {align *} but always with errors. I am still learning, grateful for your help and all who have made further comments. – Diego Bnei Noah Apr 21 at 21:28

Do you mean like this?

\documentclass{article}
\usepackage{xparse,array}

\ExplSyntaxOn

\NewDocumentCommand{\frg}{mm}
{
\dbn_frg:nn { #1 } { #2 }
}

\tl_new:N \l__dbn_frg_num_tl
\tl_new:N \l__dbn_frg_den_tl

\cs_new_protected:Nn \dbn_frg:nn
{
\tl_set:Nn \l__dbn_frg_num_tl { #1 }
\tl_set:Nn \l__dbn_frg_den_tl { #2 }
\regex_replace_once:nnN { (\+|\-) } { \cT\& \1 \cT\& } \l__dbn_frg_num_tl
\regex_replace_once:nnN { (\+|\-) } { \cT\& \1 \cT\& } \l__dbn_frg_den_tl
\begin{array}{@{} r @{} >{{}}c<{{}} @{} l @{} }
\l__dbn_frg_num_tl \\
\hline
\l__dbn_frg_den_tl
\end{array}
}

\ExplSyntaxOff

\begin{document}

$\frg{4-3}{4-1}\qquad \frg{4+3}{4+11} \qquad \frg{15-2}{6+12}$

\end{document}
`

• Yes, just as @marmot's answer to yours is also appropriate because you agree to increase the fraction bar thickness using \ hline [number] and also to decrease or increase the space between the denominator, bar, and numerator using \ vspace { number} or something. Now I'm looking for a way to apply a font type in a single command to the whole macro set if you have any suggestions. Thank you for your response. – Diego Bnei Noah Apr 21 at 23:45