
是否有一個全域巨集可用於在整個文件中存在的數學中的每個上標和下標之前自動添加空格。
答案1
不能。
答案2
我是該包的作者替代子集當與方括號(如_[...]
或 )一起使用時,它提供了下標和上標的替代格式^[...]
。
您可以定義自己的命令並使用
\newcommand*{\mysubsupformat}[1]{\,#1}% add a thin space
\SetAltSubSupCommands{\mysubsupformat}
然後,所有用方括號書寫的下標和上標都將使用指令進行格式化\mysubsupformat
。
完整範例
\documentclass{article}
\usepackage{amsmath}% for align*
\usepackage{altsubsup}
\newcommand*{\mysubsupformat}[1]{\,#1}% add a thin space
\SetAltSubSupCommands{\mysubsupformat}
\begin{document}
\begin{align*}
x_a & & x^b & & x_a^b \\
x_[a] & & x^[b] & & x_[a]^[b]
\end{align*}
\end{document}
但也許您不想重寫整個文件。自從替代子集^
套件將和的原始定義保存_
在\altsbsp@standardsub
和中\altsbsp@standardsup
,您可以嘗試破解它們(\AtBeginDocument
因為它們是在那裡創建的,並且使用\maketatletter
和來處理巨集名稱中的\makeatother
字元):@
\makeatletter
\AtBeginDocument{%
\let\rampsmart@standardsub\altsbsp@standardsub
\def\altsbsp@standardsub#1{\rampsmart@standardsub{\,#1}}% add a thin space
\let\rampsmart@standardsup\altsbsp@standardsup
\def\altsbsp@standardsup#1{\rampsmart@standardsup{\,#1}}% add a thin space
}
\makeatother
完整範例:
\documentclass{article}
\usepackage{amsmath}% for align*
\usepackage{altsubsup}
\makeatletter
\AtBeginDocument{%
\let\rampsmart@standardsub\altsbsp@standardsub
\def\altsbsp@standardsub#1{\rampsmart@standardsub{\,#1}}% add a thin space
\let\rampsmart@standardsup\altsbsp@standardsup
\def\altsbsp@standardsup#1{\rampsmart@standardsup{\,#1}}% add a thin space
}
\makeatother
\begin{document}
\begin{align*}
x_a & & x^b & & x_a^b
\end{align*}
\end{document}
顯然,在這種情況下不要使用方形,它們會被破壞。