A modified \includegraphics

Hi all,

I need a macro that includes a graph but automatically adds a
'width=\textwidth' parameter if the included graph is wider than
\textwidth. Any ideas? Thanks.

Leo
0
Leo
11/28/2009 11:07:37 AM
comp.text.tex 37543 articles. 0 followers. Post Follow

7 Replies
433 Views

Similar Articles

[PageSpeed] 45
On Nov 28, 6:07=A0am, Leo <sdl....@gmail.com> wrote:
> Hi all,
>
> I need a macro that includes a graph but automatically adds a
> 'width=3D\textwidth' parameter if the included graph is wider than
> \textwidth. Any ideas? Thanks.
>
> Leo

Dunno why graphicx doesn't have a maximum width function. workaround
is here

http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2007-08/msg00572=
..html

got it from the second entry here

http://tinyurl.com/yars8jv

0
Perkee
11/28/2009 11:38:40 AM
On 2009-11-28 11:38 +0000, Perkee wrote:
> On Nov 28, 6:07�am, Leo <sdl....@gmail.com> wrote:
>> Hi all,
>>
>> I need a macro that includes a graph but automatically adds a
>> 'width=\textwidth' parameter if the included graph is wider than
>> \textwidth. Any ideas? Thanks.
>>
>> Leo
>
> Dunno why graphicx doesn't have a maximum width function. workaround
> is here
>
> http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2007-08/msg00572.html
>
> got it from the second entry here
>
> http://tinyurl.com/yars8jv

Thank you for this. By the way the macro:

