[OS X TeX] How to comment out includegraphics?

Ross Moore ross at ics.mq.edu.au
Fri Oct 28 02:30:14 EDT 2005


Hello Alain,

On 28/10/2005, at 3:26 PM, Alain Schremmer wrote:

> But 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.

   \includegraphics  (as defined in  graphics.sty  and  graphicx.sty )
knows that a filename may use characters differently to what TeX  
normally
expects.  However using '.' as a separator won't work, as then it gets
mixed-up as to what part is the 3-letter suffix.

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.


>
> Most grateful regards to all.

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.



> --schremmer


Hope this helps,

     Ross

>
>
>
> ------------------------- 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/
>
>
>

------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114
------------------------------------------------------------------------


------------------------- 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