File: FAQ-topgraph.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 (42 lines) | stat: -rw-r--r-- 1,506 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
35
36
37
38
39
40
41
42
<head>
<title>UK TeX FAQ -- question label topgraph</title>
</head><body>
<h3>Top-aligning imported graphics</h3>
<p>When TeX sets a line of anything, it ensures that the base-line of
each object in the line is at the same level as the base-line of the
final object.  (Apart, of course, from <code>\</code><code>raisebox</code> commands...)
<p>Most imported graphics have their base-line set at the bottom of the
picture.  When using packages such as <i>subfig</i>, one often
wants to align figures by their tops.  The following odd little bit of
code does this:
<blockquote>
<pre>
\vtop{%
  \vskip0pt
  \hbox{%
    \includegraphics{figure}%
  }%
}
</pre>
</blockquote>
The <code>\</code><code>vtop</code> primitive sets the base-line of the resulting object to
that of the first "line" in it; the <code>\</code><code>vskip</code> creates the illusion
of an empty line, so <code>\</code><code>vtop</code> makes the very top of the box into the
base-line.
<p>In cases where the graphics are to be aligned with text, there is a
case for making the base-line one ex-height below the top of the box,
as in:
<blockquote>
<pre>
\vtop{%
  \vskip-1ex
  \hbox{%
    \includegraphics{figure}%
  }%
}
</pre>
</blockquote>
The fact is, <em>you</em> may choose where the base-line ends up.  This
answer merely shows you sensible choices you might make.
<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=topgraph">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=topgraph</a>
</body>