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:renvois:changer_le_format_des_labels [2018/05/25 19:32] – joseph.wright | 3_composition:texte:renvois:changer_le_format_des_labels [2022/07/14 17:12] (Version actuelle) – Usage de ⟨...⟩ dbitouze | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | --- | + | ====== Comment modifier le format des étiquettes? |
| - | category: programming | + | |
| - | tags: latex macros | + | |
| - | permalink: / | + | |
| - | date: 2014-06-10 | + | |
| - | --- | + | |
| - | # How to change | + | Par défaut, lorsqu' |
| - | By default, when a label is created, it takes on the appearance of the | + | ===== Avec les commandes de bases ===== |
| - | counter labelled, so the label appears as | + | |
| - | `\the``& | + | |
| - | asked to typeset the counter in your text. This isn't always what you | + | |
| - | need: for example, if you have nested enumerated lists with the outer | + | |
| - | numbered and the inner labelled with letters, one might expect to want | + | |
| - | to refer to items in the inner list as '' | + | |
| - | [change the structure of list items](/ | + | |
| - | The change is of course | + | |
| - | possible by explicit labelling of the parent and using that label to | + | |
| - | construct the typeset result& | + | |
| - | ```latex | + | |
| - | \ref{parent-item}(\ref{child-item}) | + | |
| - | ``` | + | |
| - | which would be both tedious and error-prone. | + | |
| - | undesirable, | + | |
| - | which is inflexible (you couldn' | + | |
| - | of a list at one fell swoop). | + | |
| - | LaTeX in fact has a label-formatting command built into every label | + | Ceci est bien sûr possible en étiquetant explicitement chaque niveau de liste puis en faisant un appel comme : |
| - | definition; by default it's null, but it's available for the user to | + | |
| - | program. For any label ‹_counter_& | + | <code latex> |
| - | command `\p@`& | + | \ref{⟨itemNiveauUn⟩}(\ref{⟨itemNiveauDeux⟩}) |
| - | on an inner list item is supposedly done using the command | + | </ |
| - | `\p@enumii{`\theenumii`}`. | + | |
| - | workings of this aren't quite right, and you need to patch the | + | Mais ce serait à la fois fastidieux et sujet à erreur. De plus, vous construiriez une structure délicate à modifier : vous ne pourriez pas changer toutes les références aux éléments d'une liste d'un seul coup. |
| - | `\refstepcounter` command: | + | |
| - | <!-- {% raw %} --> | + | < |
| - | ```latex | + | |
| + | <code latex> | ||
| \renewcommand*\refstepcounter[1]{\stepcounter{# | \renewcommand*\refstepcounter[1]{\stepcounter{# | ||
| \protected@edef\@currentlabel{% | \protected@edef\@currentlabel{% | ||
| Ligne 43: | Ligne 22: | ||
| }% | }% | ||
| } | } | ||
| - | ``` | + | </code> |
| - | <!-- {% endraw %} --> | + | |
| - | With the patch in place you can now, for example, change the labels on | + | Avec ce correctif, vous pouvez maintenant, par exemple, changer les étiquettes sur toutes les listes de niveau 2 en ajoutant le code suivant dans votre préambule |
| - | all inner lists by adding the following | + | |
| - | ```latex | + | < |
| \makeatletter | \makeatletter | ||
| \renewcommand{\p@enumii}[1]{\theenumi(# | \renewcommand{\p@enumii}[1]{\theenumi(# | ||
| \makeatother | \makeatother | ||
| - | ``` | + | </ |
| - | This would make the labels for second-level enumerated lists appear as | + | |
| - | '' | + | |
| - | gets used in a `\label` command. | + | |
| - | In fact, the [`fncylab`](https:// | + | Cela ferait apparaître les étiquettes des listes énumérées de niveau 2 sous la forme « 1(a) » (et ainsi de suite). Un changement analogue fonctionne pour tout compteur utilisé dans une commande '' |
| - | the patch to LaTeX itself). With the package, the code above is | + | |
| - | (actually quite efficiently) rendered by the command: | + | ===== Avec l' |
| - | ```latex | + | |
| + | L' | ||
| + | |||
| + | < | ||
| \labelformat{enumii}{\theenumi(# | \labelformat{enumii}{\theenumi(# | ||
| - | ``` | + | </ |
| - | In fact, the above example, which we can do in several different ways, | + | |
| - | has been rendered obsolete by the appearance of the [`enumitem`](https:// | + | ===== Avec l' |
| - | package, which is discussed in the answer about | + | |
| - | [decorating enumeration lists](/ | + | Pour finir, l' |
| + | ----- | ||
| + | //Source:// [[faquk> | ||
| + | {{htmlmetatags> | ||
| + | metatag-og: | ||
| + | metatag-og: | ||
| + | }} | ||

