Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

what?

I would like to "store" the definition of \includegraphics into \something so that the following logics will work:

% the following line is what I am looking for
store(\includegraphics, \something)
% and then I want to achieve what follows

\renewcommand\includegraphics}[2][]
{}

\doalotofstuff

\renewcommand\includegraphics}[2][]
{%
get_the_definition_from(\something)
}

% now I can again use \includegraphics with its usual definition

Is it possible and easily achievable?

but why?!

I want to disable the command \includegraphics in some parts on my document and be able to get again the usual \includegraphics after. This question is related to this post (the solution does not work if the \includegraphics command is active.

share|improve this question
2  
To store it: \let\savedincludegraphics\includegraphics and then to restore it \let\includegraphics\savedincludegraphics –  Dan Mar 20 at 17:52
    
Can we assume the local 'place' can form a group (defined scope, not definitions need to 'escape')? –  Joseph Wright Mar 20 at 17:54
    
@JosephWright I don't understand all the terms of your question, but I think, more or less: YES. –  Colas Mar 20 at 18:11

2 Answers 2

up vote 4 down vote accepted

You want something like

\usepackage{letltxmacro}

and

\LetLtxMacro\colassavedincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{}

for disabling the command; for reenabling it

\LetLtxMacro\includegraphics\colassavedincludegraphics

For the specific command \let might be sufficient, but \LetLtxMacro is safer for commands that accept optional arguments.

See When to use \LetLtxMacro? for more information about \LetLtxMacro.

For environments it depends on how they are defined, but the comment package may reveal useful.

share|improve this answer
    
Thanks! I have asked another question for environements, see tex.stackexchange.com/q/166724/8323 –  Colas Mar 20 at 18:28

It seems that you are looking for \let:

\let\something=\includegraphics
share|improve this answer
    
Is it possible to do the same with environments??? –  Colas Mar 20 at 18:14
1  
see tex.stackexchange.com/q/166724/8323 –  Colas Mar 20 at 18:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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