3

I am trying use the package listofsymbols to define a symbol to be included in a list of symbols in a book. I have problems using the command \newsym to define a symbol which involves the command \cdots.

The following is a simple symbol definition that illustrates the problem:

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

When a document which includes the symbols file is compiled, pdflatex issues the the following error messages:

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

The description of the error is:

... 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.

If \cdots is replaced with a string such as xxxx or a command such as \alpha, in the above symbol definition, then pdflatex compiles the document.

Could someone help me sort out this problem. Any help would be appreciated highly.

  • 1
    Please add to your question a complete yet minimal document illustrating the problem mentioned. – Gonzalo Medina Feb 18 '15 at 13:20
  • 2
    I ask you for this MWE since this \documentclass{article} \usepackage[draft]{listofsymbols} \opensymdef \newsym[A family of sets]{sFam}{A_{1},\cdots,A_{n}} \closesymdef \begin{document} test The symbol \sFam means \sFamdoc \end{document} works flawlessly in my system (TeX Live2014). – Gonzalo Medina Feb 18 '15 at 13:23
  • Thanks four your answer Gonzalo. I have tried out your example exactly as you have written it. However, it still does not work for me. I also use TeXLive 2014. – user24098 Feb 18 '15 at 19:46
  • 1
    Please add \listfiles to the preamble of the exact code I gave in my previous comment and compile the document, open the .log file and search for the *File List* section and add this list as an edit to your question. – Gonzalo Medina Feb 18 '15 at 21:54
  • Thank you very much Gonzalo Medina. Analysis of the difference between your code and mine led me to discover the source of my problem. When I use your code in the context of my original document it fails to compile; but if I use your code in isolation it compiles without problems at all. I discovered that one of the packages I used in my context, the amsmath package, was the cause of the problem. My code works if the \usepackage{amsmath} command is commented out. Unfortunately, I need the amsmath package in order to access the \numberwithin command. – user24098 Feb 19 '15 at 12:13
5

The error is in the listofsymbols package that uses \immediate\write, which is wrong and is the cause of your troubles.

Loading amsmath after the list of new symbols is not really a solution, because other commands can be affected; for instance, \sqrt will not work whatever order you use.

Better is changing \immediate\write into \protected@iwrite as defined in one of my answers.

\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}

enter image description here

With this redefinitions some symbols can still give problems; in this case add \protect before the offending one.

By the way, you shouldn't use \cdots in this context, but simply \dots: an ellipsis between commas should always be with low dots.

  • Thanks a lot egreg. I have tried out your code. It works even for \sqrt. I also appreciate your comments on \cdots and \dots. I have just read the amsmath user guide on dots and discovered the contextually flexible dots such as \dotsc, \dotsb, etc. Great stuff. – user24098 Feb 19 '15 at 19:51
4

Update

as egreg mentions in his comment this is just a partial solution.

In the comments to the question, the problem has been reduced to the use of the amsmath package together with listofsymbols; this simple document

\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}

triggers the error message

! Undefined control sequence.
\DN@ ->\def \next@ 

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

? 

The problem can be solved by loading amsmath after all the definitions of symbols, as in:

\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}

enter image description here

  • Try with \sqrt in the final argument to \newsym and enjoy. ;-) – egreg Feb 19 '15 at 13:53
  • @egreg you're right. I'll add a remark to my answer linking to your comment and leave this as a provisional answer. – Gonzalo Medina Feb 19 '15 at 14:02
  • Thanks, once more, Gonzalo Medina. I have tried out your code. It works as given but fails when \cdots is replaced with \sqrt. Cheers for your response. – user24098 Feb 19 '15 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.