我想知道是否有可能有一个开关(例如\myswitch
):
1-改变下划线的行为_
仅在数学模式下这样所有后续字符都将分组为单个下标,同时在遇到第一个空格时终止下标处理。
2-本地影响父环境或组内的数学模式,而不会与其打开的父环境或组之外的任何数学内容进行交互。
3- 接受可选的换行命令。例如,表示默认情况下\myswitch[1][\mathit]
所有下标都换行,并且只要开关打开,就不会格式化下标但会将下标字符分组。\mathit{<all the subscript characters>}
\myswitch[]
4- 当下标被一对花括号括起来时,能够在下标中包含空格,而不将其视为终止字符{}
。
例如,
\documentclass{article}
\usepackage{mathtools}
\usepackage[margin=1cm]{geometry}
\parindent0pt
\begin{document}
Before switching it on\\
\verb|$A_BCD$| should yield the same output of \verb|$A_B CD$|\\
Enabling the switch inside an environment or group\\
\verb*|\begin{some environemnt} or \begingroup|\\
Switch it on here\\
\verb|$A_BCD E_FGH$| should yield the same output of \verb|$A_\mathit{BCD} E_\mathit{FGH}$|\\
Change the default \verb|\mathit| to wrap the subscript in, for example, \verb|\mathrm|\\
\verb|$A_BCD E_FGH$| should yield the same output of \verb|$A_\mathrm{BCD} E_\mathrm{FGH}$|\\
Spaces can be included if the subscript is wrapped in a pair of curly braces\\
\verb|$A_{B CD}$| will yield the same output of \verb|$A_\mathit{B CD}$|\\
Disabling the default optional argument will remove the effect of \verb|\mathit|\\
\verb|$A_BCD E_FGH$| should yield the same output of \verb|$A_{BCD} E_{FGH}$|\\
\verb*|\end{some environemnt} or \endgroup|\\
Even it is left switched on in another environment/group, it has no effect outside it\\
\verb|$A_BCD$| should yield the same output of \verb|$A_B CD$|\\
\end{document}