[OS X TeX] How to comment out includegraphics?

Alain Schremmer Schremmer.Alain at gmail.com
Fri Oct 28 19:37:05 EDT 2005

Ross Moore wrote:

> On 28/10/2005, at 3:26 PM, Alain Schremmer wrote:
>> Moore's
>> \renewcommand{\includegraphics}[1][]{\url}
>> substitutes the name of the file which is truly nice.
>> 2) Even though so far, say, \includegraphics[,scale=0.75]{Figures/ 
>> 01_01_00.pdf}has been working fine as is, namely without $ … $, I  
>> understand Høgholm as saying that when the command is changed by  
>> renewcommand, the status of underscore can change so that my idea  of 
>> using underscore as separator in file names was not exactly  brilliant.
> Your use of underscore is fine, provided the command that you use
> knows what to expect and how to handle it.

Er …

>   \includegraphics  (as defined in  graphics.sty  and  graphicx.sty )
> knows that a filename may use characters differently to what TeX  
> normally
> expects.  

I am relieved as I am not planning at all to do anything exotic.

> However using '.' as a separator won't work, as then it gets
> mixed-up as to what part is the 3-letter suffix.

Yes, I found out the hard way a while ago.

> Now \url  is also aware of the use of _ in filenames.
> But \textbf (and other usual text-font commands) is *not*.
> The real issue is the top of category-codes.
> This is what allows characters to have different uses,
> according to the context in which they occur.
> The tricky bit is that macros need to prepare that context
>  *before* the argument is read by the (La)TeX job.
> This is why the following does *not* work:
>    \renewcommand{\includegraphics[2][]{\url{#2}}
>  (the #2 argument is read before \url has a chance to
>   prepare the context appropriately)
> whereas my previous suggestion *does* work:
>    \renewcommand{\includegraphics[1][]{\url}
> Here \url prepares the context before the following {...}
> is read. It resets the context back to the default afterwards.
> But be wary of things like
>    \fbox{\includegraphics[..]{Figures/01_01_00.pdf}}
>   or  \mbox or \framebox and suchlike.
> If these read their argument immediately, then the \url
> will not be able to have the _ prepared correctly.
> Now you *do* need something like Morton's use of LaTeX internals
> to filter through all the characters in the filename,
> switching each 'math-mode' _  into a benign 'ascii-mode' _ .
>> (I think I used underscore because 01.02.03b.pdf was not working at  
>> all and, as discussed in an earlier thread, 01/02/03b.pdf does not  
>> always work.)
> You have to use something that is a valid filename on the computer
> system that is doing the work.
> Both / and : can be directory separators, so rule them out!
> Also rule out \ if DOS is involved in any way.
>> What would then be a safe separator to use to rename, say, the file  
>> that right now I am calling 01_02_03b.pdf ?
>   '-' would work, but you may be using this already in some names.
>  So '_' is just fine, provided you handle it properly within the TeX
>  coding for your document.

Given that I am staying safely within a garden variety of LaTeX, I think 
that I will save myself the trouble of renaming a whole bunch of graphic 
and pdf files (When it saves a copy as cropped pdf, Intaglio keeps the 
name and just changes the suffix.)

> If you've not encountered the \catcode concept before, it can
> seem mysterious and complicated.  In fact it is very straight-forward
> and extremely convenient --- but it requires you to think carefully
> about the exact order in which your document's processing tasks
> are being performed. This may require you to look "under the hood"
> from time to time.

I am afraid that the circumstances are forcing me "à parer au plus 
pressé", the price being of course that my output could certainly be 
improved, if only typographically. Still, and even if I did not entirely 
understand all of the above, it does seem fascinating and, one can 
always hope, maybe, one day, I will have the time seriously to look 
"under the hood". After all, in my wild youth, I did dabble in racing 
car mechanics.

> Hope this helps,

Yes, it did and in many ways.

Thanks for all of it and my best regards.

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/

More information about the MacOSX-TeX mailing list