[XeTeX] Problem with apacite and fontspec
Diederick C. Niehorster
diederick at niehorster.eu
Fri Oct 3 18:00:05 CEST 2008
Hi Ross,
Your solution(s) indeed seem to have fixed the problem here also.
Thanks to all the others for jumping in on this thread so quickly!
Thanks again,
Diederick
> -----Original Message-----
> From: xetex-bounces at tug.org [mailto:xetex-bounces at tug.org] On Behalf Of
Ross Moore
> Sent: Friday, October 03, 2008 9:04 AM
> To: Unicode-based TeX for Mac OS X and other platforms
> Subject: Re: [XeTeX] Problem with apacite and fontspec
>
> Hi Diedrick,
>
> On 03/10/2008, at 2:09 AM, Diederick C. Niehorster wrote:
>
> > Dear Xetex Users,
> >
> >
> >
> > I've just discovered XeteX and got very excited by it. So I decided
> > to practice and convert a work in progress from plain LateX to
> > XeteX (well, just add some fontspec stuff to select a different
> > (OpenType) font). I ran into the following problem:
> >
> > When both the packages apacite and fontspec are loaded and I cite
> > more than one paper by the same authors from the same year, I get
> > an error message during compilation.
> >
> > If I don't load either apacite (just use plainnat.bst with natbib)
> > or fontspec, this error does not occur.
> >
> > The error message occurring is:
> >
> > ------
> >
> > ! Undefined control sequence.
> >
> > \@calc at post@scan ...fi \fi \fi \fi \fi \calc at next
> >
> >
> >
> > l.16 ...e item works fine: \citet{Wertheimer1967a}
> >
>
> I've tested your example and found that the incompatibility
> is triggered by the use of the calc.sty package,
> which is loaded by fontspec.sty .
>
>
> More specifically, calc.sty changes the way \setcounter works.
> The programming in apacite.sty does not take this into account.
> The problem occurs when using \citet and other \cite command variants
> defined by natbib.sty , since these require significant extra parsing
> beyond what LaTeX would do without natbib .
>
>
> Here's a simple fix that seems to work:
>
>
> \usepackage[tocbib]{apacite}
> %% ---- RRM 2008/10/03
> %% for compatibility with calc.sty
> %% we need an extra \protect as below before \setcounter
> %%
> \renewcommand{\BCnt}[1]{\protect\setcounter{BibCnt}{#1}\protect
> \theBibCnt}
> \renewcommand{\BCntIP}[1]{\protect\setcounter{BibCnt}{#1}\mbox{-
> \protect\theBibCnt}}
> \renewcommand{\BCntND}[1]{\protect\setcounter{BibCnt}{#1}\mbox{-
> \protect\theBibCnt}}
>
> \usepackage[sort]{natbib}
> %\usepackage{calc}
> \usepackage{fontspec} % provides font selecting commands
> ...
>
>
> This avoids \setcounter being expanded too early, at a place
> where it isn't actually being used.
> All still works correctly at the place where it *is* required.
>
>
>
> An alternative solution, and perhaps a better one, would be
> to have made the commands \BCnt \BCntIP \BCntND robust
> in the first place; e.g. apacite.sty should use
>
> \DeclareRobustCommand{\BCnt}[1]{\setcounter{BibCnt}{#1}\theBibCnt}
> \DeclareRobustCommand{\BCntIP}[1]{\setcounter{BibCnt}{#1}\mbox{-
> \theBibCnt}}
> \DeclareRobustCommand{\BCntND}[1]{\setcounter{BibCnt}{#1}\mbox{-
> \theBibCnt}}
>
>
> You can patch this solution cleanly into existing documents,
> as follows:
>
>
> \usepackage[tocbib]{apacite}
> \DeclareRobustCommand{\robustBCnt}[1]{\setcounter{BibCnt}{#1}\theBibCnt}
> \DeclareRobustCommand{\robustBCntIP}[1]{\setcounter{BibCnt}{#1}\mbox{-
> \theBibCnt}}
> \DeclareRobustCommand{\robustBCntND}[1]{\setcounter{BibCnt}{#1}\mbox{-
> \theBibCnt}}
> \let\BCnt\robustBCnt
> \let\BCntIP\robustBCntIP
> \let\BCntND\robustBCntND
>
> \usepackage[sort]{natbib}
> %\usepackage{calc}
> \usepackage{fontspec} % provides font selecting commands
> ...
>
>
> Furthermore, if a future version of apacite.sty makes its own fix,
> as suggested above, then documents with this modification should
> continue
> to work properly. However, a danger is if \BCnt \BCntIP \BCntND
> are changed in a *different way*, to solve this or any other problem.
>
>
> This analysis is based on:
>
> \ProvidesPackage{apacite}
> [2007/09/03 v4.00 APA citation]
>
> which is the latest version available at CTAN.
>
>
>
>
> > ------
> >
> >
> >
> > This error is not specific to the two papers I cite in the example,
> > it occurs with others also.
> >
> > Any ideas on how to fix this or is this a bug incompatibility in
> > one of the packages that has to be fixed?
> >
>
>
> Hope this helps,
>
> Ross
>
> >
> >
> > Thanks,
> >
> > Diederick
> >
>
> ------------------------------------------------------------------------
> Ross Moore ross at maths.mq.edu.au
> Mathematics Department office: E7A-419
> Macquarie University tel: +61 (0)2 9850 8955
> Sydney, Australia 2109 fax: +61 (0)2 9850 8114
> ------------------------------------------------------------------------
>
>
>
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex
More information about the XeTeX
mailing list