9

I am a bit of a novice with LaTeX so excuse if this is a silly question.

I am writing a "common methods" booklet for my department, and one of the agreed methods is to show fractional equivalences when adding/subtracting fractions. As such, we want to show the step where multiplication occurs. I want this to be a small superscript/subscript at the outside of the fraction (ie on the left of the first and on the right of the second). The subscript is working fine and the right hand sided fraction looks fine, but the superscript on the left is in line with the fraction line.

I have tried to add a blank fraction to help, but it's almost as if the absence of text/numbers/anything has lead the superscript to not be superscript.

Here is the code I've tried:

$$\frac{}{}_{\times 3}^{\times 3}\frac{4}{7}- \frac{1}{3}^{\times 7}_{\times 7}$$

enter image description here

I want the three at the top to be aligned with the seven. I have also tried \vphantom, fractions with white writing etc.

Thanks in advance.

2

3 Answers 3

12

Rather than using an explicit phantom or strut, you could also use \sideset except that that is intended for operators like \sum so you need a \mathop here which is a bit unfortunate.

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}
\[
  \sideset{_{\times 3}^{\times 3}}{}{\mathop{\frac{4}{7}}}
  -
  \sideset{}{_{\times 7}^{\times 7}}{\mathop{\frac{1}{3}}}
\]
\end{document}
3
  • @MrManderson You've accepted this but I was thinking of deleting: mathtools is a standard extension of amsmath` and as it provided leftindex that's probably better idea than gently abusing sideset as I suggest here. You should probably accept Nbur's answer. Commented Jun 12 at 10:48
  • or @campa's one since it doesn't require extra package
    – NBur
    Commented Jun 12 at 10:52
  • @NBur well all documents using math should have amsmath (or mathtools) loaded so I don't count these as extra any more that article class being loaded is extra. It's just the way it is due to 1980's memory limitations. Commented Jun 12 at 11:02
9

Based on https://tex.stackexchange.com/a/11566/151808, you can use mathtools or leftindex:

\documentclass{article}
\usepackage{mathtools}
\usepackage{leftindex}

\newcommand*{\multL}[3]{\prescript{#3\times}{#3\times}{\frac{#1}{#2}}}
\newcommand*{\multLbis}[3]{\leftindex^{#3\times}_{#3\times}{\frac{#1}{#2}}}
\newcommand*{\multR}[3]{{\frac{#1}{#2}}_{\times#3}^{\times#3}}

\begin{document}
  \[
  \multL{4}{7}{3} - \multR{1}{3}{7} = \multLbis{4}{7}{3} - \multR{1}{3}{7}
  \]
\end{document}

which produces

enter image description here

1
  • see comment under my answer :-) Commented Jun 12 at 10:48
4

You can add superscripts and subscripts that take no space, so they don't influence the width of the fraction line, but adding the necessary space (at the left or the right).

\documentclass{article}
\usepackage{mathtools}

\NewDocumentCommand{\fractimes}{smmm}{%
  % #1 = optional * (for factors on the left)
  % #2 = numerator, #3 = denominator, #4 = factor
  \IfBooleanTF{#1}{% factor on the left
    \fractimesdo{#2}{#3}{#4}{}%
  }{% factor on the right
    \fractimesdo{#2}{#3}{}{#4}%
  }%
}

\newlength{\fractimesfactor}

\NewDocumentCommand{\fractimesdo}{mmmm}{%
  \settowidth{\fractimesfactor}{$\scriptstyle\times{#3}{#4}\,$}%
  \IfBlankT{#4}{\hspace{\fractimesfactor}}%
  \frac{\fractimesterm{^}{#1}{#3}{#4}}{\fractimesterm{_}{#2}{#3}{#4}}%
  \IfBlankT{#3}{\hspace{\fractimesfactor}}%
}
\NewDocumentCommand{\fractimesterm}{mmmm}{%
  \IfBlankT{#4}{\mathllap{{}#1{\times#3\,}}}
  #2
  \IfBlankT{#3}{\mathrlap{{}#1{\,\times#4}}}
}

\begin{document}

\[
\left|\fractimes*{4}{7}{3}-\fractimes{1}{3}{7}\right|
\]

\[
\left|\fractimes*{444}{7}{3}-\fractimes{111}{3}{7}\right|
\]

\end{document}

The absolute value bars are used just to show that the spacing is right.

enter image description here

You must log in to answer this question.

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