5

I'm attempting to reproduce an existing display math.

existing display math

\begin{equation*}P=50,210,000\left(\frac{t}{D}\right)^3\!,\end{equation*}

This produces:

typeset display math

I would like to shove the trailing comma back under superscript.

I have tried various combinations of spacing commands to no avail.

Thanks in advance for advice, including any "Don't do that" suggestions.

2
  • 1
    how about 50.21\times 10^6 \left( \frac{t} {D}\right)^3 ? You can still use the comma in the end if you really want to use it. Jul 19, 2021 at 2:07
  • @fromthebeeland I don't see how that affects the trailing comma. (Although I do agree that it's useful to change the leading coefficient.)
    – Teepeemm
    Jul 19, 2021 at 23:52

3 Answers 3

7

Speaking for myself, I think the final comma should be placed somewhere to the right of the 3 power term, as the comma is not part of the formula itself. Of course, just how far to the right of the formula it should be placed is subject to debate. See below for a specific suggestion.

I would like to recommend that you make several changes.

  • Load the mleftright package and use its \mleft and \mright macros instead of \left and \right to reduce the amount of whitespace around the large parentheses.

  • Reduce the horizontal space between the parenthetic term and the power term by replacing ^3 with ^{\!\!3}.

  • Optionally, load the siunitx package with the option group-separator={,} and replace 50,210,000 with \num{50210000}. This will get the correct spacing around the thousands-separators. If you don't want to use the \num macro in this way, you really should encase both commas in curly braces; doing so changes their math status from math-punct to math-ord, implying that TeX won't insert extra space after them.

  • Use but a single \! directive before the final comma. That way, the overall "picture" of the formula is nice and compact, while still providing a visual clue that the final comma is not part of the formula itself.

enter image description here

\documentclass{article}
\usepackage{amsmath}    % for 'equation*' environment
\usepackage{mleftright} % for '\mleft' and '\mright' macros
\usepackage[T1]{fontenc}
\usepackage[group-separator={,}]{siunitx}
\begin{document}
\begin{align*}
P
&= 50,210,000\left(\frac{t}{D}\right)^3, \quad\texttt{before} \\[2ex]
&= \num{50210000}\mleft(\frac{t}{D}\mright)^{\!\!3}\!, \qquad\texttt{after}
\end{align*}
\end{document}
2
  • 2
    Logically you're right, but sometimes fitting an equation and any trailing punctuation onto one line trumps that (especially in a 2-column layout). I reckon the majority of \!'s I've ever used were in 2 equations in one paper for that reason (full-width equations weren't handled well by the journal especially with plentiful figures - the downside of a small theoretical section in an experimental paper). Much of the was tucking the superscripts in like your 2nd suggestion.
    – Chris H
    Jul 19, 2021 at 10:29
  • 1
    @ChrisH - I fully agree with the proposition that if you absolutely, positively have to economize on horizontal whitespace (say, because of a two-column layout requirement and a long-ish formula, you'll sometimes do things you otherwise would never consider doing. :-) One such measure is to reduce the default values of \thinmuskip, \medmuskip, and \thickmuskip, possibly to as little as 0mu...
    – Mico
    Jul 19, 2021 at 11:25
4
  • If you’re writing a long number with commas as place separators, you should write those commas using {,} instead of ,. The former gives “ordinary” spacing so you won't have the extra space between the commas and the following digits.

  • My instinct for the comma is don't do that, but if you really want to do it, you can do something like the following:

    \left. % ❷
    \left(
    \frac{t}{D}
    \right)
    \! % ❸
    \rlap{,} % ❶
    \! % ❸
    \right. % ❷
    ^{3}
    

    We make the comma stick out to the right ❶ by enclosing it in \rlap (overlap to the right). However, this will also cause the superscript to be attached to the comma instead of to the parentheses so we’ll put a pair of invisible delimiters ❷ around the parentheses.¹ Finally, everything is a bit spaced out more than we'd like so I threw in some negative thin skips ❸ to tighten the whole formula.


  1. Normally we see \left. and \right. used to create unmatched big delimiters for things like multi-line equations or constructions like a case. This is the first time I’ve ever had cause to match them up.
2

In fact, the default output that the comma is after the superscript 3 is suitable since the comma is used for the entire equation. But if you want the output as you like, see the following three ways:

\begin{equation*}P=50,210,000\left(\frac{t}{D}\right)^3\!\!\!,\end{equation*}%just to add 2 more \!
\begin{equation*}P=50,210,000\left(\frac{t}{D}\right)^3\hspace{-0.23cm},\end{equation*}%the value can be reset as you like
\begin{equation*}P=50,210,000\left(\frac{t}{D}\right)^3\kern-0.25cm,\end{equation*}%the value can be reset as you like

The output is as follows:

enter image description here

And if you use them frequently, you can define a command as follows:

\newcommand{\equationcomma}{\!\!\!,}
\newcommand{\equationcomma}{\hspace{-0.23cm}}
\newcommand{\equationcomma}{\kern-0.25cm}

You must log in to answer this question.

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