5

I am trying to use siunitx in an emulateapj document, however it reports a conflict of command:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "xparse/command-already-defined"
! 
! Command '\tablenum' already defined!
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................

generate by pdflatex of the following document:

\documentclass[apj]{emulateapj}
%\documentclass{aastex}
%\let\tablenum\relax
\usepackage{siunitx}

\begin{document}
\title{emulateapj with siunitx}

\author{Jerry Ma}

\begin{deluxetable}{rr}
\tabletypesize{\scriptsize}
\tablewidth{\the\columnwidth}
\tablecaption{\label{tab:test}
A dummy table}
\tablehead{\colhead{col1} &
\colhead{col2} \\
\colhead{\left(\si{\gram}\right)} &
\colhead{\left(\si{\milli\meter}\right)}
}
\startdata
 80.76 & 50.4 \\
 19.28 & 33.4 \\
\enddata
\tablecomments{siunitx doesn't work}
\end{deluxetable}

\end{document}

Naively I put the following just before I load siunitx:

\let\tablenum\relax

to solve the confliction. This time it compiles through (means I can see the output pdf file which contains a table as expected) but with errors like the following:

! Package array Error:  Illegal pream-token (\lt@expand@linewidth@): `c' used.

See the array package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.13 \begin{deluxetable}{rr}

? 
! Missing $ inserted.
<inserted text> 
                $
l.22 }

? 

So, the question is, How could I make emulateapj to work with siunitx? Thank you in advance!

2
  • I'm afraid the answer to me looks like 'you can't'. If you load the class and the array package (used by siunitx) you get the same Illegal pream-token error. The array package is part of the core LaTeX tools set, so not working here is a big problem. Probably the deluxtable environment has its own internals that are distinct from the standard tabular set up, which will break with array.
    – Joseph Wright
    Jul 22, 2014 at 6:01
  • The deluxetable environment tweaks longtable in order to get tables as wide as the text column. Why would anybody do this is beyond my understanding.
    – egreg
    Jul 22, 2014 at 7:25

1 Answer 1

9

I had the same problem with the aastex documentclass. I was able to use the savesym package as a workaround:

\usepackage{savesym}
\savesymbol{tablenum}
\usepackage{siunitx}
\restoresymbol{SIX}{tablenum}

The savesym package is used to "redefine symbols where names conflict." In this case, the conflict is with the tablenum symbol.

Note that this only solves the problem of siunitx trying to define a symbol that already exists. There is another problem pointed out by Joseph Wright: the deluxetable environment is not compatible with the array package. This is only a problem if one actually uses the deluxtable environment.

In order to use the deluxetable environment, I need to modify the environment as follows:

% redefine deluxetable for compatibility with the array package.
\let\oldenddeluxetable\enddeluxetable
\let\olddeluxetable\deluxetable
\makeatletter
\renewenvironment{deluxetable}[1]{
\olddeluxetable{[#1]}
\def\pt@format{#1}%
}{\oldenddeluxetable}
\makeatother

This can be done right after the \restoresymbol{SIX}{tablenum}. The redefinition changes \def\pt@format{\string#1}% from aastex.cls to \def\pt@format{#1}%.

There may still be some other issues lurking around, but so far these changes have worked for me.

1
  • 1
    Please explain what this code does. Suppose the reader does not know savesym ...
    – Mensch
    Sep 23, 2015 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .