There's no check if the optional argument of \mycite
is present or not. So \mycite{#2}
will still call \cite[]{#2}
with an empty optional argument for \cite
, meaning to typeset ,
in the list.
I added the 'traditional' way to check for the optional argument and the xparse
method (much easier!)
Note: Bibliography related packages might change the \cite
command already. This is not covered here.
\documentclass{article}
\usepackage{etoolbox}
\usepackage{xparse}
\makeatletter
\newcommand{\@myotherciteopt}[2][]{%
\hspace{30pt}%
\ifblank{#1}{%
\cite{#2}%
}{%
\cite[#1]{#2}%
}%
}
\newcommand{\@myothercitenoopt}[1]{%
\@myotherciteopt[]{#1}%
}
\newcommand{\myothercite}{%
\@ifnextchar[{\@myotherciteopt}{\@myothercitenoopt}%
}
\makeatother
\NewDocumentCommand\mycite{om}{%
\hspace{30pt}%
\IfValueTF{#1}{%
\cite[#1]{#2}%
}{%
\cite{#2}%
}%
}
\begin{document}
\mycite{Lam94}
\myothercite{Lam94}
Now with options:
\mycite[Ms. Ann Elk]{Lam94}
\myothercite[Ms. Ann Elk]{Lam94}
\bibliographystyle{alpha}
\bibliography{biblio}
\end{document}

\cite
- related packages do redefine\cite
to provide more optional arguments already. – user31729 Sep 30 '15 at 13:41