错误:在 LaTeX3 中查找并存储作者名字、姓名首字母和姓氏值

错误:在 LaTeX3 中查找并存储作者名字、姓名首字母和姓氏值
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\keys_define:nn { balaji/author }
 {
  mail .tl_set:N = \l_balaji_mail_tl,
  mail .initial:n = {},
  web .tl_set:N = \l_balaji_web_tl,
  web .initial:n = {},
  address .tl_set:N = \l_balaji_address_tl,
  address .initial:n = {},
  firstname .tl_set:N = \l_balaji_firstname_tl,
  firstname .initial:n = {},
  initials .tl_set:N = \l_balaji_initials_tl,
  initials .initial:n = {},
  lastname .tl_set:N = \l_balaji_lastname_tl,
  lastname .initial:n = {},
  fullname .tl_set:N = \l_balaji_fullname_tl,
  key .tl_set:N = \l_balaji_key_tl,
  key .initial:n = {},
 }
\NewDocumentCommand\xauthor{ O{} m }
 {
  \group_begin:
  \keys_set:nn { balaji/author } { #1 }
  \keys_set:nn { balaji/author } { fullname = #2 }
  \balaji_define_author:n { #2 }
  \group_end:
 }

\cs_new_protected:Npn \balaji_define_author:n #1
 {
  \tl_if_empty:NT \l_balaji_lastname_tl
   {
    \seq_set_split:Nnn \l_balaji_author_seq { ~ } { #1 }
    \seq_pop_right:NN \l_balaji_author_seq \l_balaji_lastname_tl
    \seq_pop_left:NN \l_balaji_author_seq \l_balaji_firstname_tl
    \tl_set:Nx \l_balaji_initials_tl { \seq_use:Nn \l_balaji_author_seq { ~ } }
   }
  \tl_if_empty:NT \l_balaji_key_tl
   { \tl_set_eq:NN \l_balaji_key_tl \l_balaji_lastname_tl }
  \seq_gput_right:NV \g_balaji_author_list_seq \l_balaji_key_tl
  \prop_new:c { g_balaji_author_ \l_balaji_key_tl _prop }
  \balaji_populate:n { mail, web, address, firstname, initials, lastname, fullname }
 }

\cs_new_protected:Npn \balaji_populate:n #1
 {
  \clist_map_inline:nn { #1 }
   {
    \prop_gput:cnv { g_balaji_author_ \l_balaji_key_tl _prop } 
     { ##1 }
     { l_balaji_##1_tl }
   }
  %\prop_show:c { g_balaji_author_ \l_balaji_key_tl _prop } % for debugging
 }

\cs_generate_variant:Nn \prop_gput:Nnn { cnv }
\seq_new:N \l_balaji_author_seq
\seq_new:N \g_balaji_author_list_seq

\NewDocumentCommand{\getauthorfield} { m m }
 {
  \prop_get:cn { g_balaji_author_#1_prop } { #2 }
 }

\ExplSyntaxOff

\begin{document}

\xauthor{John X. Smith}

\xauthor[
  key=HK,
  web=http://x.y.z,
  firstname=Brian,
  lastname=Hamilton Kelly
]{Brian Hamilton Kelly}

\xauthor[
  key=VP,
  firstname=Charles,
  initials={L. X. J.},
  lastname={de la Vall\'ee Poussin},
]{Charles Louis Xavier Joseph de la Vall\'ee Poussin}

\getauthorfield{Smith}{firstname} \getauthorfield{Smith}{lastname}

\getauthorfield{HK}{web}

\end{document}

编译上述代码时出现以下错误

失控参数?{!扫描 \NewDocumentCommand 的使用时发现禁止的控制序列。\par l.305 \prop_get:cn { g_balaji_author_#1_prop { #2 }?

请指导我修复此错误。

答案1

您看到的第一个错误是

<argument> \LaTeX3 error: 
                           '\prop_get:cn' deprecated on 2016-01-05. Use '\pr...

如果您查阅此处的文档,您会发现您想要的是\prop_item:cn:如果您\prop_get:cn用替换\prop_item:cn,一切都会正常工作。

相关内容