# How to define new cite command with specific citation format?

The standard \cite{some_ref} command produce citation text like [1], but i'm looking for citation like [1*]. How can i define new cite command for such behavior?

-
Welcome to tex.sx! There are many possible citation/bibliography formats -- please provide some background to your question. Should a star be added to every label number? Should a star inidicate some kind of "special" source? – lockstep May 5 '11 at 17:12
Sorry for confusing question. I need indicate special source. So i think it's better to define new command like \cites{some_ref} in this case, instead of redefining existing command. I'll update question to remove confusion. – TheBug May 5 '11 at 17:18

Since you are using natbib, there's no need to define any new commands; you can achieve the desired effect using the \citetext and \citealp commands:

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{test,
author={Steve Somebody},
title= {The Title},
year={2011},
publisher={The publisher}
}
\end{filecontents}
\documentclass{article}
\usepackage[numbers]{natbib}

\begin{document}

\citetext{\citealp{test}*}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

-
Thanks, defined new command as in your example \def\mycite#1{\citetext{\citealp{#1}*}} – TheBug May 5 '11 at 18:58
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{test,
author={Steve Somebody},
titel= {The Title},
year={2011},
}
\end{filecontents}
\documentclass{article}
\makeatletter
\DeclareRobustCommand\mycite{%
\@ifnextchar [{\@tempswatrue\@mycitex}{\@tempswafalse\@mycitex[]}}
\def\@mycitex[#1]#2{\leavevmode
\let\@citea\@empty
\@mycite{\@for\@citeb:=#2\do
{\@citea\def\@citea{,\penalty\@m\ }%
\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation \@citeb' on page \thepage \space undefined}}%
{\@cite@ofmt{\csname b@\@citeb\endcsname}}}}{#1}}
\def\@mycite#1#2{[{#1*\if@tempswa , #2\fi}]}%
\makeatother
\begin{document}
\bibliography{\jobname}
\bibliographystyle{plain}
\end{document}

-
then all \cite get the star – Herbert May 5 '11 at 17:42
@Herbert: I edited my post ;-) – Marco Daniel May 5 '11 at 17:50
Why don't you just redefine \@cite to \@mycite rather than copying over the entire contents of \@citex? I can't even tell what you changed other than the star in \@mycite. – Ryan Reich May 5 '11 at 18:03
@Ryan: if I redefine \@cite , every cite-command get the star. – Marco Daniel May 5 '11 at 18:15
@Marco: Your sample works as i expected. But when i tried it with my real document, i got error ! Use of \@ doesn't match its definition. \mycite ->\@i fnextchar [{\@tempswatrue\@mycitex}{\@tempswafalse\@mycitex[]} Seems, problem with natbib package. How your sample can be fixed in this case? – TheBug May 5 '11 at 18:19

with a second switch it is a bit shorter. Use \cite or cite*

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{test,
author={Steve Somebody},
titel= {The Title},
year={2011},
}
\end{filecontents}
\documentclass{article}
\makeatletter
\newif\if@tempswb
\DeclareRobustCommand\cite{%
\@ifnextchar*{\@tempswbtrue\cite@i}{\@tempswbfalse\cite@i*}}
\def\cite@i*{\@ifnextchar[{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}
\def\@cite#1#2{[{#1\if@tempswb*\fi\if@tempswa , #2\fi}]}%
\makeatother
\begin{document}


Your sample works fine. But with my document it leads to error Runaway argument? ]{test1} \cite *{test2} ! Paragraph ended before \@citex was complete. <to be read again> \par Can you help with this issue? – TheBug May 5 '11 at 18:46
@TheBug: natbib` redefines all macros itself and it would have been a good idea if you had this mentioned before ... – Herbert May 5 '11 at 18:50