尽可能多次扩展宏而不会出现错误

尽可能多次扩展宏而不会出现错误

我想使用该permute包来计算陪集。

以下是我目前所掌握的信息:

\documentclass{article}
\usepackage{expl3,xparse,permute}

\ExplSyntaxOn
% Create a new command to compute the right coset Hg, taking in the element and the set
%% Clear a local clist for use
%% For each element in the set (#2)
%%% Set the current permutation to the identity
%%% Set the current permutation to the one we are looking at in the iteration
%%% Compose it with the element we were given in #1 on the right
%% Type the clist; Print the clist
\NewDocumentCommand \PMTCosetR { m m } {
  \clist_clear:N \l_tmpa_clist
  \clist_map_inline:nn { #2 } {
    \pmtid          \pmtdo{##1}      \pmtdo{#1}  % compressed to avoid scrollbar on TeX.SX
    \clist_put_right:NV \l_tmpa_clist \pmtprint
  }
  \clist_show:N \l_tmpa_clist
  \ensuremath{\Big\{\clist_use:Nn \l_tmpa_clist {,}\Big\}}
}
\ExplSyntaxOff

\begin{document}
\PMTCosetR{(12)}{(),(123),(132)} \par
Expecting values:
\begin{itemize}
\item \pmt{(12)()}
\item \pmt{(12)(123)}
\item \pmt{(12)(132)}
\end{itemize}
\end{document}

关键问题实际上是将什么放入列表中:

The comma list \l_tmpa_clist contains the items (without outer braces):
>  {\pmt@GetPrintArgs {\pmt@PrintPmt \pmt@curr }}
>  {\pmt@GetPrintArgs {\pmt@PrintPmt \pmt@curr }}
>  {\pmt@GetPrintArgs {\pmt@PrintPmt \pmt@curr }}.

不幸的是,更改适当的 argspec ( V|ox) 会导致错误:

ERROR: Undefined control sequence.

--- TeX said ---
\pmt@GetPrintArgs #1->\let \pmt@order 
                                      \pmtprintorder \def \pmt@next {#1}\@if...
l.27 \PMTCosetR{(12)}{(),(123),(132)}

我认为一定有办法控制扩展的次数\pmtprint,因为一次扩展显然不够。我可以精确地扩展两次吗?三次?“根据需要”扩展多少次,无论多少次方法?

答案1

您必须计算构图,那么为什么在构建clist交付物时要尝试这样做呢?

我使用序列,因为它更有效率。

\documentclass{article}
\usepackage{expl3,xparse,permute}

\ExplSyntaxOn
\NewDocumentCommand \PMTCosetR { m m }
 {
  \seq_clear:N \l_tmpa_seq
  \clist_map_inline:nn { #2 }
   { \seq_put_right:Nn \l_tmpa_seq { \pmt{#1##1} } }
  \bigl\{\seq_use:Nn \l_tmpa_seq {,}\bigr\}
}
\ExplSyntaxOff

\begin{document}
$\PMTCosetR{(12)}{(),(123),(132)}$

Expecting values:
\begin{itemize}
\item \pmt{(12)()}
\item \pmt{(12)(123)}
\item \pmt{(12)(132)}
\end{itemize}
\end{document}

在此处输入图片描述

相关内容