0

I'm trying to make the following code compile. It does work if I don't put any & in my environment, but if I do I get an error:

ERROR: Argument of \environment pral  has an extra }
--- TeX said ---
<inserted text> 
                \par 
l.20   \end{align}

Sadly I do need to put & inside. Any solution?

Thanks!

\documentclass{article}
\usepackage{mathtools}

\usepackage{xparse}
\NewDocumentEnvironment{pral}{sob}{%
  \Pr\IfValueT{#2}{_{\IfBooleanTF{#1}{\substack{#2}}{#2}}}\begin{alignedat}[t]{2}[\,#3\,]\end{alignedat}
}{}

\begin{document}
\begin{align}
  &
    \begin{pral}[a \leftarrow \{0,1\}]
      % works without the & on the next two lines:
      &\forall x\\
      &a \geq \delta      
    \end{pral}\\
  &\geq \eta
  \end{align}
\end{document}
0
2

You don't need the b argument, which should only be used when really necessary.

\documentclass{article}
\usepackage{mathtools}

\usepackage{xparse}

\NewDocumentEnvironment{pral}{so}
 {%
  \Pr\IfValueT{#2}{_{\IfBooleanTF{#1}{\substack{#2}}{#2}}}
  \begin{alignedat}[t]{2}[\,
 }
 {\,]\end{alignedat}}

\begin{document}
\begin{align}
  &
    \begin{pral}[a \leftarrow \{0,1\}]
      &\forall x\\
      &a \geq \delta
    \end{pral}\\
  &\geq \eta
  \end{align}
\end{document}

enter image description here

3
  • Thanks! But could you ellaborate a bit more on why the b is an issue here? What should I do if I really need this b?
    – tobiasBora
    Mar 30 '20 at 9:29
  • @tobiasBora The problem is that with the b argument type, the & are not hidden from the scanner. I see no real need for it, do you?
    – egreg
    Mar 30 '20 at 9:33
  • I don't think I need any no, I'm just curious to understand. Thanks!
    – tobiasBora
    Mar 30 '20 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.