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? – Teepeemm Feb 19 '23 at 15:16\begin{tabular}{>{$}l<{$} >{$}l<{$}}to work, even without a new environment. What are you trying to accomplish with that part? – Teepeemm Feb 20 '23 at 02:43align. The columns in thetabularenvironment avoid writing$in every line of the table. – DAGO Feb 20 '23 at 04:02arraythough ... – Joseph Wright Feb 20 '23 at 06:49\resis not defined. // so please write a minimal working example (See link for more details what it means) if you still need help. – user202729 Feb 20 '23 at 08:55\res,\why, and\To, I can get your two snippets to compile without any errors. So I'll echo the request to please extend this into a minimal working example. – Teepeemm Feb 20 '23 at 22:02\documentclassand ends with\end{document}, so that we can copy/paste and see the output that you see. I get your two snippets to compile without any errors. – Teepeemm Feb 21 '23 at 14:51