[Tex/LaTex] Create a new math mode

math-mode

Motivation

When I use math mode inside of itemize environments for multiline equations, I have to do something like the following

...
\begin{itemize}
  \item $\begin{aligned}[t]
    equation stuff
  \end{aligned}$
  ...
\end{itemize}
...

Question

How can I wrap the two components $\begin{aligned}[t] and \end{aligned}$ into a new symbol, e.g. §? I'd like to write the above example as

...
\begin{itemize}
  \item §equation stuff§
  ...
\end{itemize}
...

It is favorable for the solution to be robust.


(It is not required for the new symbol to be §.)

Best Answer

The \catcode`§=\active method won't work if the document declares

\usepackage[utf8]{inputenc}

because § is a two byte character in UTF-8. For this case you can use

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\usepackage{newunicodechar}
\newunicodechar{§}{\mymath}
\def\mymath#1§{$\begin{aligned}[t] #1\end{aligned}$}

\newenvironment{itemalign}
  {$\aligned[t]}
  {\endaligned$}

\begin{document}
\begin{itemize}
\item §x&=2\\y&=6§
\item \begin{itemalign}x&=2\\y&=6\end{itemalign}
\end{itemize}
\end{document}

that has the advantage of working also with LuaLaTeX and XeLaTeX (where the call to inputenc should not be present).

However, I'd recommend using the new environment method.

enter image description here

Related Question