Spacing in “$d=2$-dimensional”

What is the correct spacing if I want to write phrases like "d=3-dimensional".

If I just write $d=1$-dimensional, the spacing around the equal-sign seems to be way too wide for me?

(Maybe also the spacing around the "-" could be a little bit too small?)

(I want to use this formulation to subtly remind the reader that the input dimension is called $d$ in this text, while telling that the current sections only deals with the 1-dimensional case.)

Example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\newcommand{\R}{\mathbb{R}}
\begin{document}
Define a neural network $\mathcal{NN}_\theta$ as a function from $X=\R^d$ to $Y=\R$ s.t.

$\mathcal{NN}_\theta (x)=\dots defintion \dots \quad\forall x\in X$

For the rest of the section only the the $d=1$-dimensional case is considered.
\end{document}


(PS: Probably one should also add something against hyphenation, like mentioned here: Avoid hyphenation in "2-D". It would be nice if this were already included in the answer.)

• It's probably because you're writing $d = 1$-dimensional, which psychologically leaves the 1 separated from dimensional. How about $d = \text{$1$-dimensional}$. It'll look the same, but you'll feel better about it. ;) You can also just write it out: $d$ is $1$-dimensional. – Werner Aug 15 at 17:31
• $d=1$ where $d$ is the number of dimensions [... and thus we have a 1-dimensional ... (motion or something)] or If we name $d$ the number of dimensions we have... (Just realized that used my Greek approach in this second sentence... Usually in English scientific/tutoring formal texts "we don't use 'we' ") – koleygr Aug 15 at 17:43
• To suppress line-breaking after the hyphen, amsmath provides the command \nobreakdash. See p.14 of the amsmath user guide (texdoc amsmath). – barbara beeton Aug 15 at 18:02
• I feel like $d=1$-dimensional isn't grammatical to begin with, and that reflects itself in your typesetting difficulties. (Also not that the first two comments misinterpreted your intent, which suggests that your notation isn't intuitive.) An equation is grammatically a sentence, which can't modify "dimensional". I would recommend "Within this section, $d=1$." – Teepeemm Aug 15 at 18:44
• "For the rest of this section only the case of dimension $d=1$ is considered." – Andrew Swann Aug 16 at 7:40

Building on @Mico's code, with the help of xparse, I propose a \Diml command, in which the spacing around the = sign is tighter, and the argument is input in a more natural way, as d = some value. It is of course easy to adjust the spacing to your taste.

\documentclass{article}
\usepackage{amsmath} %
\usepackage{xparse}
\newcommand{\Diml}[1]{\dimlargs{#1}}
\NewDocumentCommand{\dimlargs}{>{\SplitArgument{1}{=}}m}
{\dimlargsaux#1}
\NewDocumentCommand{\dimlargsaux}{mm}{%
\text{$#1\mkern2mu{=}\mkern2mu#2$\nobreakdash-dimensional}}%

\begin{document}

$\Diml{d=1},\;\Diml{e = n }$

\end{document}


• This post fits my personal taste, but I would be interested in some comments if this is good typography? Ideally some references how other authors use this notation? Is this notation easily understandable or should I switch to other formulations like "only the case of dimension $d=1$ is considered" (by @Andrew Swann) or "in the case of input dimension $d=1$ ..."? – Jakob Aug 20 at 12:57
• Good typography is the art of making things easy to read. I have no particular references, albeit I've often met this way of formulating things – it's a sort of usual ellipsis, but I guess most authors don't care about the exact spacing – they're mathematicians, after all, not typographers, and they trust TeX to do the job. – Bernard Aug 20 at 13:15

Assuming you've loaded the amsmath package, I would make use of its \nobreakdash directive to make sure there's never a line break between 2- and dimensional.

\documentclass{article}
\usepackage{amsmath} % for \nobreakdash and \text macros
%% Define a macro that takes an optional argument;
%% default value of optional argument is '2'.
\newcommand\diml[1][2]{\text{$#1$\nobreakdash-dimensional}}

\begin{document}
$d=\diml$, $d=\diml[3]$, $d=\diml[n]$
\end{document}

• is this good spacing? I would have expected the preferable spacing to be much narrower around the "="? – Jakob Aug 15 at 18:07
• @Jakob - The spacing around the = symbo in question is exactly the same as around all other = symbols in text-style and display-style math mode. You'll automatically get less spacing when in script-style and scriptscript-style math mode. – Mico Aug 15 at 18:09
• In this case I’d agree with @Jakob that it is much too much space. With the current spacing it could easily be read as “the variable d equals the string 2-dimensional” instead of a single word d-two-dimensional. Thus I’d narrow the spacing around the = down to nearly zero. However it might be even better to find a different notation for this. Maybe something like 2-dimensional (d=2) – Tobi Aug 15 at 18:23