是否可以讓套件 listofsymbols 識別 \cdots 指令?

是否可以讓套件 listofsymbols 識別 \cdots 指令?

我正在嘗試使用該包listofsymbols來定義要包含在書中符號列表中的符號。我在使用該命令\newsym定義涉及該命令的符號時遇到問題\cdots

以下是說明問題的簡單符號定義:

\opensymdef
\newsym[A family of sets]{sFam}{A_{1},\cdots,A_{n}}
\closesymdef

編譯包含符號檔的文件時,pdflatex會發出以下錯誤訊息:

Undefined control sequence.
Undefined control sequence.
Undefined control sequence.
Undefined control sequence.
Undefined control sequence.

錯誤的描述是:

... family of sets]{sFam}{A_{1},\cdots,A_{n}}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

如果在上面的符號定義中\cdots被替換為諸如 之類的字串xxxx或諸如 , 之類的命令,則編譯該文件。\alphapdflatex

有人可以幫我解決這個問題嗎?任何幫助將不勝感激。

答案1

錯誤出現在listofsymbols使用 的包中\immediate\write,這是錯誤的,並且是造成您麻煩的原因。

amsmath在新符號列表之後加載並不是真正的解決方案,因為其他命令可能會受到影響;例如,\sqrt無論您使用什麼順序都不起作用。

更好的是改變\immediate\write\protected@iwrite定義我的答案之一

\documentclass{article} 
\usepackage{listofsymbols} 
\usepackage{amsmath}
\usepackage{xpatch}

\makeatletter
% get a copy of \protected@write
\let\protected@iwrite\protected@write
% patch the copy to add \immediate
\xpatchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}
% patch \addsymline to use \protected@iwrite instead of \immediate\write
\xpatchcmd{\addsymline}
  {\immediate\write#5}
  {\protected@iwrite{#5}{}}
  {}{}
\makeatother

\opensymdef 
\newsym[A family of sets]{sFam}{A_{1},\cdots,A_{n}} 
\closesymdef

\begin{document} 

\listofsymbols

test The symbol \sFam means \sFamdoc 
\end{document}

在此輸入影像描述

透過這種重新定義,某些符號仍然會出現問題;在這種情況下,請\protect在有問題的之前添加。

順便說一下,您不應該\cdots在這種情況下使用,而只是簡單地使用\dots:逗號之間的省略號應始終帶有低點。

答案2

更新

正如egreg中所提到的his comment這只是部分解決方案。

amsmath在問題的評論中,問題已簡化為與listofsymbols;一起使用包。這個簡單的文件

\documentclass{article} 
\usepackage[draft]{listofsymbols} 
\usepackage{amsmath}

\opensymdef 
\newsym[A family of sets]{sFam}{A_{1},\cdots,A_{n}} 
\closesymdef 

\begin{document} 
test The symbol \sFam means \sFamdoc 
\end{document}

觸發錯誤訊息

! Undefined control sequence.
\DN@ ->\def \next@ 
                   
l.6 ...A family of sets]{sFam}{A_{1},\cdots,A_{n}}
                                                  
? 

透過加載即可解決問題amsmath 所有符號的定義,如:

\documentclass{article} 
\usepackage[draft]{listofsymbols} 

\opensymdef 
\newsym[A family of sets]{sFam}{A_{1},\cdots,A_{n}} 
\closesymdef 

\usepackage{amsmath}

\begin{document} 
test The symbol \sFam means \sFamdoc 
\end{document}

在此輸入影像描述

相關內容