Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Dernière révision Les deux révisions suivantes | ||
2_composition:macros:detecter_que_quelque_chose_est_vide [2018/06/02 17:37] joseph.wright |
2_composition:macros:detecter_que_quelque_chose_est_vide [2018/12/04 00:26] jejust |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | --- | + | ====== Detecting that something is empty ====== |
- | title: Detecting that something is empty | + | |
- | category: programming | + | |
- | tags: macros | + | |
- | permalink: /FAQ-empty | + | |
- | date: 2014-06-10 | + | |
- | --- | + | |
Suppose you need to know that the argument of your command is empty: | Suppose you need to know that the argument of your command is empty: | ||
- | that is, to distinguish between `\cmd{}` | + | that is, to distinguish between ''\cmd{}'' |
- | and `\cmd{blah}`. This is pretty simple: | + | and ''\cmd{blah}''. This is pretty simple: |
- | <!-- {% raw %} --> | + | |
- | ```latex | + | |
+ | <code latex> | ||
\def\cmd#1{% | \def\cmd#1{% | ||
\def\tempa{}% | \def\tempa{}% | ||
Ligne 21: | Ligne 17: | ||
\fi | \fi | ||
} | } | ||
- | ``` | + | </code> |
- | <!-- {% endraw %} --> | + | |
The case where you want to ignore an argument that consists of nothing | The case where you want to ignore an argument that consists of nothing | ||
but spaces, rather than something completely empty, is more tricky. | but spaces, rather than something completely empty, is more tricky. | ||
- | It's solved in the code fragment [`ifmtarg`](https://ctan.org/pkg/ifmtarg), which defines | + | It's solved in the code fragment [[ctanpkg>ifmtarg|ifmtarg]], which defines |
- | commands `\@ifmtarg` and `\@ifnotmtarg`, which examine their | + | commands ''\@ifmtarg'' and ''\@ifnotmtarg'', which examine their |
first argument, and select (in opposite directions) their second or | first argument, and select (in opposite directions) their second or | ||
third argument. The package's code also appears in the LaTeX | third argument. The package's code also appears in the LaTeX | ||
- | [`memoir`](https://ctan.org/pkg/memoir) class. | + | [[ctanpkg>memoir|memoir]] class. |
- | [`Ifmtarg`](https://ctan.org/pkg/Ifmtarg) makes challenging reading; there's also a discussion of the | + | [[ctanpkg>Ifmtarg|Ifmtarg]] makes challenging reading; there's also a discussion of the |
- | issue in number two of the ''around the bend'' articles by the late | + | issue in number two of the "around the bend" articles by the late |
lamented Mike Downes. | lamented Mike Downes. | ||
+ | |||
+ | ----- | ||
+ | |||
+ | //Source:// [[faquk>FAQ-empty|Detecting that something is empty]] | ||
+ | |||
+ | {{htmlmetatags>metatag-keywords=(LaTeX,programming) | ||
+ | metatag-og:title=(Detecting that something is empty) | ||
+ | metatag-og:site_name=(FAQ LaTeX francophone) | ||
+ | }} | ||