Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Dernière révision Les deux révisions suivantes | ||
3_composition:illustrations:aligner_des_images_en_heut [2018/05/24 19:10] joseph.wright |
3_composition:illustrations:aligner_des_images_en_heut [2018/12/02 23:31] jejust |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | --- | + | ====== Top-aligning imported graphics ====== |
- | section: Graphics | + | |
- | permalink: /FAQ-topgraph.html | + | |
- | date: 2014-06-10 | + | |
- | --- | + | |
- | # Top-aligning imported graphics | ||
When TeX sets a line of anything, it ensures that the base-line of | 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 | each object in the line is at the same level as the base-line of the | ||
- | final object. (Apart, of course, from `\raisebox` commands…) | + | final object. (Apart, of course, from ''\raisebox'' commands...) |
Most imported graphics have their base-line set at the bottom of the | Most imported graphics have their base-line set at the bottom of the | ||
- | picture. When using packages such as [`subfig`](https://ctan.org/pkg/subfig), one often | + | picture. When using packages such as [[ctanpkg>subfig|subfig]], one often |
wants to align figures by their tops. The following odd little bit of | wants to align figures by their tops. The following odd little bit of | ||
code does this: | code does this: | ||
- | <!-- {% raw %} --> | + | |
- | ```latex | + | |
+ | <code latex> | ||
\vtop{% | \vtop{% | ||
\vskip0pt | \vskip0pt | ||
Ligne 23: | Ligne 19: | ||
}% | }% | ||
} | } | ||
- | ``` | + | </code> |
- | <!-- {% endraw %} --> | + | |
- | The `\vtop` primitive sets the base-line of the resulting object to | + | The ''\vtop'' primitive sets the base-line of the resulting object to |
- | that of the first ''line'' in it; the `\vskip` creates the illusion | + | that of the first "line" in it; the ''\vskip'' creates the illusion |
- | of an empty line, so `\vtop` makes the very top of the box into the | + | of an empty line, so ''\vtop'' makes the very top of the box into the |
base-line. | base-line. | ||
Ligne 33: | Ligne 29: | ||
case for making the base-line one ex-height below the top of the box, | case for making the base-line one ex-height below the top of the box, | ||
as in: | as in: | ||
- | <!-- {% raw %} --> | + | |
- | ```latex | + | |
+ | <code latex> | ||
\vtop{% | \vtop{% | ||
\vskip-1ex | \vskip-1ex | ||
Ligne 41: | Ligne 38: | ||
}% | }% | ||
} | } | ||
- | ``` | + | </code> |
- | <!-- {% endraw %} --> | + | |
A more LaTeX-y way of doing the job (somewhat inefficiently) uses | A more LaTeX-y way of doing the job (somewhat inefficiently) uses | ||
- | the [`calc`](https://ctan.org/pkg/calc) package: | + | the [[ctanpkg>calc|calc]] package: |
- | ```latex | + | |
+ | <code latex> | ||
\usepackage{calc} | \usepackage{calc} | ||
... | ... | ||
\raisebox{1ex-\height}{\includegraphics{figure}} | \raisebox{1ex-\height}{\includegraphics{figure}} | ||
- | ``` | + | </code> |
(this has the same effect as the text-align version, above). | (this has the same effect as the text-align version, above). | ||
- | The fact is, _you_ may choose where the base-line ends up. This | + | The fact is, //you// may choose where the base-line ends up. This |
answer merely shows you sensible choices you might make. | answer merely shows you sensible choices you might make. | ||
+ | |||
+ | --- | ||
+ | |||
+ | //Source:// [[faquk>FAQ-topgraph|Top-aligning imported graphics]] | ||
+ | |||
+ | {{htmlmetatags>metatag-keywords=(LaTeX,graphics) | ||
+ | metatag-og:title=(Top-aligning imported graphics) | ||
+ | metatag-og:site_name=(FAQ LaTeX francophone) | ||
+ | }} | ||