Redefine \S - problem with indices

You need \nolimits to force \mathop not to treat the operator like, for example, \sum.

\documentclass[a4paper,12pt,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman,english]{babel}
\usepackage{csquotes}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\let\origS\S\renewcommand{\S}{%
  \relax\ifmmode\mathop{\mathsf{S}}\nolimits\else\origS\fi}
\begin{document}
\begin{equation}\label{eqn:decS}
\S=\S_0 \oplus\S_1 .
\end{equation}
\[
\begin{pmatrix}\S\end{pmatrix}
\]
\end{document}

enter image description here


Assuming your command should be a \mathop, the correct redefinition would be

\renewcommand{\mathsection}{\operatorname{\mathsf{S}}

Redefining \S that way is bound to problems, as \S is a “robust” command.

If it is not an operator, \renewcommand{\mathsection}{\mathsf{S}} would suffice.

You can see the difference in the two examples below (twocolumn used just for making a smaller picture). In (1) the symbol behaves like an operator, in (2) it's an ordinary symbol.

\documentclass[a4paper,12pt,twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman,english]{babel}
\usepackage{csquotes}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}

\renewcommand{\mathsection}{\operatorname{\mathsf{S}}}

\begin{document}

\begin{equation}\label{eqn:decS}
\S=\S_0 \oplus\S_1 x.
\end{equation}

\renewcommand{\mathsection}{\mathsf{S}}

\begin{equation}
\S=\S_0 \oplus\S_1 x.
\end{equation}

\end{document}

enter image description here