COMPGROUPS.NET | Post | Groups | Users | Stream | Browse | About | |

### A modified \includegraphics

• Email
• Follow

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

See related articles to this posting

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

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

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

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

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
 comp.text.tex 37175 articles. 72 followers.

7 Replies
396 Views

Similar Articles

[PageSpeed] 31

• Email
• Follow

Similar Artilces:

\includegraphics and \includegraphics* difference
Does anyone know what is the difference between \includegraphics and \includegraphics* (yes, with a *)? montecinos.julio@gmail.com writes: > Does anyone know what is the difference between \includegraphics and > \includegraphics* (yes, with a *)? ,----[ grfguide, 4.4 Including Graphics Files ] | If * is present, then the graphic is clipped' to the size specified. If | * is omitted, then any part of the graphic that is outside the specified | bounding box' will over-print the surrounding text. `---- or read epslatex.{ps,pdf} cheerio ralf <montecinos.julio@gmail.com>...

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

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

\includegraphics
Hi! I wanted include graphics with this command. I tested it with jpeg files (i read that that should be supported), but i get an error. How can i include jpeg files? Thanks, flox Florian Xaver wrote: > Hi! > > I wanted include graphics with this command. I tested it with jpeg files > (i read that that should be supported), but i get an error. > How can i include jpeg files? > > Thanks, flox That should be possible if you add something where you include the package "graphicx": \ifx\pdftexversion\undefined \usepackage[dvips]{graphicx} \else \usepackage[...

includegraphics
I have this odd problem. Heres is what i use, in a subsubsection, to include a picture: \begin{figure} \includegraphics[width=8cm,height=6cm]{Misc/loga.jpg} \end{figure I then compile the tex file with pdflatex. The odd thing is when i look through the pdf file the includedgraphics loga.jpg is placed roughtly 1 page above where it should be located. What could be wrong? cp wrote: > I have this odd problem. > > Heres is what i use, in a subsubsection, to include a picture: > > \begin{figure} > \includegraphics[width=8cm,height=6cm]{Misc/loga.jpg} > \end{figure > &...

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",&...

vintage disk drive dilema
Hi Folks, I figured I throw this dilema out there as something that all users of vintage articles have to deal with from time to time. I strongly believe that this old stuff should be used from time to time, but there are usually compromises involved in such usage. I am currently using my original Disk II drive which I purchased in 1978. Right now I am using it as drive 1 on my primary Apple II and it works fine, except that it does not do well reading Atarisoft game disks. Unfortunately I find that those old time games are kind of fun, and I would like to play those games from t...

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

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

RE:vintage disk drive dilema
This is a followup to a post I made last April. Basically I had an old Disk II analog board that didn't perform well when reading Atarisoft Disks. I was considering whether I should modify this early rev analog board to add a resistor to hopefully increase the read circuits tolerance of noise. This is a change that Apple put into newer analog cards but my first generation card did not have this mod. I finally decided I could make the change without damaging the value of the board by lifting one lead of a resistor and using wirewrap technology to insert a 5K pot between the resistor lead...

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

How can I identify whether the file is modified with touch or it is modified manually?
I want to identify whether a file is really modified or it is done by using touch command? How can I find that? On Dec 19, 1:18 am, lak <lakindi...@gmail.com> wrote: > I want to identify whether a file is really modified or it is done by > using touch command? > How can I find that? You can't. On Wed, 19 Dec 2007 01:18:17 -0800, lak wrote: > I want to identify whether a file is really modified or it is done by > using touch command? > How can I find that? Hi, You could try to use some hashing functions similarly to "md5sum" program, but this of cours...

Modify a file's date & time without modifying the file (or opening it)
Just in case you ever need this. We run a lot of �monitor� programs that look at the date and time of a file to see if a particular application is �alive and well�. In the past we had been simply writing another line to the file each time the application program cycled. This (of course) meant that the file grew proportional to how often the application cycled. With this routine, the file never grows, but still provides the desired results. Hope you can find a use for it. Lee (Obviously this is Object Rexx on Windows) /* touchfile.rex */ call SysCls parse arg myfile path = filespec(&#...

Text widget: <<Modified>> and the "edit modified" command
Dear TCLers, From Tk 8.5 Reference about the text widget: "...The flag can be queried, set and cleared programmatically as well. Whenever the flag changes state a <<Modified>> virtual event is generated." Well, this is more or less what I did in two procedures, both under the same namespace (I don't know if this makes a difference, but however): proc ns::TextWdgSetup { txtwdg } { ... bind $txtwdg <<Modified>> "[namespace code StatusChange] %W" } proc ns::StatusChange {txtwdg} { # Test line: set status [$txtwdg edit modifie...

I Don't Want A Machinist To Modify "My Part" / Why Would A Machinist Need To Modify A Customers Part?
In my opinion the people who make this kind of statement are idiots who often show they have no idea how manufacturing works in the real world. The people who make these kinds of statement are morons like Matt Lombard, Joe 788, Tom Brewer, etc. For those who think these worthless idiots have a clue perhaps this video will give you some ideas why a machinist must have the ability to modify a customers part in order to make it. http://www2.spaceclaim.com/LearnMoreNow/ConseptualDemo.aspx Jon Banquer San Diego, CA http://jonbanquer.blogspot.com/ On Fri, 18 Jul 2008 22:43:44 -0700 (PDT), jon_...

how modify $: permanently? Is there a way to add a path to$: permanently so I don't have to append a path at the start of every script that needs it? -- Posted via http://www.ruby-forum.com/. Greg Willits wrote: > Is there a way to add a path to $: permanently so I don't have to append > a path at the start of every script that needs it? Use the RUBYLIB environment variable. From man ruby: RUBYLIB A colon-separated list of directories that are added to Ruby?s library load path ($:). Directories from this environment variable are searched before the standard ...

modifying ode23t
I've been posting threads about my trouble fiddling with the ode23t solver to make it more efficient. After reading through a ton of matlab help files, I find this: Q. My integration proceeds very slowly, using too many time steps. A. First, check that your tspan is not too long. Remember that the solver uses as many time points as necessary to produce a smooth solution. If the ODE function changes on a time scale that is very short compared to the tspan, the solver uses a lot of time steps. Long-time integration is a hard problem. Break tspan into smaller pieces. If the ODE function doe...

modify data
Is there an easy way to modify table data (DML) using the new 10g web interface (without SQL)? I can figure out how to view it but not how to add new rows, etc. mike7411@gmail.com wrote in news:1158012541.704459.200420@b28g2000cwb.googlegroups.com: > Is there an easy way to modify table data (DML) using the new 10g web > interface (without SQL)? > > I can figure out how to view it but not how to add new rows, etc. > > How do you "view it" without SQL? AFAIK, Oracle only understand two languages, SQL & PL/SQL. It appears you know TLA, but not what they m...

Modifying equations
Hello My intention is to write a mathematical paper which derives results step by step. So here is my first question: Given the equations eqn1 = a == b eqn2 = c == d How can I combine these to form (for example) a + c == b + d ? I tried the obvious eqn1 + eqn2, but that does not seem to work... Second question: Given this: Sum[a_i, {i, 0, n}] + Sum[b_i, {i, 0, n}] How can I make Mathematica combine the sums giving: Sum[a_i + b_i, {i, 0, n}] ? Thanks. Hi Kalle, see below. sincerely Daniel Kalle Rutanen wrote: > Hello > > My intention is to w...

NukePHP
I'm using a few modules within an existing website, particularly a Calendar. If I create the required extra fields in the DB, is it possible to modify the existing inut/output to include this field? Regards, Ranga ...

How do I modify a selection ?
I use version 1.2.5 of The Gimp. It's an old version, but what I'm trying to do is a most basic operation when, say, you want to create a picture for a desktop: I want to modify a selection while keeping the aspect ratio. I found out that you can create a selection of a given ratio by going to the Dialog menu(1) of the selection tool. This dialog menu only appears in the File menu of the GIMP interface, not if you right-click on the picture. I have then found all kind of ways to bend the selection left and right, but absolutely no way to do the most basic opereation: en...

Modifying ls
I want to some how modify the contents of a ls listing to only display the filename and the time it was modified. Example if I do ls -lt drwx------+ 1 mkrishnamoorthy Domain Users 0 Feb 16 17:32 Application Data -rwx------+ 1 mkrishnamoorthy Domain Users 188757 Feb 8 16:12 trial.pdf -rwx------+ 1 mkrishnamoorthy Domain Users 349544 Feb 8 15:55 IEEEtran.tar. I just want the time and the file name, that is Feb 16 17:32 Application Data How can I push that information into an array. \$array = 'ls -t' and usr array[1] to get the latest file. Thanks manian.k@gmail.c...

How do I modify a string?
I am trying to write a routine which follows this logic, but not sure how to implement: <script> xxx = "... apple green yellow blue ..."; {right here I need to modify part of the string, so i.e. just 'green' in the string above would become 'purple''} alert(xxx); </script> How can I do this? Thank you!! :)) amyx...@gmail.com wrote: > I am trying to write a routine which follows this logic, but not sure > how to implement: > > <script> > xxx = "... apple green yellow blue ..."; > > {right here I need to modify...

format modifier
Hi I've seen a code that uses ??, as below input(date,??yymmdd10.); Just wondering what the function of ?? is?. I've tried hard but could not find any documentation on this. Thanks in advance ?? means don't tell me how bad my data is. It is documented on the INPUT statement. INPUT(source, <? | ??>informat.) Arguments source contains the SAS character expression to which you want to apply a specific informat. ? or ?? The optional question mark (?) and double question mark (??) format modifiers suppress the printing of both the error messages and the input lines when...