\newlength{\testwd}
\newcommand{\fitpic}[1]{%
  \settowidth{\testwd}{\includegraphics{#1}}%
  % \message{#1 width=\the\testwd, page=\the\textwidth}%
  \ifthenelse{\lengthtest{\testwd>\textwidth}}{%
    \noindent\includegraphics[width=\textwidth]{#1}}{%
    \centering\includegraphics{#1}}}

seems to use includegraphics twice. Is that expensive (slow)?

Thanks again.

Leo
0
Leo
11/28/2009 11:54:02 AM
Leo <sdl.web@gmail.com> wrote:

> I need a macro that includes a graph but automatically adds a
> 'width=\textwidth' parameter if the included graph is wider than
> \textwidth. Any ideas? Thanks.

\newcommand*{\maxwidth}{%  
  \ifdim\Gin@nat@width<\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother

\includegraphics[width=\maxwidth]{...}

Yours sincerely
  Heiko <oberdiek@uni-freiburg.de>
0
Heiko
11/28/2009 12:10:47 PM
On 2009-11-28 12:10 +0000, Heiko Oberdiek wrote:
> Leo <sdl.web@gmail.com> wrote:
>
>> I need a macro that includes a graph but automatically adds a
>> 'width=\textwidth' parameter if the included graph is wider than
>> \textwidth. Any ideas? Thanks.
>
> \newcommand*{\maxwidth}{%  
>   \ifdim\Gin@nat@width<\linewidth
>     \linewidth
>   \else
>     \Gin@nat@width
>   \fi
> }
> \makeatother
>
> \includegraphics[width=\maxwidth]{...}
>
> Yours sincerely
>   Heiko <oberdiek@uni-freiburg.de>

I've used this. Many thanks.

Leo
0
Leo
11/28/2009 1:27:10 PM
 Leo <sdl.web@gmail.com> writes:
>On 2009-11-28 11:38 +0000, Perkee wrote:
>> On Nov 28, 6:07�am, Leo <sdl....@gmail.com> wrote:
>>>
>>> I need a macro that includes a graph but automatically adds a
>>> 'width=\textwidth' parameter if the included graph is wider than
>>> \textwidth. Any ideas? Thanks.
>>
>> Dunno why graphicx doesn't have a maximum width function. workaround
>> is here
>>
>> http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2007-08/msg00572.html
>>
>> got it from the second entry here
>>
>> http://tinyurl.com/yars8jv
>
>Thank you for this. By the way the macro:
>
>\newlength{\testwd}
>\newcommand{\fitpic}[1]{%
>  \settowidth{\testwd}{\includegraphics{#1}}%
>  % \message{#1 width=\the\testwd, page=\the\textwidth}%
>  \ifthenelse{\lengthtest{\testwd>\textwidth}}{%
>    \noindent\includegraphics[width=\textwidth]{#1}}{%
>    \centering\includegraphics{#1}}}
>
>seems to use includegraphics twice. Is that expensive (slow)?

potentially, yes.  the next entry in the thread, from heiko oberdiek,
is the one i use (when i'm doing figures, which isn't often):

\documentclass{article}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\begin{document}
\noindent
\includegraphics[width=\maxwidth]{picture.png}
\end{document}

i _think_ i had worked it out independently, actually.  (let's claim i
did: heiko doesn't need any more glory, and i'm a mere drudge... ;-)
-- 
Robin Fairbairns, Cambridge
0
rf10
11/28/2009 3:03:57 PM
On 2009-11-28 15:03 +0000, Robin Fairbairns wrote:
> potentially, yes.  the next entry in the thread, from heiko oberdiek,
> is the one i use (when i'm doing figures, which isn't often):
>
> \documentclass{article}
> \usepackage{graphicx}
> \makeatletter
> \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
> \else\Gin@nat@width\fi}
> \makeatother
> \begin{document}
> \noindent
> \includegraphics[width=\maxwidth]{picture.png}
> \end{document}

I use this one too.

> i _think_ i had worked it out independently, actually. (let's claim i
> did: heiko doesn't need any more glory, and i'm a mere drudge... ;-)

;) 

Leo
0
Leo
11/28/2009 3:46:37 PM
rf10@cl.cam.ac.uk (Robin Fairbairns) wrote:

> \makeatletter
> \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
> \else\Gin@nat@width\fi}
> \makeatother
> \begin{document}
> \noindent
> \includegraphics[width=\maxwidth]{picture.png}
> \end{document}
> 
> i _think_ i had worked it out independently, actually.  (let's claim i
> did: heiko doesn't need any more glory, and i'm a mere drudge... ;-)

As far as I can remember, it isn't my invention, but I cannot remember
the exact source.

Yours sincerely
  Heiko <oberdiek@uni-freiburg.de>
0
Heiko
11/28/2009 4:55:21 PM
Reply:
Similar Artilces:

py script modify it's Modified Time?
I guess os.stat() could retrieve information about ctime, mtime of a path, but how can I change them? Is it possible to make it work both under Win32 and Linux? P.S. How to get the current running python? (Like WScript.ScriptFullName in vbscript) On Apr 11, 6:14 am, "est" <electronix...@gmail.com> wrote: > I guess os.stat() could retrieve information about ctime, mtime of a > path, but how can I change them? Is it possible to make it work both > under Win32 and Linux? > > P.S. How to get the current running python? (Like > WScript.ScriptFullName in vbscri...

Newbie question : How to modify the value of a field in Lotusscript ?
Hi, I'm sorry because my question may seem really stupid ! I want to change the value of the From field with the value of the INetFrom field. And I don't know how to do that... I'll explain you : I'm an admin and not a developper. And I got stuck by the paste agent int the mail.box :( All the mails I cut/paste in this new mail.box got their From field changed by my name... I saw that the INetFtom field contains the sender of the mail, so I want to correct my mistake. Thanks for your help !! nabjaf Open MAIL.BOX in Designer and create a new Agent Set ...

Re: Modifying styles using ODS escapechar= option #2
Chang, Thank you very much, that is it working now. You're right though, it is very silly, I would have spent the rest of the day on that. Cheers, Rob. _______________________________________________________ This e-mail transmission and any documents, files or previous email messages attached to it may contain information that is confidential or legally privileged. If you are not the intended recipient or a person responsible for delivering this transmission to the intended recipient, you are hereby notified that you must not read this transmission and that any disclosure, copying, pri...

Class & modifiers modifiers
Hi I want to make a question to all the ruby-lang people (I hope that somebody answered it). I'm writing a database GUI and I'm coding the backend using modules and classes. If I have this situation: module A protected def b_method() return 'foo->A' end end class B include A def b_method() return 'foo->B' end end Is B's method b_method() protected? Is it public? What the hell is this method (;-) ) ? Thanks in advance Kind regards Miquel ______________________________________________ LLama Gratis a cualquier PC del Mundo. ...

Modified Wavelets Coefficients
Hello Friends For a Watermarking application, I am taking the discrete wavelet transform of an audio signal using wavedec(). I am modifying some of the coefficients and Cm be the modified set of wavelet coefficients. When I reconstruct the signal using waverec() and then take the wavelet transform again using wavedec(), the resulting wavelet coefficients are way different than Cm. I am using 3 level dB4 wavelets. Can somebody tell me what I am doing wrong? ...

R3 Online Modify
Dear All, I haven't had tiem to read all the R3 docs so hopefully someone can point me in the right direction. I have a base table plus a number of secondary indexes. In order to perform an online modify, I issued a modify ... with concurrent_updates. This appears to work ok and it drops the secondaries. How do I get ingres to recreate the secondaries whilst sessions are connected - there doesn't appear to be a concurrent_updates on the with clause of 'create index'. Persistent indexes? Thanks John John Young wrote: > Dear All, > > I hav...

modifying a headshot with gimp
Hi there, i am quite clueless when it comes to image manipualtion. does anyone know how to modify a headshot (for employment / ID purpose) so that a person's face looks slimmer and the overal length of his/her head (from the top of the head to the chin) doesn't appear as long (the so-called horse face) thank you a mil. Kris wrote: > Hi there, > > i am quite clueless when it comes to image manipualtion. > does anyone know how to modify a headshot (for employment / ID purpose) > so that a person's face looks slimmer and the overal length of his/her > head (from...

how to modify...
i have in a xml file this <post> <titolo>Forno solare</titolo> <data>28/08/2006</data> <testo> Ecco il mio forno solare, bla , bla, bla , bla, bla , bla.... </testo> </post> and in xsl file this: <div id="post"> <xsl:for-each select="news/post"> <xsl:sort data-type="text" select="data" order="descending"/> <h1><xsl:value-of select="titolo" /></h1> <...

I have some questions about this modified String class
I have the following script that I just have only slight changes in the hash from "Why's poignant guide to Ruby" book: http://pastie.org/private/ojmcfglofwloqemqmuhra I have those questions regarding the script: 1- I have inserted this method call after the class: puts "Abder-Rahman-is-my-name".name_significance And, got the following message: sub.rb:7:in `name_significance': undefined method `[]' for nil:NilClass (NoMethodError) from sub.rb:6:in `collect' from sub.rb:6:in `name_significance' from sub.rb:1...

Perl/Tk, CheckButtons, and modifying variables
I'm trying to use a series of CheckButtons, and all is going pretty well. However, I want to change the associated variable and have it reflected in the CheckButton. I'm not sure of how to do this. I searched through Google Groups and Google Web and found nothing. Because of the number of CheckButtons in my case (300) they are split up into 10 columns on screen in 10 different frames (which shouldn't matter). The Checkbuttons are actually stored in a Ruby hash (based on a text string - server name, in this case). I created a series of associated TkVariables in a related hash,...

How to modify registry (xp) (newbie)
Hi, where can I find such info, so my aplication can mess with Bill Gates :-) any clues regards OsAC wrote: ... > where can I find such info, JNI >..so my aplication can mess with Bill Gates :-) I'll wager Bill can do way more to your software, than you can to his (especially from Java). ;-) Andrew T. hehe, thx m8 /me goes to read docs ... :-(((( "Andrew Thompson" <andrewthommo@gmail.com> wrote in message news:1163957000.105747.67120@h54g2000cwb.googlegroups.com... > OsAC wrote: > .. >> where can I find such info, > > JNI > >...

Modify it !
Hello to all, I have made a calendar from 1900-2000(Except leap years which i do my own!)It gives you the day when inputting the month and date. I want to know how can i improve it in terms of complexity(of concepts).Waiting for your creative ideas james. ------------------------- #include<conio.h> #include<stdio.h> void days(int); int *cal(int,int,int); void main() { char ch='y'; int month=0,date=0,i,year,year1,*day; clrscr(); printf("\t\t\t\tCALENDAR \n\n\t\t\t 1900--2000\n\n"); printf("\n Enter the year(1900-2000)"); scanf("%d",&...

Modifying the sptool
Hi, I would like to add some features to the signal processing toolbox. For one, I would like to be able to plot multiple Signals in one window below each other. Secondly, I would like to add the ability to generate a spectrum from just the part of a signal that is between the two markers. (This can easily be done manually, but I would like to automize it 'on Click'). Now, what is the proper way to do this? Is there any tutorial (not necessaryly for this toolbox) demonstrating how to add features to a toolbox? Greets, Hendrik ...

How to modify a correction on lots of drawings
Hello, Maybe someone might be able to help me with this lets say I have close to 100 dgn drawings and there are typo and lots of line style that are incorrect on all the same sheets. How can I make one change so that all the corrections will be made on all the other 100 dgn drawings. I am using Microstation J se. thanks It's a bit difficult to say without knowing the specific changes but you could try recording a macro ('|Utilities', 'Create Macro') whilst performing the steps on one drawing. The ones you have mentioned could probably be achieved with the...

Modify Icons?
I would like to have non-standard icons for certain folders (that I've put in my dock). How do I do this? If there's a set of already made icons even better. thanks dick Dick Sidbury <DrJamesSidbury@hotmail.com> wrote: > I would like to have non-standard icons for certain folders (that I've > put in my dock). How do I do this? Get Info (in the Finder) and paste into the icon area. m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Tiger - http://www.takecontrolbooks.com/tiger-customizing.html AppleScript - http://www.amazon.com/gp/produ...

lvalue -modifiable and non-modifiable
Can someone give and explain in simple terms a definition of lvalue? Also what are these modifiable and non-modifiable lvalues? I always thought that, if we can assign to anything then that anything is lvalue and if cannot assign to anything then that anything is not lvalue. "Kavya" <Lerner84@gmail.com> wrote: > Can someone give and explain in simple terms a definition of lvalue? Sure. The Standard can, in [6.3.2.1#1]: # An lvalue is an expression with an object type or an incomplete type # other than void; > Also what are these modifiable and non-modifiable lvalues...

How can a string by accidently modified?
Given the following code that achieves no useful purpose: #include <string.h> #include <stdio.h> #include <string.h> int manip(char *str) { size_t len = strlen(str)-1; if(len >= 3) { str[0] = 'A'; str[1] = 'B'; printf("The length of the string is: %d\n", len); } else { return -1; } } int main(int argc, char **argv){ if(argc !=2){ fprintf(stderr,"Not enough arguements\n"); exit(1); } manip(argv[1]); printf("The modified value is: %s\n",argv[1])...

SCO modifies SEC filing to include more whining
A few hours after Groklaw posted SCO's mods to its SEC filing, here are even more mods! Weird ones, ones that, to me, indicate that SCO is now lying in its filings. http://www.groklaw.net/article.php?story=20040116230648322 -- No, I won't fix your Windows computer! On Sat, 17 Jan 2004 08:40:19 -0600, Lin�nut <lin�nut@bone.com> wrote: >A few hours after Groklaw posted SCO's mods to its SEC filing, >here are even more mods! Weird ones, ones that, to me, indicate >that SCO is now lying in its filings. > >http://www.groklaw.net/article.php?story=20040116230...

modifying system palette
How can I modify system palette in 8bit video resolutions? http://msdn.microsoft.com/library/en-us/gdi/colors_6trn.asp -- Tim Robinson (MVP, Windows SDK) http://www.themobius.co.uk/ "/dev/null" </dev/null@localhost.ld> wrote in message news:bt1pb8$d0v$1@nemesis.news.tpi.pl... > How can I modify system palette in 8bit video resolutions? > ...

RE: modifying mutable list elements in a for loop
Hi, I'm no expert in python (only a beginner), so my words here probably should be taken with caution... Anyways i would think you are fine. You didn't modify the sequence that comprises 'a'. A is a list of objects. the list stayed the same. Each object did indeed change, but the reference to them (stored in a) hasn't changed). Therefore I would think its ok. However, I will eagerly wait and see how the gurus answer this question as it will be a good learning experience. David ------- Cell: http://cellphone.duneram.com/index.html Cam: http://www.duneram.com/c...

How to modify/edit smart objects in CS3?
What's the most direct way to modify/edit a smart objects\ in CS3? I know I can rasterize it, do my edits, and convert it back to smart object, but is there a more direct way? How about creating a group, adding the object to the group, and editing the group maybe? On May 11, 12:07 pm, "Zilla" <zill...@XSPAMbellsouth.net> wrote: > What's the most direct way to modify/edit a smart objects\ in CS3? > I know I can rasterize it, do my edits, and convert it back to smart > object, but is there a more direct way? How about creating a group, > adding the object ...

MODIFY with BY-groups?
I would like to do the following: data sql.bigtab; retain firstx; modify sql.bigtab; by var1 var2 ... var50; if first.var50 then firstx=x; if last.var50 then do; price=price*2; x=firstx; replace; end; run; But with MODIFY this is not possible because BY is used with another meaning with MODIFY. Any idea how to solve this? I cannot use "SET" because I'm modifying a SAS/ACCESS table. Jens Martin Schlatter ...

modified a*?
The following problem: Given a 2D array of integers, starting at a point A (x, y), find the LONGEST way, so that the summed up values along the way don't exceed some given value N. Any ideas? sauron wrote: > The following problem: > > Given a 2D array of integers, starting at a point A (x, y), find the > LONGEST way, so that the summed up values along the way don't exceed some > given value N. > > Any ideas? If your integers can be negative then this problem is likely to be NP, so I'll assume that all integers are non-negative. Furthermore, I'll ass...

Modifying $_ in "map", with an array containing a gap... #2
Hello, I'm sorry I'm not good at English. :-) foreach and map functions show the same result when an array has no gap. @array = (1, 2, 3, 4); foreach (@array) { $_ *= 10 } # now, $array = (10, 20, 30, 40) @array = (1, 2, 3, 4); map { $_ *= 10 } @array; # now, $array = (10, 20, 30, 40) However, if an array contains a gap... 1 $array1[0] = 0; 2 $array1[9] = 9; # now $array1 = (0, undef, undef, ... , 9); 3 print "@array1", "\n"; # 0 "" "" ... "" 9 4 foreach (@array1) { 5 $_ *= 10 ...

Modifying values in the PhysicalConstants package
I note that the symbols defined in the PhysicalConstants package, like HubbleConstant, do not have the attribute Protected. Is it "safe" to give redefinitions for these symbols in my code? That is, is there any reason why I shouldn't write the following? Needs["PhysicalConstants`"] HubbleConstant = Convert[70*((Kilo*(Meter/Second))/(Mega*Parsec)), 1/Second]; ...