# Typesetting Hermann-Mauguin notation correctly

Hermann--Mauguin notation is used to define a naming scheme for three-dimensional space groups (aka crystallographic groups). A list of these groups together with their names can be found here. I would like to know how to typeset these names correctly.

Judging from the names presented in the International Tables for Crystallography (Vol. A), it seems that the first letter is printed in math mode, between each number there is a tiny bit of space, and the numbers are exactly the same size as the initial letter.

If I typeset the full name in math mode, the spacing is not correct and also the size of the letter and the other symbols is different. If I use text mode it's the same situation with the additional problem that the names are printed in bold face if used in a heading.

What's The Right Way to typeset Hermann-Mauguin notation?

• I am sorry, but it is not clear to me what typeset output you are seeking. – Steven B. Segletes Nov 4 '15 at 11:03

This might be a starting point: - denotes an overline above the next digit (multidigit numbers should be braced), * denotes the “fraction” with denominator m applied to the next digit, i denotes infinity.

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


## Second step, adding thin spaces between items

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

A mapping is done on the token list; items * and - are substituted by macros taking two arguments (one will be \, from the following item), while i is substituted by \,\infty` and similarly digits (or braced groups of digits). Next the list is delivered.