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.

I want to enclose all \includegraphics into \shadowbox. Therefore I thought to re-define \includegraphics:

\renewcommand{\includegraphics}{\shadowbox\includegraphics}

so that each time \includegraphics is called, actually the graphic is enclosed in a \shadowbox. But the above does not work:

Missing { inserted. \do@VerbBox l.80 \includegraphics {0_home_rkrug_Documents_Publications_2012_handbook_Mana... A left brace was mandatory here, so I've put one in. You might want to delete and/or insert some corrections so that I will find a matching right brace soon. (If you're confused by all this, try typing `I}' now.)

Any suggestions how I can redefine \includegraphics ?

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

I assume you're using \shadowbox from the fancybox package. You need to save the definition of \includegraphics and to pass it to \shadowbox:

\documentclass{article}
\usepackage{graphicx,fancybox,letltxmacro}

% save the meaning of \includegraphics
\LetLtxMacro\latexincludegraphics\includegraphics

% pass the image to \shadowbox
\renewcommand{\includegraphics}[2][]{%
  \shadowbox{\latexincludegraphics[#1]{#2}}}

\begin{document}
\includegraphics[width=1cm]{try}
\end{document}

In this particular case \LetLtxMacro is not really needed and the primitive \let would have sufficed, but this approach is safer whenever commands with optional arguments are redefined.

Note that you lose the possibility of using the *-form, use the clip option instead.

share|improve this answer
    
Very nice - thanks. –  Rainer Sep 7 '12 at 11:30
add comment

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.