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 | ||
2_programmation:syntaxe:compteurs:compteurs_maitres_et_esclaves [2021/04/11 14:25] – Correction de lien interne. jejust | 2_programmation:syntaxe:compteurs:compteurs_maitres_et_esclaves [2021/12/24 09:11] (Version actuelle) – Correction d'un lien suite à déplacement. yannick.tanguy | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== | + | ====== |
+ | Il est courant d' | ||
- | It's common to have things numbered "per chapter" | + | Mais comment faire cela par vous-même ? Vous souhaitez peut-être numéroter les algorithmes en tenant compte du numéro de section, ou les corollaires en tenant compte du numéro de théorème, par exemple. |
- | the standard [[ctanpkg> | + | |
- | and footnotes are all numbered thus). | + | |
- | done automatically, | + | |
- | '' | + | |
- | '' | + | |
- | to zero). | + | |
- | How would you do that for yourself? | + | ===== Avec des commandes de base ===== |
- | algorithms per section, or corollaries per theorem, for example. | + | |
- | you're defining these things by hand, you declare the relationship | + | |
- | when you define the counter in the first place: | + | |
- | '' | + | |
- | says that every time counter <// | + | |
- | <// | + | |
- | But what if you have an uncooperative package, that defines the | + | Si vous définissez cela manuellement, vous devez déclarer cette relation entre compteurs lorsque vous définissez le compteur qui dépend d'un autre (ici //esclave// qui dépend de //maitre//) : |
- | objects for you, but doesn't provide a programmer interface to make | + | |
- | the counters behave as you want? | + | |
- | The '' | + | <code latex> |
- | can also use it: | + | \newcounter{esclave}[maitre] |
- | '' | + | </ |
- | (but remember that it needs to be between '' | + | |
- | '' | + | Ainsi, à chaque fois le compteur nommé //maitre// est incrémenté, |
+ | |||
+ | Mais que se passe-t-il si vous avez une extension qui définit les objets pour vous mais qui ne fournit pas d'interface de programmation pour que les compteurs se comportent comme vous le souhaitez ? | ||
+ | |||
+ | ===== Avec des commandes internes ===== | ||
- | The [[ctanpkg> | + | La commande '' |
- | command into a command | + | |
<code latex> | <code latex> | ||
- | \counterwithin*{corrollary}{theorem} | + | \@addtoreset{esclave}{maitre} |
</ | </ | ||
- | will make the corollary counter slave to theorem counters. | + | |
- | command without its asterisk: | + | ===== Avec l' |
+ | |||
+ | L' | ||
<code latex> | <code latex> | ||
- | \counterwithin{corrollary}{theorem} | + | \counterwithin*{corollaire}{theorem} |
</ | </ | ||
- | will do the same, and also redefine '' | ||
- | <// | ||
- | if you ever want to refer to the corollaries --- there are potentially | ||
- | many " | ||
- | to the counter of the theorem it belongs to. This is true of pretty | ||
- | much any such counter-within-another; | ||
- | [[ctanpkg> | ||
- | [[2_programmation: | ||
- | for the necessary techniques. | ||
- | The 2018 LaTeX release adopted the [[ctanpkg> | + | La commande utilisée sans l'astérisque aura un comportement légèrement différent : |
- | commands into the format, so '' | + | |
- | are now directly available without requiring a package. | + | |
+ | <code latex> | ||
+ | \counterwithin{corollaire}{theorem} | ||
+ | </ | ||
- | Note that the technique doesn't work if the master counter is ''page'', | + | Par rapport à ce que fait '' |
- | the number of the current page. The '' | + | |
- | inside the output routine, which usually gets called some time after | + | |
- | the text for the new page has started to appear: so special | + | |
- | techniques are required to deal with that. One special case is dealt | + | |
- | with elsewhere: [[FAQ-footnpp|footnotes numbered per page]]. One | + | |
- | of the techniques described there, using package | + | |
- | may be applied to any counter. | + | |
- | '' | + | |
- | will cause <// | + | |
- | a label-like mechanism, and may require more than one run of LaTeX | + | |
- | to stabilise counter values --- LaTeX will generate the usual | + | |
- | warnings about labels changing. | + | |
+ | La version 2018 de < | ||
- | ----- | + | ===== Cas particulier du compteur des pages ===== |
- | //Source:// [[faquk> | + | Notez que la technique ne fonctionne pas si le compteur maître est '' |
- | {{htmlmetatags> | + | <code latex> |
- | metatag-og: | + | \MakePerPage{counter} |
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | ----- | ||
+ | //Source :// [[faquk> | ||
+ | |||
+ | {{htmlmetatags> | ||
+ | metatag-og: | ||
metatag-og: | metatag-og: | ||
}} | }} | ||
- |