Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
composition:texte:pages:empecher_un_saut_de_page_entre_deux_lignes [2018/05/25 19:36] – joseph.wright | 3_composition:texte:pages:empecher_un_saut_de_page_entre_deux_lignes [2022/09/22 14:19] (Version actuelle) – Insertion d'espace de longueur nulle en vue de conversion dbitouze | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | --- | + | ====== Comment éviter un saut de page entre des lignes? ====== |
- | category: formatting | + | |
- | tags: layout | + | |
- | permalink: / | + | |
- | date: 2014-06-10 | + | |
- | --- | + | |
- | # Preventing | + | En temps normal, un bloc de texte doit être conservé sur une même page. Mais il s' |
- | One commonly requires that a block of typeset material be kept on the | + | ===== De manière automatique ===== |
- | same page; it turns out to be surprisingly tricky to arrange this. | + | |
- | LaTeX provides a `samepage` environment which claims it | + | ==== Avec des commandes de base ==== |
- | does this sort of thing for you. It proceeds by setting infinite | + | |
- | penalties for all sorts of page-break situations; but in many | + | |
- | situations where you want to prevent a page break, | + | |
- | `samepage` doesn' | + | |
- | text together, you need to end the paragraph inside the environment | + | |
- | (see [preserving paragraph parameters](/ | + | |
- | Also, if the things you are trying to keep together insert their own | + | |
- | pagebreak hints, `samepage` has no power over them (though | + | |
- | list items' attempts& | + | |
- | are subverted by `samepage`). | + | |
- | `samepage` _does_ work, it is capable of leaving | + | |
- | stuff jutting out at the bottom of the page. | + | |
- | Another convenient trick is to set all the relevant stuff in a | + | < |
- | `\parbox` | + | |
- | verbatim text that may not be used in the argument of a `\parbox`). | + | * si les éléments que vous essayez de garder ensemble insèrent leurs propres recommandations de saut de page, '' |
- | The resulting box certainly _won't_ break between pages, but | + | * si '' |
- | that's not to say that it will actually do what you want it to do: | + | |
- | again, the box may be left jutting out at the bottom of the page. | + | |
- | Why do neither of these obvious things work?& | + | Une autre astuce pratique consiste à placer tous les éléments pertinents dans une commande |
- | really distinguish between infinitely awful things. | + | |
- | `Samepage` will make any possible break point '' | + | |
- | bad'' | + | |
- | alternative is the leave an infinitely bad few centimetres of blank | + | |
- | paper at the bottom of the page, TeX will take the line of least | + | |
- | resistance and do nothing. | + | |
- | This problem still arises even if you have `\raggedbottom` in | + | Pourquoi aucune de ces choses évidentes ne fonctionne ? Parce que < |
- | effect: TeX doesn't notice the value of _that_ until it starts | + | |
- | actually shipping a page out. One approach is to set: | + | Ce problème se pose d' |
- | ```latex | + | |
+ | < | ||
\raggedbottom | \raggedbottom | ||
\addtolength{\topskip}{0pt plus 10pt} | \addtolength{\topskip}{0pt plus 10pt} | ||
- | ``` | + | </ |
- | The `10pt` offers a hint to the output | + | |
- | stretchable; | + | Le '' |
- | stretch while building the page. If you're doing this as a temporary | + | |
- | measure, cancel the change to `\topskip` by: | + | < |
- | ```latex | + | |
\addtolength{\topskip}{0pt plus-10pt} | \addtolength{\topskip}{0pt plus-10pt} | ||
- | ``` | + | </ |
- | as well as resetting `\flushbottom`. | + | |
- | actually shows up, because it is overwhelmed when the page is shipped | + | |
- | out by the stretchability introduced by `\raggedbottom`; | + | |
- | could well have an effect if `\flushbottom` was in effect.) | + | |
- | An alternative (which derives from a suggestion by Knuth in the | + | De même, il fera réinitialiser '' |
- | TeXbook) is the package | + | |
- | which both define a command `\needspace` whose argument | + | ==== Avec l' |
- | what space is needed. If the space isn't available, the current | + | |
- | is cleared, and the matter that needs to be kept together will be | + | Une alternative (suggérée par Donald |
- | inserted on the new page. For example, if 4& | + | |
- | kept together, the sequence | + | < |
- | ```latex | + | |
\par | \par | ||
\needspace{4\baselineskip} | \needspace{4\baselineskip} | ||
- | % the stuff that must stay together | + | % Les éléments qui doivent rester ensemble |
- | <text generating lines 1-4> | + | ⟨le texte d'une à quatre lignes⟩ |
- | % now stuff we don't mind about | + | % Puis la suite où vous êtes moins regardant |
- | ``` | + | </code> |
- | Yet another trick by Knuth is useful if you have a sequence of small | + | ==== Avec la commande \filbreak ==== |
- | blocks of text that need, individually, to be kept on their own page. | + | |
- | Insert the command `\filbreak` before each small block, and the | + | Une autre astuce donnée par Knuth peut servir si vous avez une séquence de petits blocs de texte qui doivent, individuellement, être conservés sur leur propre |
- | effect is achieved. | + | |
- | sequences of LaTeX-style | + | <code latex> |
- | into the definition of a command | + | |
- | [patching commands](/ | + | |
- | patch would be: | + | |
- | <!-- {% raw %} --> | + | |
- | ```latex | + | |
\let\oldsubsubsection=\subsubsection | \let\oldsubsubsection=\subsubsection | ||
\renewcommand{\subsubsection}{% | \renewcommand{\subsubsection}{% | ||
Ligne 88: | Ligne 52: | ||
\oldsubsubsection | \oldsubsubsection | ||
} | } | ||
- | ``` | + | </code> |
- | <!-- {% endraw %} --> | + | |
- | While the trick works for consecutive sequences of blocks, it's | + | Bien que l' |
- | slightly tricky to get out of such sequences unless the sequence is | + | |
- | interrupted by a forced | + | ===== De manière manuelle ===== |
- | be introduced by a `\chapter` command, or the end of the document). | + | |
- | If the sequence is not interrupted, the last block is likely to be | + | Si vous êtes prêt à accepter que tout ne peut pas être accompli de manière totalement automatique, la voie à suivre est de composer le document et de vérifier les éléments susceptibles de créer des problèmes. Dans un tel scénario, vous pouvez décider, au cas par cas, comment traiter les problèmes au dernier stade de la relecture. Là, vous pouvez modifier manuellement les sauts de page : |
- | forced onto a new page, regardless of whether it actually needs it. | + | * en utilisant '' |
+ | * en plaçant une commande '' | ||
+ | |||
+ | Vous pouvez également procéder à de petits ajustements de la géométrie de la page, en utilisant '' | ||
+ | |||
+ | <code latex> | ||
+ | \enlargethispage{2\baselineskip} | ||
+ | </ | ||
+ | |||
+ | Deux lignes sont ajoutées ainsi à la page que vous composez. Et que cette technique puisse sembler horrible ou acceptable, elle reste un élément utile dans votre arsenal. | ||
+ | |||
+ | Notez que les commandes '' | ||
- | If one is willing to accept that not everything can be accomplished | + | ----- |
- | totally automatically, | + | |
- | check for things that have the potential to give trouble. | + | |
- | scenario (which has Knuth' | + | |
- | the rather few words he says on the subject in the TeXbook) one can | + | |
- | decide, case by case, how to deal with problems at the last | + | |
- | proof-reading stage. | + | |
- | breaking, using either `\pagebreak` or `\clearpage`, | + | |
- | place a `\nopagebreak` command to suppress unfortunate breaks. | + | |
- | Otherwise, you can make small adjustments to the page geometry, using | + | |
- | `\enlargethispage`. | + | |
- | issue the command `\enlargethispage{2`\baselineskip`}` and | + | |
- | two lines are added to the page you're typesetting. | + | |
- | looks impossibly awful or entirely acceptable depends on the document | + | |
- | context, but the command remains a useful item in the armoury. | + | |
- | Note that both `\pagebreak` and `\nopagebreak` take an optional | + | // |
- | number argument to adjust how the command is to be interpreted. | + | |
- | `\pagebreak[0]`, the command '' | + | |
- | might be worth doing, whereas `\pagebreak[4]` '' | + | |
- | page break. | + | |
- | while `\nopagebreak[4]` is a demand. | + | |
- | default value of the optional argument is 4. | + | |
+ | {{htmlmetatags> | ||
+ | metatag-og: | ||
+ | metatag-og: | ||
+ | }} | ||