I've seen the three questions related to using $ around numbers/mathematical numerals in text outside of equations: When to use math mode?; Numbers outside Math environment; and What is the Necessity of $...$ Around Numbers?

I have the following expression in a paragraph and I wish to avoid different glyphs for the numbers if I change the font:

contour levels at ($-2$, 2, 4, 8, 16 and~32)~$\times$~0.348$\sigma$

Would any of these below be recommended to achieve this (and ensure if it breaks across two lines that breaking occurs before the and)?

($-2$, $2$, $4$, $8$, $16$ and~$32$)~$\times$~$0.384\sigma$

($-2$, $2$, $4$, $8$, $16$ and~$32$)~$\times~0.384\sigma$

$(-2, 2, 4, 8, 16$ and~$32) \times 0.384\sigma$

or possibly using \text{} as suggested by marmot:

$(-2, 2, 4, 8, 16\text{ and }32) \times 0.384$
  • 1
    Welcome to TeX.SE! Most likely someone will give you an answer that you'll like, but perhaps you might consider adding $(-2, 2, 4, 8, 16\text{ and }32) \times 0.384$ to your list. In this example this is not too obvious, but if you consider e.g. $\left(-2, \frac{2+\frac{1}{7}}{3}, 4, 8, 16\text{ and }32\right) \times 0.384$ then you see that at least in some situations this is "better" since it allows you to let LaTeX adjust the brackets. – user121799 Feb 25 '18 at 3:46
  • 1
    It would help if you indicated what (-2, 2, 4, 8, 16, 32) denotes. Is it a row vector (an n-tuple), a collection of 6 scalar numbers, or something else still? The presence of the word "and" between "16" and "32" makes your example somewhat ambiguous in this regard. – Mico Feb 25 '18 at 6:10
  • 1
    @marmot -- there's a possibly great disadvantage to the code you suggest. unless it nicely falls completely in the middle of a line, it will break only after the \times. a string in \text won't break either -- it follows the math rules. – barbara beeton Feb 26 '18 at 15:09
  • @barbarabeeton I fully agree with what you're saying. Note, however, that I was not suggesting to necessarily use this code, I was proposing to add this to the list such that someone like you could discuss all the pros and cons of the different possibilities. – user121799 Feb 26 '18 at 15:13
  • @Mico this expression would be the equivalent of "contour levels at $-0.768$, 0.768, 1.536, 3.072, 6.144 and 12.288." (each value a multiple of sigma) – jacinta989 Feb 27 '18 at 5:43

With xparse and expl3 you can get an easier syntax for input.


  \seq_set_from_clist:Nn \l_jacinta_numlist_in_seq { #1 }
  \seq_set_map:NNn \l_jacinta_numlist_out_seq \l_jacinta_numlist_in_seq { $##1$ }
  \IfValueT{#2}{ $($ }
  \seq_use:Nnnn \l_jacinta_numlist_out_seq
   { ~ and \nobreakspace } % two items
   { ,~ }                  % between items
   { ~ and \nobreakspace } % last two
  \IfValueT{#2}{ $)#2$ }
\seq_new:N \l_jacinta_numlist_in_seq
\seq_new:N \l_jacinta_numlist_out_seq


Contour levels at \numlist{-2, 2, 4, 8, 16, 32}[\times0.348\sigma].

Contour levels at \numlist{-2, 2, 4, 8, 16, 32}.

Contour levels at \numlist{-2, 2}[\times0.348\sigma].


enter image description here

| improve this answer | |
  • In case the numbers to be printed are not integers, one can use \num{##1} instead of $##1$ (requires \usepackage{siunitx}). – egreg Apr 9 '18 at 8:10

(Thanks for providing a comment with some additional information about the intended use and meaning of your code fragment.)

Since you're talking about five different contour levels, they're (logically speaking) not part of one and the same "formula". I'd therefore say that

($-2$, $2$, $4$, $8$, $16$ and~$32$)\hspace{0pt}${}\times0.384\sigma$

enter image description here

is the most appropriate form. (Feel free to add an "Oxford comma".) This makes TeX insert ordinary interword whitespace between the numbers in the parenthetic construct, it allows a line break after the closing parenthesis, and it provides for the right amount of spacing around the \times symbol if no linebreak occurs.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.