I want to define an environment that uses two optional arguments, but i want to be able to use one with <> and the other with []
Here is what I have done:
\NewDocumentCommand\why{O{\equiv}m}%
{ #1 & \quad\langle\;\text{{#2}}\;\rangle }
\NewDocumentCommand\res{m}%
{ & #1}
\NewDocumentCommand\To{}{\Rightarrow}
\NewDocumentEnvironment{derivation}{D<>{1.2} O{0pt}}{
\begingroup
\renewcommand{\arraystretch}{#1}
\setlength{\tabcolsep}{#2}
\begin{tabular}{>{$}l<{$} >{$}l<{$}}
}{
\end{tabular}
\endgroup
}
When I try to use any of the optional arguments either they print in the pdf or I just get an error. How can I fix this?
The code of the example is:
\documentclass{article}
\usepackage{xparse}
\usepackage{mathtools}
\usepackage{nicematrix}
\usepackage[spanish]{babel}
\ExplSyntaxOn
\NewDocumentCommand\why{O{\equiv}m}%
{ #1 & \quad\langle\;\text{{#2}}\;\rangle }
\NewDocumentCommand\res{m}%
{ & #1}
\NewDocumentCommand\To{}{\Rightarrow}
\NewDocumentEnvironment{derivation}{D<>{1.2} O{0pt}}{
\renewcommand{\arraystretch}{#1}
\setlength{\tabcolsep}{#2}
\begin{tabular}{>{$}l<{$} >{$}l<{$}}
}{
\end{tabular}
}
\ExplSyntaxOff
\begin{document}
\begin{center}
\begin{derivation}<1.5>
\res{ (p \To \neg q) \land (\neg q \To \neg p) }\\
\why[\To]{ Transitividad($\To$) }\\
\res{ p \To \neg p }\\
\why{ Def.(alt)($\To$) }\\
\res{ \neg p \lor \neg p }\\
\why{ Idempotencia($\lor$) }\\
\res{ \neg p }
\end{derivation}
\end{center}
\end{document}
Apparently, the issue is the babel package.


\begingroup/\endgroupalready comes with an environment, I don't think you need it. More importantly, (2) if the arguments are optional, what should happen if they're not given? Can you show us how you're trying to use them, so that they print in the pdf or give you an error?\begin{tabular}{>{$}l<{$} >{$}l<{$}}to work, even without a new environment. What are you trying to accomplish with that part?align. The columns in thetabularenvironment avoid writing$in every line of the table.arraythough ...\resis not defined. // so please write a minimal working example (See link for more details what it means) if you still need help.