Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente |
composition:flottants:positionnement:forcer_la_position_d_un_flottant2 [2020/12/08 13:24] – Début de la traduction. yannick.tanguy | 3_composition:flottants:positionnement:forcer_la_position_d_un_flottant2 [2021/11/28 15:46] (Version actuelle) – Correction d'une coquille. yannick.tanguy |
---|
====== Comment imposer un emplacement à un flottant ? ====== | ====== Comment imposer un emplacement à un flottant? ====== |
| |
FIXME This is of course a contradiction: ''figure'' and ''table'' are //designed// to float, and will always have the potential to appear away from where you asked for them. Therefore you need something that behaves like a ''figure'' or ''table'' environment, except that it doesn't allow the figure or table to float. | La demande est contradictoire : ''figure'' et ''table'' sont //conçus// pour flotter, et auront toujours la possibilité d'être placés loin de l'endroit où vous les avez évoqués. Par conséquent, vous avez besoin de quelque chose qui se présente comme un environnement ''figure'' ou ''table'' mais sans le comportement d'un flottant. |
| |
The most straightforward way is to use of the [[ctanpkg>float|float]] package; it gives you a ''[H]'' float placement option that prevents floating: | ===== Avec l'extension “float” ===== |
| |
| Le moyen le plus simple est d'utiliser l'extension [[ctanpkg>float]] qui vous donne une option de placement flottant « ''H'' » qui empêche le flottement : |
| |
<code latex> | <code latex> |
\begin{figure}[H] | \begin{figure}[H] |
\centering | \centering % Pour centrer la figure |
\includegraphics{foo} | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH ! |
\caption{caption text} | \caption{Beaucoup de bruit pour rien} |
\label{fig:nonfloat} | \label{fig:aaaaah} |
\end{figure} | \end{figure} |
</code> | </code> |
| |
As the example suggests, such a ''[H]'' figure (or corresponding table) offers all you need to cross-reference as well as typeset. (The package [[ctanpkg>here|here]] provides the same function, but is no longer recommended.) | Il existe une extension [[ctanpkg>here]] qui permet d'obtenir la même fonctionnalité mais elle n'est pas recommandée : elle sert uniquement pour des documents anciens. |
| |
However, you don't actually //have// to use [[ctanpkg>float|float]] (or [[ctanpkg>here|here]]) since it is, in fact, doing rather little for you. You can place your figure as you please, with a sequence like | ===== Avec l'extension “caption” ou l'extension “capt-of” ===== |
| |
| En fait, vous n'avez pas //besoin// d'utiliser l'extension [[ctanpkg>float]]. Il existe un moyen simple pour placer votre figurine à votre guise que montre le code suivant : |
| |
<code latex> | <code latex> |
\begin{center} | \begin{center} |
\includegraphics{foo} | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH ! |
\captionof{figure}{caption text} | \captionof{figure}{Beaucoup de bruit pour rien} |
\label{fig:nonfloat} | \label{fig:aaaaah} |
\end{center} | \end{center} |
</code> | </code> |
which relies on the ''\captionof'' command to place a caption without | |
benefit of an enclosing float. That command may be had from the extremely | |
simple-minded package [[ctanpkg>capt-of|capt-of]] or from the highly | |
sophisticated [[ctanpkg>caption|caption]] package. | |
| |
Using either method, you have to deal with the possibility of the | Ce code s'appuie sur la commande ''\captionof'' pour placer une légende sans bénéficier d'un flottant englobant. Cette commande peut être obtenue à partir de l'extension très simple [[ctanpkg>capt-of]] ou de l'extension sophistiquée [[ctanpkg>caption]]. Elle est présentée à la question « [[3_composition/flottants/legendes/inserer_une_legende_sans_flottant|Comment utiliser la commande “\caption” hors d'un environnement flottant ?]] ». |
figure or table being too large for the page. (Floating objects will | |
float away in this circumstance; "doing it by hand", like this, you | |
take upon yourself the responsibility for avoiding | |
"//Overfull ''\vbox''//" errors. | |
| |
A further problem is the possibility that such "fixed floats" will | ===== Les limites de ces méthodes ===== |
overtake "real floats", so that the numbers of figures will be out | |
of order: figure 6 could be on page 12, while figure 5 had floated to | |
page 13. It's best, therefore, either to stay with floating figures | |
throughout a document, or to use fixed figures throughout. | |
| |
If it's really impossible to follow that counsel of perfection, you | ==== Gestion de l'encombrement des flottants ==== |
can use the [[ctanpkg>perpage|perpage]] package's command ''\MakeSorted'' | |
command: | Quelle que soit la méthode utilisée, vous devrez gérer le cas où une figure ou un tableau soit trop grand pour la page (sous peine d'erreurs « //[[2_programmation/erreurs/o/overfull|Overfull \vbox]]// » et de mise en page dégradée). |
| |
| ==== Gestion de la numérotation des flottants ==== |
| |
| Un autre problème vient de la possibilité que de tels « flottants fixes » s'insèrent entre de vrais flottants, de sorte que leurs numéros seront dans le désordre : la figure 6, non flottante, pourrait être à la page 12, tandis que la figure 5, flottante, pourrait se retrouver en page 13. Ici, mieux vaut n'avoir que des flottants ou que des « flottants fixes ». |
| |
| Si vous ne pouvez suivre ce conseil, vous pouvez utiliser la commande ''\MakeSorted'' de l'extension [[ctanpkg>perpage]]. En voici un exemple qui corrige la numérotation de vos flottants : |
| |
<code latex> | <code latex> |
... | |
\usepackage{float} | \usepackage{float} |
\usepackage{perpage} | \usepackage{perpage} |
\MakeSorted{figure} | \MakeSorted{figure} |
\MakeSorted{table} | \MakeSorted{table} |
... | |
</code> | </code> |
and the sequence of float numbers is all correct. | |
| |
| |
----- | ----- |
| |
//Source:// [[faquk>FAQ-figurehere|Figure (or table) _exactly_ where I want it]] | //Source:// [[faquk>FAQ-figurehere|Figure (or table) _exactly_ where I want it]] |
| |
{{htmlmetatags>metatag-keywords=(LaTeX,figures,floats,tables) | {{htmlmetatags>metatag-keywords=(LaTeX,flottants,positionnement,tables,figures) |
metatag-og:title=(Comment imposer un emplacement à un flottant) | metatag-og:title=(Comment imposer un emplacement à un flottant) |
metatag-og:site_name=(FAQ LaTeX francophone) | metatag-og:site_name=(FAQ LaTeX francophone) |
}} | }} |