I found a very specific formatting error: when I use lstinline[mathescape]
inside an align
environment, some of the basic math formatting like subscripting stops working. It does however work in e.g., an equation
environment. The strange thing is that when I don't load the syntax
package, this bug does not occur.
A complete minimal example that reproduces the problem:
\documentclass{article}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{syntax}
\begin{document}
\begin{align*}
e_1 \mapsto \lstinline[mathescape]|Stream.of($e_1$)|
\end{align*}
\begin{equation*}
e_1 \mapsto \lstinline[mathescape]|Stream.of($e_1$)|
\end{equation*}
\end{document}
As you can see, the subscription inside the align envirnoment doesn't work.
Is there a way to resolve this error cleanly? What is causing it?
EDIT Based on @UlrikFisher's comment, I could find a workaround specifically for the underscore. Unfortunately, this workaround does not work for other macros. Here is a more complete example:
\documentclass{article}
\usepackage{amsmath}
\usepackage{listings}
\usepackage[nounderscore]{syntax}
\usepackage[shorthand]{semantic}
\begin{document}
\begin{align*}
e_1 \mapsto \lstinline[mathescape]+Stream.of($|[e_1|]$)+
\end{align*}
\begin{equation*}
e_1 \mapsto \lstinline[mathescape]+Stream.of($|[e_1|]$)+
\end{equation*}
\end{document}
\usepackage[nounderscore]{syntax}
. Then the package will not redefine the underscore, something which seems to disturb listings.\usepackage{syntax}
everything works fine._
is made active not its usual math subscript meaning, so you get less lucky