“$d=2$維”中的間距

“$d=2$維”中的間距

如果我想寫「d=3維」這樣的片語,正確的間距是多少?

如果我只寫$d=1$-dimensional,等號周圍的間距對我來說似乎太寬了?

在此輸入影像描述

(也許「-」周圍的間距也可能有點太小了?)

(我想用這個公式巧妙地提醒讀者,$d$本文中稱為輸入維度,同時告訴讀者當前部分只處理一維情況。)

例子:

\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:也許還應該添加一些反對連字符的東西,就像這裡提到的:避免“2-D”中的連字符。如果這已經包含在答案中那就太好了。

答案1

在 @Mico 的程式碼的基礎上,在 的幫助下xparse,我提出了一個\Diml命令,其中 = 符號周圍的間距更緊密,並且參數以更自然的方式輸入,因為 d = 某個值。當然,根據您的喜好調整間距很容易。

\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} 

在此輸入影像描述

答案2

假設您已經加載了該amsmath包,我將利用它的指令來確保和\nobreakdash之間永遠不會出現換行符。2-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}

相關內容