f



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 38671 articles. 1 followers. Post Follow

7 Replies
648 Views

Similar Articles

[PageSpeed] 59

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:

Obfuscating PDFs typeset with TeX, or modifying the underlying text in a PDF
I'd like to create PDFs using (La)TeX which are readable by humans but cannot be read by naive automated techniques. For example, it should not be possible to copy plain text out of the document. One easy way to do this, I realize, would be typesetting the document normally then taking a screenshot of each page and creating a new document containing only images. Unfortunately, should the (human) reader want to zoom in, he would find that the resolution is limited and everything would become blocky. A while back I did a Google search to determine how to obfuscate PDFs in this way. I found ...

Dynamic text: modify text by image/link click
Hello, The effect i'm trying for: Tha tthe user clicks an image, and a line of text on the page changes. I'd like to make it so that this could be done over and over with different links. But this isn't working. I think the problem is related to a refresh not happening, but I'm just learning the javascript ropes. Thanks in advance for your help. -Dave --code follows *attempt*1* var avar = 'beforeclick'; //defined in body //included document.write(avar) in text. it shows up in text, but doesn't change on click. function newtext(){ document.write(avar); return fal...

text-text
Wondering how what I input to my UTF-8 terminal gets passed along through my patched [1] trn ... Cyrillic: А Б В Г Д Е Ж З И Й К Л М Н О П а б в г д е ж з и й к л м н о п IPA: ᴀ ᴁ ᴂ ᴃ ᴄ ᴅ ᴆ ᴇ ᴈ ᴉ ᴊ ᴋ ᴌ ᴍ ᴎ ᴏ ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ [1] https://groups.google.com/d/msg/comp.sys.raspberry-pi/7Z37Hdrm0DM/6aqD-reXFzAJ ...

text + text
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do this. And MS SQL Server too, I think (CMIIW). -- dave ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org Am Freitag, 8. Oktober 2004 12:57 schrieb David Garamond: > What is "text + text" supposed to do right now? Nothing. > What a...

modifying text
I would like to be able to make text into a real sketch so I can edit individual letters to make it easier for the guys making the EDM electrodes. For example I would want to remove the crossbar on a "T" and then make another part that has the crossbar present and the vertical bar missing. The cutters can't get into the sharp inside corners, so we'd like to make our EDM electrodes in 2 or more pieces to allow the inside sharp corners to be burned into the mold. Is it possible to edit parts of the letters as a sketch, but leave most of the letters alone? Thanks -- Bill Ch...

How can I modify the name of the text section which is by default ".text"
When C source code is compiled into an object file (.o), the functions are put into the .text section. Is it possible that I put all functions to a renamed text section whose name may be ".text.app". When linking several .o files into an executable, I need to put the code of .o files into different positions(in MCU). If I can rename the text section of object files, I can set different section start addresses for each section. LinNan wrote: > When C source code is compiled into an object file (.o), the functions > are put into the .text section. > Is it possible that I p...

Created text as raster, can I convert it to vector so I can modify text
I want to be able to edit it, but since it is raster, I can't. Do i just need to re-create the wheel? twice_redeemed@yahoo.com wrote: > I want to be able to edit it, but since it is raster, I > can't. Do i just need to re-create the wheel? When you created the text as raster, you painted it into the image, replacing the pixels that were there. You will need to re-create those pixels, either from a before-text copy of the image or by retouching the image you have. Then write your vector text and leave it on its own vector layer, saving your master copy in PspImage format f...

Created text as raster, can I convert it to vector so I can modify text
I want to be able to edit it, but since it is raster, I can't. Do i just need to re-create the wheel? twice_redeemed@yahoo.com wrote: > I want to be able to edit it, but since it is raster, I > can't. Do i just need to re-create the wheel? When you created the text as raster, you painted it into the image, replacing the pixels that were there. You will need to re-create those pixels, either from a before-text copy of the image or by retouching the image you have. Then write your vector text and leave it on its own vector layer, saving your master copy in PspImage format f...

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

