
我必須使用 tocloft 套件將「補充資料清單」新增至我目前的文件。目前我的序言中有以下程式碼:
\usepackage[titles]{tocloft} % Create Table of Supplementary Materials
\newcommand{\listsuppmatname}{Supplementary Materials}
\newlistof{suppmat}{smat}{\listsuppmatname}
\newcommand{\suppmat}[1]{%
\refstepcounter{suppmat}
\noindent{Video \thechapter.\thesuppmat\xspace}
\addcontentsline{smat}{suppmat}
{\protect\numberline{\thechapter.\thesuppmat}#1}
}
在文字中我有:
\suppmat{blah blah}\label{vid:blahblah}
這按預期工作,但我在引用後面有一個尾隨空格。我已經嘗試了一些針對宏尾隨空格的建議解決方案(例如 xspace 包或 \supmat/ 等),但似乎沒有一個能夠刪除空格。我感覺這與 tocloft 包有一個小衝突。
有任何想法嗎?謝謝!
答案1
\newcommand{\listsuppmatname}{Supplementary Materials}
\newlistof{suppmat}{smat}{\listsuppmatname}
\newcommand{\suppmat}[1]{%
\refstepcounter{suppmat}%%%%%
\noindent{Video \thechapter.\thesuppmat}%%%%%%%%
\addcontentsline{smat}{suppmat}%%%%%
{\protect\numberline{\thechapter.\thesuppmat}#1}%%%%%
}
%%%%
你的巨集每次都添加 4 個空格,我用(你只需要一個%
)註解掉了它們,\xspace
如果你確實使用它,我也刪除了它,它必須是定義中的最後一個標記。在您擁有它的地方,它總是會在定義中看到以下空格,因此永遠不要添加空格。