答案1
这可能是一个起点:-
表示下一位数字上方的上划线(多位数字应该用括号括起来),*
表示将分母 m 应用于下一位数字的“分数”,i
表示无穷大。
\documentclass{article}
\newcommand{\hmn}[1]{% Hermann-Maguin notation
\ensuremath{\begingroup\setupHMN #1\endgroup}%
}
\newcommand{\setupHMN}{%
\doHMN{-}{\HMNoverline}%
\doHMN{*}{\HMNminverse}%
\doHMN{i}{\infty}
}
\newcommand{\doHMN}[2]{%
\begingroup\lccode`~=`#1
\lowercase{\endgroup\let~}#2%
\mathcode`#1="8000
}
\newcommand{\HMNminverse}[1]{\frac{#1}{m}}
\newcommand{\HMNoverline}[1]{\mkern1mu\overline{\mkern-1mu#1\mkern-1mu}\mkern1mu}
\begin{document}
\hmn{-6}\quad
\hmn{*4}\quad
\hmn{8mm}\quad
\hmn{im}\quad
\hmn{-3 *2}\quad
\hmn{-4 2 m}\quad
\hmn{*i m}\quad
\hmn{-3m-2-{10}}
\[
\hmn{-6}\quad
\hmn{*4}\quad
\hmn{8mm}\quad
\hmn{im}\quad
\hmn{-3 *2}\quad
\hmn{-4 2 m}\quad
\hmn{*i m}\quad
\hmn{-3m-2-{10}}
\]
\end{document}
第二步,在项目之间添加细小的空间
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\hmn}{m}
{
\ensuremath
{
\hermannmauguin_group:n { #1 }
}
}
\tl_new:N \l_hermannmauguin_input_tl
\tl_new:N \l_hermannmauguin_output_tl
\cs_new_protected:Nn \hermannmauguin_group:n
{
\tl_set:Nn \l_hermannmauguin_input_tl { #1 }
\tl_clear:N \l_hermannmauguin_output_tl
\tl_map_inline:Nn \l_hermannmauguin_input_tl
{
\__hermannmauguin_item:n { ##1 }
}
\! % kill the first \,
\tl_use:N \l_hermannmauguin_output_tl
}
\cs_new_protected:Nn \__hermannmauguin_item:n
{
\str_case:nnF { #1 }
{
{*}{ \__hermannmauguin_put:n { \__hermannmauguin_inverse:Nn } }
{-}{ \__hermannmauguin_put:n { \__hermannmauguin_overline:Nn } }
{i}{ \__hermannmauguin_put:n { \,\infty } }
}
{ \__hermannmauguin_put:n { \, {#1} } }
}
\cs_new_protected:Nn \__hermannmauguin_put:n
{
\tl_put_right:Nn \l_hermannmauguin_output_tl { #1 }
}
\cs_new_protected:Nn \__hermannmauguin_overline:Nn
{% #1 should be \,; #2 is the number to operate on
#1 \mkern1mu\overline{\mkern-1mu#2\mkern-1mu}\mkern1mu
}
\cs_new_protected:Nn \__hermannmauguin_inverse:Nn
{% #1 should be \,; #2 is the number to operate on
#1 \frac{ #2 } { m }
}
\ExplSyntaxOff
\begin{document}
\hmn{-6}\quad
\hmn{*4}\quad
\hmn{8mm}\quad
\hmn{im}\quad
\hmn{-3 *2}\quad
\hmn{-4 2 m}\quad
\hmn{*i m}\quad
\hmn{-3m-2-{10}}
\[
\hmn{-6}\quad
\hmn{*4}\quad
\hmn{8mm}\quad
\hmn{im}\quad
\hmn{-3 *2}\quad
\hmn{-4 2 m}\quad
\hmn{*i m}\quad
\hmn{-3m-2-{10}}
\]
\end{document}
在标记列表上进行映射;项*
和-
被带有两个参数的宏替换(一个参数来自\,
以下项),而i
被\,\infty
和类似数字(或带括号的数字组)替换。接下来传递列表。