Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following code does not do what it should:

\documentclass{article}
\usepackage{refcheck}

\begin{document}

\begin{thebibliography}{1111}

%% This works:
\bibitem[Ccc]{FP}
The Frog, Kermit, and Piggy, Miss.
\newblock Sesame Street.

%% This does not work:
\bibitem[CCC]{FP2}
The Frog, Kermit, and Piggy, Miss.
\newblock Sesame Street.

\end{thebibliography}

\end{document}

I get the follwing error:

! Undefined control sequence.
\\bibitem ...$}}\@@@biblabel@@ }\fi }\ifx #1\@nil 
                                                  \@@bibitem@@ {#2}\else \@@...
l.14 \bibitem[CCC]{FP2}

It seems that refcheck has a problem with certain optional labels in \bibitem.

What I am doing wrong here?

share|improve this question

1 Answer 1

up vote 14 down vote accepted

UPDATE

The issue has been solved in version 1.9.1 of refcheck.sty (14 February, 2013)


Original answer (still valid for refcheck version 1.9)

Nasty bug in refcheck. Here's how refcheck.sty redefines \bibitem:

\renewcommand{\bibitem}[2][\@nil]{%
 \@ifundefined{cit@#2}{%
  \@warning@rc@{Unused bibitem `#2' on page \thepage}%
  \if@show@cite
    \gdef\@biblabel{\makebox[0pt][r]{\zero@height{{\mark@size{\bfseries\upshape?}}%
      \underline{\@verbatim@{#2}}{\mark@size{\bfseries\upshape?}}$\,$}}%
      \@@@biblabel@@
    }%
  \fi
 }{%
  \if@show@cite
    \set@fbox@par
    \gdef\@biblabel{\makebox[0pt][r]{\zero@height{\fbox{\@verbatim@{#2}}$\,$}}\@@@biblabel@@}%
  \fi
 }%
 \ifx#1\@nil\@@bibitem@@{#2}%
 \else\@@bibitem@@[#1]{#2}%
 \fi
}%

The problem is in the final part: any entry where the first two letters in the optional argument are equal will trigger the error. Let's see why. The code is

 \ifx#1\@nil\@@bibitem@@{#2}%
 \else\@@bibitem@@[#1]{#2}%
 \fi

and when you have

\bibitem[Ccc]{FP}

the argument #1 is Ccc; thus the conditional

\ifx Ccc\@nil

is false and everything up to \else is skipped. In the case of

\bibitem[CCC]{FP2}

TeX finds

\ifx CCC\@nil

and the conditional is true, so \@nil should be expanded, which can't because it's purposely left undefined by the LaTeX kernel.

What does the package want to do? It wants to check whether an optional argument is not specified, and this is the wrong way to do it. Here's a better version:

\usepackage{refcheck}
\makeatletter
\AtBeginDocument{
\renewcommand{\bibitem}[2][]{%
 \@ifundefined{cit@#2}{%
  \@warning@rc@{Unused bibitem `#2' on page \thepage}%
  \if@show@cite
    \gdef\@biblabel{\makebox[0pt][r]{\zero@height{{\mark@size{\bfseries\upshape?}}%
      \underline{\@verbatim@{#2}}{\mark@size{\bfseries\upshape?}}$\,$}}%
      \@@@biblabel@@
    }%
  \fi
 }{%
  \if@show@cite
    \set@fbox@par
    \gdef\@biblabel{\makebox[0pt][r]{\zero@height{\fbox{\@verbatim@{#2}}$\,$}}\@@@biblabel@@}%
  \fi
 }%
 \if\relax\detokenize{#1}\relax\@@bibitem@@{#2}%
 \else\@@bibitem@@[#1]{#2}%
 \fi
}
}% End of \AtBeginDocument
\makeatother

A non e-TeX way could be

\ifx\valign#1\valign

instead of the better

\if\relax\detokenize{#1}\relax

Take your pick.

share|improve this answer
5  
I know I shall not comment with "Thank you", but rather upvote and accept the answer. But that does not seem enough. Thank you! –  mafp Dec 23 '12 at 23:26
    
Is there a chance that this change will be made to the package? –  soandos Dec 24 '12 at 19:55
    
@soandos I don't think the author is still active on it. :( –  egreg Dec 24 '12 at 20:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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