I'm new to LaTeX and I want to define an auxiliary command for citing. What I would like to achieve is a \newcommand or similar that takes a BibTeX parameter such as paper and produces the same output as:

(Image from \cite{paper})

Instead I would like to write:


I have tried the following:

\newcommand{\imfrom}[1]{(Image from \cite{#1})}

It works, but it is not type safe, so Kile's auto-completion does not work. Is there any way this could be done easily?

Thanks in advance!

  • Is Kile able to auto complete personal commands? – Sigur Jul 30 '14 at 2:44
  • I don't know for certain. I found this: tex.stackexchange.com/questions/80093/… Although it is something different. – Ivo Jul 30 '14 at 2:56
  • Yes, see this: tex.stackexchange.com/a/80110/14757 – Sigur Jul 30 '14 at 2:58
  • But this is just for the parameter names, or am I wrong? How to 'tell it' to show me the full list of citation keys? – Ivo Jul 30 '14 at 2:59
  • I don't know if Kile does this but I'm sure that TeXstudio does. – Sigur Jul 30 '14 at 3:00

Save the original cite command and redefine it to do what you want.

\renewcommand{\cite}[1]{(Image from \oldcite{#1})}

If you want to use the old cite command just call \oldcite{}.



\renewcommand{\cite}[1]{(Image from \oldcite{#1})}

Using the new command: \verb|\cite{foo}| produces \cite{foo}

Using the old command: \verb|\oldcite[Sec.~1]{foo}| produces \oldcite[Sec.~1]{foo}

\bibitem{foo} Foo

enter image description here

Note: now the cite command does not accept optional argument.

| improve this answer | |
  • Thanks, but now I can't use auto-completion for \oldcite. – Ivo Jul 30 '14 at 2:54
  • So in this case I'm almost sure that Kile could auto complete user's commands. – Sigur Jul 30 '14 at 2:57

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.