On the question How to create a dummy generic environment replacement? I learned how to replace an generic envinronment with a dummy one. Until now I had success replacing then as replacing \currenttime from datetime package with \def\currenttime{Current Time}.
But when I tried this strategy with \includegraphics:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\newif\ifdebug
\debugtrue
% \debugfalse
\ifdebug
% \def\includegraphics{includegraphics}
\newcommand{\includegraphics}{includegraphics}
\else\fi
\begin{document}
\includegraphics[width=\linewidth]{pictures/ex01}
\end{document}
It does not worked:
! Missing number, treated as zero.
<to be read again>
]
l.86 \includegraphics[width=\linewidth]
{pictures/ex01}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Illegal unit of measure (pt inserted).
<to be read again>
]
l.86 \includegraphics[width=\linewidth]
{pictures/ex01}
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)
Can I wrap the command contents as \includegraphics[width=\linewidth]{pictures/ex01} on verbatim environment as done for environments?
\@ifundefined{longtable}
{
\newenvironment{longtable}[0]
{longtable environment \par\verbatim\tiny}
{\endverbatim\endgraf\normalfont replacement for debug mode}
}{}
Update
Trying to do:
\newcommand{\includegraphics}[2]{\par\verbatim\tiny includegraphics #1 #2 \endverbatim\endgraf\normalfont}
Throws a new error:
File: t1cmtt.fd 2014/09/29 v2.5h Standard LaTeX font definitions
)
Runaway argument?
! Paragraph ended before \next was complete.
<to be read again>
\par
l.87
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
But it is printing something on the PDF:
Related:


draftordemooption tographicx? – Alan Munn Aug 20 '17 at 19:27\renewcommand\includegraphics[2][]{....}– Ulrike Fischer Aug 20 '17 at 19:42[2]but[2][]. And don't use verbatim here, it doesn't make much sense.\detokenize{#2}is better. – Ulrike Fischer Aug 20 '17 at 20:02\newcommand{\includegraphics}[2][]{ includegraphics \detokenize{#1} \detokenize{#2} }and it worked. – user Aug 20 '17 at 20:41draftordemooption to graphicx does the same thing, I would just look into their implementation and copy it. Also, now I can do it for any package command, whether they supportdraftordemooption or not. Perhaps my question title was misleading. I will change it toHow to replace a command with a dummy one?– user Aug 20 '17 at 20:44