The problem is that you can't end a line when \mathsf
has not yet ended.
Decide where the breaks should go and add \mathsf
:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{aligned}
X^{(0)} = \lbrace
& \mathsf{PR \ R \ ST0 \ T{+} \ TP \ PR, \ PR \ R \ ST{-} \ T{-} \ TP \ PR,} \\
& \mathsf{PR \ rs \ ST0 \ T{-} \ TP \ PR, \ PR \ rS \ ST{+} \ T{+} \ TP \ PR,} \\
& \mathsf{PR \ Rs \ ST{+} \ T{+} \ TP \ PR} \rbrace
\end{aligned}
\end{equation*}
\end{document}
Note also {+}
and {-}
in order not to get bad spacing. I believe it's conceptually preferable to use aligned
rather than align*
. Also I wouldn't space the commas.

A more complicated setting, but ending in simpler input, with the same output.
\documentclass{article}
\usepackage{amsmath}
\newcommand{\entity}[1]{%
\mathsf{%
\catcode`\ =12
\begingroup\lccode`~=`\ \lowercase{\endgroup\def~{\mathclose{\ }}}%
\scantokens{#1\empty}%
}%
}
\begin{document}
\begin{equation*}
\begin{aligned}
X^{(0)} = \lbrace
& \entity{PR R ST0 T+ TP PR}, \entity{PR R ST- T- TP PR}, \\
& \entity{PR rs ST0 T{-} TP PR}, \entity{PR rS ST{+} T{+} TP PR}, \\
& \entity{PR Rs ST{+} T{+} TP PR} \rbrace
\end{aligned}
\end{equation*}
\end{document}
With less tricky code: we split the input at spaces, then reinsert \mathclose{\ }
at their place; different spacings can be obtained by changing the argument to \mathclose
.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\entity}{m}
{
\seq_set_split:Nnn \l_piotr_entity_seq { ~ } { #1 } %split at spaces
\mathsf
{
\seq_use:Nn \l_piotr_entity_seq { \mathclose{\ } }
}
}
\ExplSyntaxOff
\begin{document}
\begin{equation*}
\begin{aligned}
X^{(0)} = \lbrace
& \entity{PR R ST0 T+ TP PR}, \entity{PR R ST- T- TP PR}, \\
& \entity{PR rs ST0 T{-} TP PR}, \entity{PR rS ST{+} T{+} TP PR}, \\
& \entity{PR Rs ST{+} T{+} TP PR} \rbrace
\end{aligned}
\end{equation*}
\end{document}
\mathsf
in the first line and then don't close it with}
before the end of the line marked by\\
. If you want to keep this approach of\mathsf
ying everything at once, you have to repeat it in every line ofalign*
.align*
. all braces are present and accounted for.\mathsf{ ... \\ ...}
causes the problem. If you want to do a general switch to mathsf (probably not, but if) then you have to repeat it, like\mathsf{ ... } \\ \mathsf{ ...}
.