\mathit 与 \textit 用于多字母标识符

\mathit 与 \textit 用于多字母标识符

我想在一个句子中包含多个用逗号分隔的双字母变量,但有时当我使用时,变量和其后的逗号之间会出现明显的空格mathit。虽然下面的 MWE 中的空格并不那么明显。

textit用代替是否更好mathit?如果是这样,我如何确保字体与使用相同字母的单字母变量匹配(例如$\textit{A}$)?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\textit{AB}, \textit{BA}, \textit{CD}, \textit{DC}

$\mathit{AB}$, $\mathit{BA}$, $\mathit{CD}$, $\mathit{DC}$

$\textit{AB}$, $\textit{BA}$, $\textit{CD}$, $\textit{DC}$
\end{document}

答案1

这不是一个答案,而是一个试图让你放弃这种想法的尝试。

更新这篇文章得到了一些更有经验的用户的反馈。我同意他们所有的说法,当然应该做更多的研究。然而,我也觉得他们的陈述进一步证明了所提出的符号不是最佳的。

\documentclass{article}
\usepackage{amsmath}
\newcommand\myvar[1]{\ensuremath{\mathit{#1}}}
\begin{document}
Your options 
\begin{itemize}
 \item \textit{AB}, \textit{BA}, \textit{CD}, \textit{DC}
 \item $\mathit{AB}$, $\mathit{BA}$, $\mathit{CD}$, $\mathit{DC}$
 \item $\textit{AB}$, $\textit{BA}$, $\textit{CD}$, $\textit{DC}$
\end{itemize}
look all the same. In fact, it seems that there is no noticable difference
between these options:\\
\verb|\makebox[0pt][l]{$\mathit{AB}$}$\textit{AB}$|: \makebox[0pt][l]{$\mathit{AB}$}$\textit{AB}$

However, things are different once you wrap these commands in other
environmants:\\
\verb|\textbf{$\mathit{AB}$}|: \textbf{$\mathit{AB}$} vs.\\
\verb|\textbf{$\textit{AB}$}|: \textbf{$\textit{AB}$}\\
\verb|$\left(\mathit{AB}\right)$|: $\left(\mathit{AB}\right)$ vs.\\
\verb|$\left(\textit{AB}\right)$|: $\left(\textit{AB}\right)$

Even the pure math version looks very similar:\\
\verb|\makebox[0pt][l]{$\mathit{AB}$}$AB$|: \makebox[0pt][l]{$\mathit{AB}$}$AB$ 

However, the pure math version comes with different distances:\\
\verb|\makebox[0pt][l]{$\mathit{BA}$}$BA$|: \makebox[0pt][l]{$\mathit{BA}$}$BA$\\
\verb|\makebox[0pt][l]{$\mathit{BA}$}$\textit{BA}$|: \makebox[0pt][l]{$\mathit{BA}$}$\textit{BA}$

You may come up with a command that distinguishes netween math and nonmath
modes: \verb|\newcommand\myvar[1]{\ensuremath{\mathit{#1}}}|

Under boldface, this seems to behave like a math variable should:\\
\verb|\textbf{\myvar{AB}}|: \textbf{\myvar{AB}}\\
\verb|\textbf{$\myvar{AB}$}|: \textbf{$\myvar{AB}$}\\
\verb|\boldmath$\myvar{AB}$\unboldmath|: \boldmath$\myvar{AB}$\unboldmath\\
\verb|\boldmath\myvar{AB}\unboldmath|: \boldmath\myvar{AB}\unboldmath

The main reason for this point is to question whether it is a very wise move to
use this notation. Many people use $AB$ to indicate the
product $A\cdot B$, and $AB$ is virtually indistinguishable from your variable
\myvar{AB}. (I personally write $A\,B$, but get sometimes criticized.)

\paragraph{Bottomline:} Perhaps it is better to use a different notation.
\end{document}

在此处输入图片描述

相关内容