Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
composition:texte:renvois:detecter_qu_un_label_est_vide [2018/05/24 22:04] joseph.wright3_composition:texte:renvois:detecter_qu_un_label_est_vide [2021/11/29 22:56] (Version actuelle) – Correction de la mise en forme. yannick.tanguy
Ligne 1: Ligne 1:
---- +====== Comment savoir si une étiquette n'est pas définie? ======
-section: Macro programming +
-subsection: LaTeX macro programming +
-permalink: /FAQ-labundef.html +
-date: 2014-06-10 +
----+
  
-# Finding if a label is undefined+Au moment de l'exécution de votre code <latex>\LaTeX</latex>, vous pourriez souhaiter savoir si une étiquette n'est pas définie (même si c'est un état transitoire et que <latex>\LaTeX</latex>  gère assez bien cette situation).
  
-People seem to want to know (at run time) if a label is undefined (I +===== Avec les commandes de base =====
-don't actually understand _why_, particularly: it's a transient +
-state, and LaTeX deals with it quite well).+
  
-A resolved label is simply a command: +Une étiquette définie est simplement une commande ''\r@''//nom-étiquette//Notre question initiale revient donc à vérifier si la commande existe. Avec <latex>\LaTeX</latex>, cela se fait généralement avec la commande de test ''\@ifundefined{r@''//nom-étiquette//''}{''//cas-non-déf//''}{''//cas-déf//''}'' pour laquelle : 
-`\r@``&lsaquo;_label-name_&rsaquo;`; determining if the label is set is +  * ''nom-étiquette'' est le nom d'étiquette que vous avez utilisé dans la commande ''\label'' 
-then simply a matter of detecting if the command exists The usual +  * et les deux autres arguments sont les commandes qui seront exécutées si l'étiquette est non définie (''cas-non-déf''ou si elle est définie (''cas-déf'').
-LaTeX internal way of doing this is to use the command +
-`ifundefined`: +
-  `ifundefined{r@label-name}{undef-cmds}{def-cmds}` +
-In which, &lsaquo;_label-name_&rsaquois exactly what you would use in +
-a `\label` command, and the remaining two arguments are command +
-sequences to be used if the label is undefined +
-(&lsaquo;_undef-cmds_&rsaquo;or if it is defined +
-(&lsaquo;_def-cmds_&rsaquo;).+
  
-Note that any command that incorporates `ifundefined` is naturally +Notez que toute commande qui intègre ''\@ifundefined'' est naturellement [[2_programmation:syntaxe:c_est_quoi_la_protection|fragile]]. Pour la protégerconsultez la question « [[2_programmation:syntaxe:c_est_quoi_la_protection|À quoi sert la « protection » ?]] ».
-fragile, so remember to create it with `\DeclareRobustCommand` or to +
-use it with `\protect` in a moving argument.+
  
-If you're into this gameyou may well not care about LaTeX'+Si vous suivez cette pistevous ne soucierez peut-être pas de l'avertissement de <latex>\LaTeX</latex> concernant les étiquettes non définies à la fin du document. Cependantsi vous y trouvez un intérêtajoutez la commande ''\G@refundefinedtrue'' dans l'argument ''cas-non-déf''.
-warning about undefined labels at the end of the document; however, +
-if you areinclude the command `\G@refundefinedtrue` in +
-&lsaquo;_`undef-cmds`_&rsaquo;.+
  
-And of courseremember you're dealing in internal commandsand pay +Enfinbien sûrrappelez-vous que vous avez affaire à des commandes internes. En cas de doute, consultez la question : « [[2_programmation:macros:makeatletter_et_makeatother|À quoi servent \makeatletter et \makeatother ?]] ».
-attention to the [at-signs]({% post_url FAQ-atsigns %}).+
  
-All the above can be avoided by using the [`labelcas`](https://ctan.org/pkg/labelcas) package: +===== Avec l'extension “labelcas” =====
-it provides commands that enable you to switch according to the state +
-of a single label, or the states of a list of labels.  The package'+
-definition is a bit complicated, but the package itself is pretty +
-powerful.+
  
 +Tout ce qui précède peut être évité en utilisant l'extension [[ctanpkg>labelcas]] : elle fournit des commandes permettant de d'agir différemment selon l'état d'une étiquette, ou des états d'une liste d'étiquettes. Cette extension, un peu compliquée, s'avère assez puissante.
  
 +-----
 +
 +//Source:// [[faquk>FAQ-labundef|Finding if a label is undefined]]
 +
 +{{htmlmetatags>metatag-keywords=(LaTeX,commande,macro,programmation,étiquette,définition)
 +metatag-og:title=(Comment savoir si une étiquette n'est pas définie)
 +metatag-og:site_name=(FAQ LaTeX francophone)
 +}}
3_composition/texte/renvois/detecter_qu_un_label_est_vide.1527199487.txt.gz · Dernière modification : 2018/05/24 22:04 de joseph.wright
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0