具有預設值的組織數組?

具有預設值的組織數組?

我正在嘗試創建一個具有預設值的自訂列表,而不依賴太多其他包,因為我正在嘗試獲取一些非常具體的格式。我正在嘗試將其用於自訂封面,希望將其放入自訂 CLS 中。我想像這是工作

\organization{2nd organization}
\organization{3rd organization}
\makecustomcover

我希望這會呈現:

1st organization
2nd organization
3rd organization

顯然, \makecustomcover 將迭代這些值;但是,我不清楚將它們“推入”堆疊的最佳方法。我也不清楚使用預設方法的最佳方法。任何討論此問題的建議或參考文獻將不勝感激。

答案1

最好用於\g@addto@macro此目的。

\documentclass{article}
\pagestyle{empty}% for cropping
\makeatletter
\newcommand\@organization{1st organization\par}
\newcommand\organization[1]{\g@addto@macro\@organization{#1\par}}
\newcommand\makecustomcover{\@organization}
\begin{document}
\organization{2nd organization}
\organization{3rd organization}
\makecustomcover
\end{document}

在此輸入影像描述

相關內容