File: FAQ-grmaxwidth.html

package info (click to toggle)
tetex-base 3.0.dfsg.3-5
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 239,540 kB
  • ctags: 10,610
  • sloc: xml: 103,461; perl: 9,398; ruby: 2,850; python: 1,551; php: 1,067; sh: 981; lisp: 494; makefile: 371; awk: 88
file content (34 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<head>
<title>UK TeX FAQ -- question label grmaxwidth</title>
</head><body>
<h3>Limit the width of imported graphics</h3>
<p>Suppose you have graphics which may or may not be able to fit within
the width of the page; if they will fit, you want to set them at their
natural size, but otherwise you want to scale the whole picture so
that it fits within the page width.
<p>You do this by delving into the innards of the graphics package (which
of course needs a little LaTeX internals programming):
<blockquote>
<pre>
\makeatletter
\def\maxwidth{%
  \ifdim\Gin@nat@width&gt;\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother
</pre>
</blockquote>
This defines a "variable" width which has the properties you want.
Replace <code>\</code><code>linewidth</code> if you have a different constraint on the width
of the graphic.
<p>Use the command as follows:
<blockquote>
<pre>
\includegraphics[width=\maxwidth]{figure}
</pre>
</blockquote>
<p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=grmaxwidth">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=grmaxwidth</a>
</body>