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/12/03 23:55] jejust3_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:
-====== Finding if a label is undefined ======+====== Comment savoir si une étiquette n'est pas définie? ======
  
 +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@<label-name>''; 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, <//label-name//> is exactly what you would use in +
-''\label'' command, and the remaining two arguments are command +
-sequences to be used if the label is undefined +
-(<//undef-cmds//>or if it is defined +
-(<//def-cmds//>).+
  
-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 +
-<//''undef-cmds''//>.+
  
-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 [[FAQ-atsigns|at-signs]].+
  
-All the above can be avoided by using the [[ctanpkg>labelcas|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.
  
 ----- -----
Ligne 41: Ligne 23:
 //Source:// [[faquk>FAQ-labundef|Finding if a label is undefined]] //Source:// [[faquk>FAQ-labundef|Finding if a label is undefined]]
  
-{{htmlmetatags>metatag-keywords=(LaTeX,latex,macros,programming+{{htmlmetatags>metatag-keywords=(LaTeX,commande,macro,programmation,étiquette,définition
-metatag-og:title=(Finding if a label is undefined)+metatag-og:title=(Comment savoir si une étiquette n'est pas définie)
 metatag-og:site_name=(FAQ LaTeX francophone) metatag-og:site_name=(FAQ LaTeX francophone)
 }} }}
- 
3_composition/texte/renvois/detecter_qu_un_label_est_vide.1543881346.txt.gz · Dernière modification : 2018/12/03 23:55 de jejust
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0