setting TeX text variable depending on keyval-generated param? (low-level TeX question)
I am using keyval to set a "scaled" parameter and am having trouble getting the right behavior, which is: If I \usepackage{package} with no [scaled] option, I want to set a variable to a compile-time-specified default, say "s*[a.b]". If I \usepackage[scaled]{package}, same thing. And if I \usepackage[scaled=x.y], I want to set the variable to "s*[x.y]". (This is for font scaling, and I've used as my model the Helvetica scaled parameter.) The variable name (for the purposes of this conversation) is pnm@scaled. What I have that's not working correctly i...

Modifying desktop text
There was this program once called Desktop Architect. Amongst other things, it changed the text on the desktop icons. How could this be accomplished? It's not the effect I need to know, but how to get it on the desktop. The only solution I could think of was to create a new maximized window, use PaintDesktop() and then redraw the icons. I'm sure there must be an another way. The text used by the desktop icons is a windows setting (display properties > appearance > Advanced > select Icon in the Item: list). The font name, style and size is saved in the registry. You...

Modify a text field
I've a text field with the name of pubs/disco etc like these the l'arch new's road I would to create new text without spaces and ' ..... the_l_arch new_s_road please note that I could have (for example) the l'arch or the l' arch or the l 'arch or the l ' arch or the l'arch or the l 'arch .... but I want always to obtain: the_l_arch thanks for help me!! luca schreef: > I've a text field with the name of pubs/disco etc > > like these > > the l'arch > new's road > > I would to create new text without s...

XmText: has the text been modified ?
Is there a simple way to find out if text in a XmText widget has been modified ? eg: something akin to a boleean XmTextGetModified(widget *wdg) routine that would return true or false. Failing that, the documentation on the XmNvalueChangedCallback is somewhat cryptic. It mentions: ## The XmNvalueChangedCallback should occur only in pairs with a XmNmodifyVerifyCallback, assuming that the doit flag in the callback structure of the XmNmodifyVerifyCallback is not set to False. ## Does this mean that in order to find out if a XmText widget has has it text modified, I need to se...

Text style to modify
1. From the properties option to go directly to the text style that contain at the same time the type of letter. 2. From the corresponding menu to change this last to which better knows. 3. Automatic they will be updated the texts ( included those of levels), to the type of letter selected. I wait serves the explanation; Regards to all. ...

Web resources about - A modified \includegraphics - comp.text.tex

Information Systems - Elsevier
Information Systems-Guide for Authors

documentclass[12pt,a4paper]{article} usepackage[T1]{fontenc} usepackage[utf8]{in - Pastebin.com
PASTEBIN - #1 paste tool since 2002 create new paste tools api archive faq PASTEBIN create new paste trending pastes sign up login my alerts ...

UPDATE 2-Apple takes wraps off new MacBook Pro lineup
* Features Intel processor, AMD graphics chip * Price of 13-inch model starts at $1,119 * AMD shares gain 5.5 percent (Adds detail on graphics ...

porton - planetmath.org
% this is the default PlanetMath preamble. as your knowledge% of TeX increases, you will probably want to edit this, but% it should be fine as ...

Icarus - Elsevier
Icarus-Guide for Authors

milogardner - planetmath.org
% this is the default PlanetMath preamble. as your knowledge% of TeX increases, you will probably want to edit this, but% it should be fine as ...

rspuzio - planetmath.org
% this is the default PlanetMath preamble. as your knowledge% of TeX increases, you will probably want to edit this, but% it should be fine as ...

pahio - planetmath.org
% this is the default PlanetMath preamble. as your knowledge% of TeX increases, you will probably want to edit this, but% it should be fine as ...

akdevaraj - planetmath.org
% this is the default PlanetMath preamble. as your knowledge% of TeX increases, you will probably want to edit this, but% it should be fine as ...

m759 - planetmath.org
% this is the default PlanetMath preamble. as your knowledge% of TeX increases, you will probably want to edit this, but% it should be fine as ...

Resources last updated: 2/2/2016 9:23:16 PM