5

When I am writing I often will realize I need to put a citation for something I wrote, but I don't have it. I like to leave myself something to remind myself which reference I need to put in once I add it to my .bib file. Like this:

This important thing\cite{Author's 2010 paper about stuff} is important 

I edit my tex source in vim and I have a vimscript defined to compile my document, but invalid \cite{} commands are not handled very gracefully. So my vimscript calls a bash script that makes a copy of my tex source with all such commands commented out. I find the "invalid" citations using a regular expression that matched my cite-key format. When my colleges ask me to help them set up something similar for themselves it gets really messy when they don't have a well defined cite-key format.

I would like to redefine the way \cite{} commands are parsed to ignore ones that begin with a specific character say *, although the specific character is not important if one choice is better than the other. So

Words in the sentence\cite{author:1990-0} more words. 

would be handled correctly but say

Words in the sentence\cite{*not a real key just a note} more words.

would be ignored. Is this possible? How could I find out?

I would also like to have a marker appear in the text to remind me I need to add something there, but that would be like a bonus not a main objective of what I need.

  • 5
    why not just use \xcite{xxxx} with \newcommand\xcite[1]{..} to do whatever you need? redefining \cite is possible but trickier due to all the various packages that give it different definitions – David Carlisle Sep 16 '15 at 18:33
  • Related: tex.stackexchange.com/questions/131641/… – alfC Sep 17 '15 at 2:59
4

If you need the optional argument of \cite then you have to extend the code:

\documentclass{article}
\let\myCite\cite
\makeatletter
\def\cite#1{\cite@I#1!!}
\def\cite@I{\@ifnextchar*\cite@II\cite@III}
\def\cite@II#1!!{}
\def\cite@III#1!!{\myCite{#1}}
\makeatother

\begin{document}

foo\cite{article-minimal} and bar\cite{*article-full}

foo\cite{*article-minimal} and bar\cite{article-full}

foo\cite{article-crossref} and bar\cite{*whole-journal}

foo\cite{*article-crossref} and bar\cite{whole-journal}

\bibliographystyle{plain}
\bibliography{xampl}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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