빈 l3seq 시퀀스에 대해 `Missing = insert for \ifnum` 오류가 발생하는 이유는 무엇입니까?

빈 l3seq 시퀀스에 대해 `Missing = insert for \ifnum` 오류가 발생하는 이유는 무엇입니까?

expl3데이터베이스에 저장된 1명 이상의 저자에 대해 0, 1개 이상의 소속을 저장하기 위해 시퀀스를 사용하려고 합니다 datatool. 다음 MWE는 훌륭하게 작동합니다.

\documentclass{article}
\usepackage{xparse}
\usepackage{datatool}

\ExplSyntaxOn

\DTLnewdb{_mymodule_authors}

\seq_new:N \g_mymodule_author_affiliations_seq

\keys_define:nn { mymodule/authors }
{
  affiliation .code:n = \seq_gput_right:Nn \g_mymodule_author_affiliations_seq {#1}
}

\cs_new_protected:Nn \_mymodule_authors:nn
{
  \DTLnewrow{_mymodule_authors}
  \DTLnewdbentry{_mymodule_authors}{name}{#1}
  \DTLnewdbentry{_mymodule_authors}{affiliations}{#2}
}

\cs_generate_variant:Nn \_mymodule_authors:nn { nV }

\RenewDocumentCommand \author { o m } {
  \IfValueTF {#1}
  {
    \keys_set:nn { mymodule/authors } { #1 }
    \_mymodule_authors:nV {#2}{\g_mymodule_author_affiliations_seq}
  }
  {
    \_mymodule_authors:nV {#2}{\c_empty_tl}
  }
  \seq_gclear:N \g_mymodule_author_affiliations_seq
}

\NewDocumentCommand \showauthors {  } {
  \DTLforeach*{_mymodule_authors}{
    \l_tmpa_tl=name,
    \l_tmpa_seq=affiliations
  }{
    \mymodule_display_author:nn {\l_tmpa_tl}{\l_tmpa_seq}
    \DTLiflastrow{
    }{
      \DTLpar
    }
  }
}

\cs_new_protected:Nn \mymodule_display_author:nn
{
  #1
  \seq_if_empty:NF {\l_tmpa_seq}
  {
    \space(\seq_use:Nn \l_tmpa_seq { ,~ })
  }
}

\ExplSyntaxOff

\begin{document}
%\author{Foo, Bar 0}
\author[affiliation=Blah]{Foo, Bar 1}
\author[affiliation=Bleh,affiliation=Blih]{Foo, Bar 2}
\author[affiliation=Bloh,affiliation=Bluh,affiliation=Blyh]{Foo, Bar 3}
%
\showauthors
\end{document}

\author{Foo, Bar 0}하지만 소속이 0인 작성자에 대해 댓글을 달자마자 이해할 수 없는 다음과 같은 오류가 발생합니다.

! Missing = inserted for \ifnum.
<to be read again> 
                   {

답변1

시퀀스는 V단일 고유 값이 없기 때문에 지정자에 대한 인수로 사용할 수 없습니다.

따라서 데이터베이스에 시퀀스를 저장하는 대신바늘시퀀스로. 포인터로서 저자 이름의 "문자열화된" 버전을 사용합니다.

\documentclass{article}
\usepackage{xparse}
\usepackage{datatool}

\ExplSyntaxOn

\DTLnewdb{_mymodule_authors}

\seq_new:N \l_mymodule_author_affiliations_seq

\keys_define:nn { mymodule/authors }
 {
  affiliation .code:n = \seq_put_right:Nn \l_mymodule_author_affiliations_seq {#1}
 }

\cs_new_protected:Nn \_mymodule_authors:n
 {
  \DTLnewrow{_mymodule_authors}
  \DTLnewdbentry{_mymodule_authors}{name}{#1}
  \DTLnewdbentry{_mymodule_authors}{affiliations}{\tl_to_str:n{#1}}
 }

\RenewDocumentCommand \author { O{} m }
 {
  \seq_clear:N \l_mymodule_author_affiliations_seq
  \keys_set:nn { mymodule/authors } { #1 }
  \_mymodule_authors:n {#2}
  \seq_new:c { g_mymodule_affiliation_ \tl_to_str:n{#2} _seq }
  \seq_gset_eq:cN { g_mymodule_affiliation_ \tl_to_str:n{#2} _seq } \l_mymodule_author_affiliations_seq
 }

\NewDocumentCommand \showauthors {  }
 {
  \DTLforeach*{_mymodule_authors}
   {
    \l_tmpa_tl=name,
    \l_tmpb_tl=affiliations
   }
   {
    \mymodule_display_author:VV \l_tmpa_tl \l_tmpb_tl
    \DTLiflastrow { }{ \DTLpar }
   }
 }

\cs_new_protected:Nn \mymodule_display_author:nn
 {
  #1
  \seq_if_empty:cF { g_mymodule_affiliation_#2_seq }
  {
   \c_space_tl(\seq_use:cn { g_mymodule_affiliation_#2_seq } { ,~ })
  }
 }

\cs_generate_variant:Nn \mymodule_display_author:nn { VV }

\ExplSyntaxOff

\begin{document}
\author{Foo, Bar 0}
\author[affiliation=Blah]{Foo, Bar 1}
\author[affiliation=Bleh,affiliation=Blih]{Foo, Bar 2}
\author[affiliation=Bloh,affiliation=Bluh,affiliation=Blyh]{Foo, Bar 3}

\showauthors
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보