Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX: Redefining the citation macro temporarily

Tags:

latex

I'm new to latex, but it seems you can temporarily redefine some commands? The problem I have is that normally the citation is (SMITH, 2000). But at times, I'd like to have Smith (2000) instead. Anyway I can temporarily redefine it, then use the standard version again after that "block" of code?

like image 255
dmc Avatar asked Sep 20 '10 06:09

dmc


2 Answers

Enclose the local definition in braces ({}).

\newcommand\foo{FOO!}
\foo
{\renewcommand\foo{BAR?}\foo\foo}
\foo

This will generate something like:

FOO!BAR?BAR? FOO!

This can be done inside macro definitions, too - just make sure you add the extra braces:

\newcommand\newfoo{{\renewcommand\foo{BAR?}\foo}}

Hope this helps.

like image 110
Phil Richards Avatar answered Oct 03 '22 15:10

Phil Richards


You should already have \citep and \citet commands that should do what you want, there's no reason to redefine the macros yourself.

like image 36
Seamus Avatar answered Oct 03 '22 14:10

Seamus