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 36361 articles. 68 followers.

7 Replies
315 Views

Similar Articles

[PageSpeed] 19

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

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

A modified linspace
Hello, I'm trying to efficiently code a function that works like linspace, but instead of being linearly spaced, I would like to be able to specify the ratio of one step to the next. For example, a five value vector from 0.0125 to 0.015 with a scale of 0.8 would produce: [0.0125, .01335, .01403, 0.01457, 0.015] So, each "step size" is (approximately) 0.8 the size of the previous. I feel like this is another case of accumarray, but haven't come up with it. Thoughts? Chan Huntington <channing@umich.edu> wrote in message <1696305895.23012.1261068082256.JavaMail....

modifying data
Hi, I have a dataset ID1 ID2 A001 A002 A001 A003 A002 F001 F002 F001 F003 F002 If ID1 gets modified then the original ID1 is placed in the ID2 variable in the next observation. I need to track all the modified ID1's and replace them with the original ID1. expected output: ID1 A001 A001 A001 F001 F001 F001 Thanks as always, Sa On Fri, 10 Nov 2006 09:59:36 -0500, souga soga <souga1234@GMAIL.COM> wrote: >Hi, > >I have a dataset > >ID1 ID2 >A001 >A002 A001 >A003 A002 >F001 >F002 F001 >F003 F002 > > >If ID1 gets modified t...

Modify script
Below is a script i need to modify to work and its driving me nuts. Essentially it fades the content of an array. The original script specified the object name, I tried to modify it to allow an object to be passed instead as there are two fading areas on the page code below, to be honest I could see absolutely no reason why but im not that offay with javascript so this could be down to me. Deadlines are getting tight on this one so not bothered how its done but i need to be able to have fading content on the two specified areas, one statscroller the other newscroller. The second content ar...

Modifying legend
I have several lines/curves in a 2D plot, that can be lumped into 2 groups - one with solid line and black color, one with dashed lines and black color. In the legend, all the individual curves show up. But I only want to show 2 groups in the legend, i.e one corresponding to solid and one corresponding to dashed. How can I do this? Thanks in advance for your help. On 25 Okt, 15:47, "Aditya Garg" <garg_adi...@lycos.com> wrote: > I have several lines/curves in a 2D plot, that can be > lumped into 2 groups - one with solid line and black color, > one with dashed li...

includegraphics in a longtable ?
I have a problem including graphics in a longtable. When I add graphics to a table (putting a little figure in each row), I found that I can 'fix' the overall alignment of the row by adding a \vspace{0px} before the image, however this 'fix' fails in the longtable environment. Here is an example that demonstrates what I am talking about (note that I insert the '\vspace{0px}' using the array package); \documentclass[a4]{article} \usepackage{ graphicx, longtable, array } \begin{document} %% Problem with row alignment and included figure in a table ... ...

Brightness and includegraphics
I'd like to be able to change the brightness of an included eps. A quick google search showed that VTeX/GeX offer something like this. I'm not too familiar with VTeX...is there an LaTeX solution? \includegraphics[brightness=10]{test.eps} Thanks. Jack <Jacko@hotmail.com> writes: >I'd like to be able to change the brightness of an included eps. A >quick google search showed that VTeX/GeX offer something like this. I'm >not too familiar with VTeX...is there an LaTeX solution? > >\includegraphics[brightness=10]{test.eps} what do you mean by "b...

Modifying file
Hi, I have a file "test.txt" with the following content: MARKER ..a/b/c MARKER_2 ../test/test2 MARKER ..d/e/f MARKER_2 ../test3/test4 Now I want a new file to be written, but all lines with MARKER should be omitted and the lines with MARKER_2 should appear in the file without MARKER_2 at the beginning of the line: New file: .../test/test2 .../test3/test4 How can I accomplish that with a simple tcl scirpt ? Rgds, ALuPin On 29 jun, 10:25, Antonio Vazquez <antonio.vazquez.ar...@googlemail.com> wrote: > Hi, > > I =A0have a file "test.txt" with the foll...