expl3 par 和序列

expl3 par 和序列

在探索 expl3 後,我一直在更新一些程式碼,並且遇到了一個我沒有預料到的有趣問題。

我收到一個奇怪的錯誤,我認為這是由於嘗試將多個段落儲存到一個序列中而導致的。我在interface3手冊中沒有找到任何內容,有人知道解決這個問題的方法嗎?

我把我的變數儲存的舊方法和新追蹤方法放在下面,供有興趣的人參考。

這是我的舊代碼。

\newcommand{\@supernote}{}
\newcommand{\supernote}[1]{\renewcommand\@supernote{#1}}

這是我的新程式碼。

\seq_new:N \itemsupernote
\NewDocumentCommand{\supernote}{sm} {
    \seq_put_right:Nn \itemsupernote {#2}
}

兩者呼叫函數的方式相同

\supernote{Here is my example

and here is the other half}

這是我對新方法的錯誤,以防有幫助。

runaway argument? {here is my example Paragraph ended before \supernote was omplete.
<to be read again> \par l.109 

答案1

問題不在於程式碼層(全部「長」),而在於您的介面設定。由於文件命令更常見的情況是它們應該只接受短文本片段,因此xparse創建“短”命令作為標準。要使一個論證“長”,你需要用 a 來標記它+

\NewDocumentCommand \supernote { s +m }
  {
    \seq_put_right:Nn \itemsupernote {#2}
  }

請注意,它xparse是逐個參數地處理長/短參數,而不是一次切換所有參數。

相關內容