[Tugindia] howto \renewcommand{\bibitem}[2][?] with default option
as in plain style
Josy P. Pullockara
josy at ctfd.cmmacs.ernet.in
Mon Oct 18 12:44:44 CEST 2004
Dear TeX users,
Want to \renewcommand \bibitem as shown below without breaking the plain
style bibliography. The below code breaks the plain style. How to fix
it? \bibitem uses the enumiv counter by default for the plain style. How
do I get it incorporated here neatly.
\documentclass{article}
\newcommand{\oldbibitem}[2][]{} % creating a tmp command
\let\oldbibitem\bibitem % copy the \bibitem command into tmp
\newcounter{totalbibitem}
\renewcommand{\bibitem}[2][]{\oldbibitem[#1]{#2}\addtocounter{totalbibitem}{1}}
\begin{document}
\cite{cite1, cite2}.
\begin{thebibliography}{9}
\bibitem{cite1} Author1 % broken plain style
\bibitem[CITE2]{cite2} Author2 % ok
\end{thebibliography}
totalbibitem = \thetotalbibitem % ok
\end{document}
It should be possible with an \ifx based condition within the
\renewcommand. Something like:
\renewcommand{\bibitem}[2][undefined]{
\ifx #1 undefined
\oldbibitem{#2}
\else
\oldbibitem[#1]{#2}
\fi
\addtocounter{totalbibitem}{1}
}
But I am not really getting it right!
Thank you.
--
Josy P. Pullockara <josy at ctfd.cmmacs.ernet.in>
National Aerospace Laboratories
More information about the tugindia
mailing list