summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-topgraph.html
blob: e3906b52dd250169d54da8cd5b939e1414c3e80e (plain)
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>