Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie: redefining includegraphics to do nothing.

312 views
Skip to first unread message

Phillip Lord

unread,
Jul 2, 2001, 8:04:00 AM7/2/01
to

My apologies for the newbie question. I've just
started using latex, and pleased with the results.

I'm a little confused over defining new commands
though. I'm using the graphicsx package to include postscript. It
works nicely. Some of my figures are quite large though, which means I
can't get everything onto a floppy. I thought it would be able to
redefine the includegraphics command. This way I could remove all of
the graphics in the preamble.

So I tried....

\renewcommand{\includegraphics}[1]{\textbf{Insert #1 here}}

which works quite nicely with commands of the form

\includegraphics{figure.eps}

but baulks on commands such as

\includegraphics[width=1\textwidth]{figure.eps}


The question then is simple enough. How do I define
commands with optional parameters in square brackets?

Phil

Gert und Ulrike Fischer

unread,
Jul 2, 2001, 8:18:40 AM7/2/01
to

Phillip Lord schrieb:

\renewcommand{\includegraphics}[2][]{\textbf{Insert #2 here}}

should work. But why don't you use the draft-option of the
graphicx-package?

Ulrike Fischer

Michael Dewey

unread,
Jul 2, 2001, 8:34:27 AM7/2/01
to Phillip Lord

Phillip Lord wrote:
[snip, he wants to redfine a command with optional parameter]



> The question then is simple enough. How do I define
> commands with optional parameters in square brackets?
>

well I suppose \newcommand{name}[n of args][optional]{definition}

I think They recommend that you use a new command of your own
devising (say \mygraphics) and then in your preamble have two different
definitions of it: one to pass through to actually include the graphics,
and the other to give your suggested message instead. Then you do not
have to redefine standard commands which might have unpredicatble
consequences

--
Michael Dewey
Trent Institute for Health Services Research

mailto:Michae...@nottingham.ac.uk
http://www.nottingham.ac.uk/~mhzmd/home.html

Phillip Lord

unread,
Jul 2, 2001, 9:11:14 AM7/2/01
to
>>>>> "Gert" == Gert und Ulrike Fischer <Nililand...@t-online.de> writes:

>> \includegraphics{figure.eps}
>>
>> but baulks on commands such as
>>
>> \includegraphics[width=1\textwidth]{figure.eps}
>>
>>
>> The question then is simple enough. How do I define commands with
>> optional parameters in square brackets?

Gert> \renewcommand{\includegraphics}[2][]{\textbf{Insert #2 here}}

Gert> should work.

It does indeed.

Gert> But why don't you use the draft-option of the
Gert> graphicx-package?


Two reasons. Firstly as I said I am new to latex.
New enough that I didn't know where the package documentation was, so
I didn't know that a draft option existed! Secondly it doesn't do what
I wanted. The draft option still checks the eps file to get an
appropriately sized bounding box. I want the latex to compile in the
absence of the eps files.


>>>>> "Michael" = Michael Dewey <michae...@nottingham.ac.uk> writes


Michael> I think They recommend that you use a new command of your
Michael> own devising (say \mygraphics) and then in your preamble
Michael> have two different definitions of it: one to pass through
Michael> to actually include the graphics, and the other to give
Michael> your suggested message instead. Then you do not have to
Michael> redefine standard commands which might have unpredicatble
Michael> consequences

Yes this makes sense. I shall do that!

Thank you both for your help.

Phil

Gert und Ulrike Fischer

unread,
Jul 2, 2001, 10:33:53 AM7/2/01
to

Phillip Lord schrieb:


>
> Gert> But why don't you use the draft-option of the
> Gert> graphicx-package?
>
> Two reasons. Firstly as I said I am new to latex.
> New enough that I didn't know where the package documentation was, so
> I didn't know that a draft option existed! Secondly it doesn't do what
> I wanted. The draft option still checks the eps file to get an
> appropriately sized bounding box. I want the latex to compile in the
> absence of the eps files.
>

But if you include the bb-information in the includegraphics-command
latex will compile without the eps-files:

\documentclass{article}
\usepackage[draft]{graphicx}

\begin{document}
\includegraphics[bb=0 0 100 100, width=\textwidth]{anunknowpicture.eps}

\end{document}


Ulrike Fischer

Phillip Lord

unread,
Jul 2, 2001, 11:06:52 AM7/2/01
to
>>>>> "Gert" == Gert und Ulrike Fischer <Nililand...@t-online.de> writes:

Gert> Phillip Lord schrieb:


>>
Gert> But why don't you use the draft-option of the
Gert> graphicx-package?
>> Two reasons. Firstly as I said I am new to latex. New enough
>> that I didn't know where the package documentation was, so I
>> didn't know that a draft option existed! Secondly it doesn't do
>> what I wanted. The draft option still checks the eps file to get
>> an appropriately sized bounding box. I want the latex to compile
>> in the absence of the eps files.
>>

Gert> But if you include the bb-information in the
Gert> includegraphics-command latex will compile without the
Gert> eps-files:

Gert> \documentclass{article} \usepackage[draft]{graphicx}

Gert> \begin{document} \includegraphics[bb=0 0 100 100,
Gert> width=\textwidth]{anunknowpicture.eps}

Fair enough. Of course then I have to work out what
the bounding box is for my eps files, but this would be a good
solution.

Cheers

Phil

Gert und Ulrike Fischer

unread,
Jul 2, 2001, 11:16:13 AM7/2/01
to

Phillip Lord schrieb:
>

> Gert> But if you include the bb-information in the
> Gert> includegraphics-command latex will compile without the
> Gert> eps-files:
>
> Gert> \documentclass{article} \usepackage[draft]{graphicx}
>
> Gert> \begin{document} \includegraphics[bb=0 0 100 100,
> Gert> width=\textwidth]{anunknowpicture.eps}
>
> Fair enough. Of course then I have to work out what
> the bounding box is for my eps files, but this would be a good
> solution.

That's easy: you only need to open the eps in an editor. The
bb-information is at the top. Or you use ghostview, and let you show the
bb-info.

Ulrike Fischer

Victor Wagner

unread,
Jul 13, 2001, 3:07:23 PM7/13/01
to
Phillip Lord <p.l...@hgmp.mrc.ac.uk> wrote:
:>>>>> "Gert" == Gert und Ulrike Fischer
<Nililand...@t-online.de> writes:


: Two reasons. Firstly as I said I am new to latex.
: New enough that I didn't know where the package
documentation was, so
: I didn't know that a draft option existed! Secondly it
doesn't do what
: I wanted. The draft option still checks the eps file to get
an
: appropriately sized bounding box. I want the latex to
compile in the

But you can just extract bounding box statements from your eps
files into very small files with appropriate extension
(say .bbx) and specify this extension in the read option of
includegraphics

\includegraphics[read=.bbx,ext=.eps]{somefigure}

then TeX would search only for somefigure.bbx when processing document,
but dvips would include somefigure.eps when generating final Postscript
output.

Extracting bounding box is simple enough, just

grep '^%%BoundingBox' somefigure.eps > somefigure.bbx

gre
(and if you are so unfortunate, that have to work under some M$
operating system which deprives you of such basic human right
as to use normal text utilities, there is number of places where
you can get one for free. For example, on
http://community.borland.com/museum, there is Turbo C 2.0, which
includes version grep which would work even on XT with 8088 processor.
Of course, cygnus or djgpp suite is better).



--
The most important service rendered by the press is that of educating
people to approach printed matter with distrust.

Dan Luecking

unread,
Jul 16, 2001, 4:55:46 PM7/16/01
to
vi...@wagner.rinet.ru (Victor Wagner) wrote in message news:<9ingtb$7er$1...@wagner.wagner.home>...

>
> Extracting bounding box is simple enough, just
>
> grep '^%%BoundingBox' somefigure.eps > somefigure.bbx
>
> (and if you are so unfortunate, that have to work under some M$
> operating system which deprives you of such basic human right
> as to use normal text utilities,

This is so basic even MS-DOS can do it:
find "%%%%BoundingBox" fig.eps > fig.bb
so none need feel deprived.

Dan Luecking

0 new messages