[comp.text.tex] What's wrong with the following macro?

young@emx.utexas.edu (Young U. Ryu) (06/13/91)

The following is a part of a version of newapa.sty (or
its modification) which generates APA style citations.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\@internalcite\cite
%
% comment: \cite -> (Author List, Year)
% comment: \citeA -> Author List (Year)
% comment: \citeauthor -> Author List
\def\cite{\def\@citeseppen{-1000}%
    \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}
    \def\citeauthoryear##1##2##3{##1, ##3}\@internalcite}
\def\citeA{\def\@citeseppen{-1000}%
    \def\@cite##1##2{{##1}\if@tempswa , ##2)\else)\fi}
    \def\citeauthoryear##1##2##3{##1 (##3}\@citedata}
\def\citeauthor{\def\@citeseppen{-1000}%
    \def\@cite##1##2{##1\if@tempswa , ##2\fi}
    \def\citeauthoryear##1##2##3{##1}\@citedata}
%
\def\@citedata{\@ifnextchar[{\@tempswatrue\@citedatax}{\@tempswafalse\@citedatax[]}}
%
\def\@citedatax[#1]#2{%
\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \def\@citea{}\@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{, }\@ifundefined
       {b@\@citeb}{{\bf ?}\@warning
       {Citation `\@citeb' on page \thepage \space undefined}}
{\csname b@\@citeb\endcsname}}}{#1}}
%
\def\@citex[#1]#2{%
\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \def\@citea{}\@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{; }\@ifundefined
       {b@\@citeb}{{\bf ?}\@warning
       {Citation `\@citeb' on page \thepage \space undefined}}%
{\csname b@\@citeb\endcsname}}}{#1}}
%
%
\def\@biblabel#1{}
\newlength{\bibhang}
\setlength{\bibhang}{2em}
%
\def\thebibliography#1{\chapter*{Bibliography}
 \addcontentsline{toc}{chapter}{Bibliography}
  \list
  {\relax}{\setlength{\labelsep}{0em}
    \setlength{\itemindent}{-\bibhang}
    \setlength{\leftmargin}{\bibhang}}
    \def\newblock{\hskip .11em plus .33em minus .07em}
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

It can be used with bibligraphy entries
generated by BiBTeX with newapa.bst
and also works with the following manual entries:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{thebibliography}{}

\bibitem[\protect\citeauthoryear{Anderson}{Anderson}{1958}]{Anderson58}
Anderson, A.~R. (1958).
\newblock A reduction of deontic logic to alethic modal logic.
\newblock {\em Mind}, {\em 67\/}(265), 100--103.

\bibitem[\protect\citeauthoryear{Anderson}{Anderson}{1967}]{Anderson67}
Anderson, A.~R. (1967).
\newblock The formal analysis of normative system.
\newblock In Rescher, N. (Ed.), {\em The Logic of Decision and Action}.
  Pittsburgh, PA: Univ.\ of Pittsburgh Press.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Now, the problem is that when the above macro generates
a citation, it places some extra space before it:
For example:

	blah blah \cite{Anderson67} blah blah

results in:

	blah blah   (Anderson, 1967) blal blah
                 ^^^Here a Big space.

What's wrong with the above macro?

Young U. Ryu
young@emx.utexas.edu

raichle@informatik.uni-stuttgart.de (Bernd Raichle) (06/13/91)

> What's wrong with the above macro?

There are unwanted spaces in the macro definitions of \cite, \citeA...

E.g. change definition of \cite to:

\def\cite{\def\@citeseppen{-1000}%
    \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}% <-----------!!!
    \def\citeauthoryear##1##2##3{##1, ##3}\@internalcite}


-bernd