![如何将文档输入流中的 LaTeX3 序列元素大写?](https://linux22.com/image/425643/%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E6%A1%A3%E8%BE%93%E5%85%A5%E6%B5%81%E4%B8%AD%E7%9A%84%20LaTeX3%20%E5%BA%8F%E5%88%97%E5%85%83%E7%B4%A0%E5%A4%A7%E5%86%99%EF%BC%9F.png)
如何将文档输入流中的 LaTeX3 序列元素大写?我认为问题\seq_item:N
在于它不可扩展。
\documentclass{article}
\ExplSyntaxOn
\seq_new:N \g_syllabus_kafname_seq
\NewDocumentCommand\kafname{ m }
{
\seq_gput_right:Nn \g_syllabus_kafname_seq { #1 }
}
\NewDocumentCommand{\thekaf}{ O{1} }
{
\seq_item:Nn \g_syllabus_kafname_seq { #1 }
}
\NewDocumentCommand \firstcap { m } { \text_titlecase:n {#1} }
\ExplSyntaxOff
\begin{document}
\kafname{aass}
\kafname{bbb}
\kafname{ccc}
\firstcap{\thekaf[2]} %Need Bbb
\end{document}
答案1
您可以将格式化命令放在 \thekaf 命令中:
\documentclass{article}
\ExplSyntaxOn
\seq_new:N \g_syllabus_kafname_seq
\NewDocumentCommand\kafname{ m }
{
\seq_gput_right:Nn \g_syllabus_kafname_seq { #1 }
}
\cs_new:Npn \__syllabus_kaf_format:n {}
\NewDocumentCommand{\thekaf}{ O{1} }
{
\__syllabus_kaf_format:n
{\seq_item:Nn \g_syllabus_kafname_seq { #1 }}
}
\NewDocumentCommand \firstcap { m } {
\group_begin:
\cs_set_eq:NN \__syllabus_kaf_format:n\text_titlecase:n
#1
\group_end:
}
\ExplSyntaxOff
\begin{document}
\kafname{aass}
\kafname{bbb}
\kafname{ccc}
\thekaf[2], \firstcap{\thekaf[2]} %Need Bbb
\end{document}