• Non ci sono risultati.

(1)The etoolbox Package An e-TeX Toolbox for Class and Package Authors Philipp Lehman [email protected] Version 2.1 January 3, 2011 Contents 1 Introduction

N/A
N/A
Protected

Academic year: 2021

Condividi "(1)The etoolbox Package An e-TeX Toolbox for Class and Package Authors Philipp Lehman [email protected] Version 2.1 January 3, 2011 Contents 1 Introduction"

Copied!
31
0
0

Testo completo

(1)

The etoolbox Package

An e-TeX Toolbox for Class and Package Authors Philipp Lehman

[email protected]

Version 2.1 January 3, 2011

Contents

1 Introduction . . . . 1

1.1 About . . . . 1

1.2 License . . . . 1

2 User Commands . . . . 1

2.1 Definitions . . . . 1

2.2 Patching . . . . 2

2.3 Protection . . . . 2

2.4 Lengths and Counters . 2 2.5 Document Hooks . . . . 3

2.6 Environment Hooks . . 4

3 Author Commands . . . . . 5

3.1 Definitions . . . . 5

3.2 Expansion Control . . . 8

3.3 Hook Management . . . 8

3.4 Patching . . . . 1 1 3.5 Boolean Flags . . . . . 12

3.6 Generic Tests . . . . 14

3.7 List Processing . . . . . 23

3.8 Miscellaneous Tools . . 27

4 Revision History . . . . 27

1 Introduction 1.1 Aboutetoolbox

Theetoolboxpackage is a toolbox of programming tools geared primarily towards LaTeX class and package authors. It provides LaTeX frontends to some of the new primitives provided by e-TeX as well as some generic tools which are not related to e-TeX but match the profile of this package.

1.2 License

Copyright © 2007–2011 Philipp Lehman. Permission is granted to copy, distribute and/or modify this software under the terms of the LaTeX Project Public License, version 1.3.1This package is author-maintained.

2 User Commands

The tools in this section are geared towards regular users as well as class and package authors.

2.1 Definitions

\newrobustcmd{hcommandi}[hargumentsi][hoptarg defaulti]{hreplacement texti}

\newrobustcmd*{hcommandi}[hargumentsi][hoptarg defaulti]{hreplacement texti}

The syntax and behavior of this command is similar to\newcommand except that the newly defined hcommandi will be robust. The behavior of this command dif- fers from the\DeclareRobustCommand command from the LaTeX kernel in that it issues an error rather than just an informational message if the hcommandi is already defined. Since it uses e-TeX’s low-level protection mechanism rather than

1 http://www.ctan.org/tex-archive/macros/latex/base/lppl.txt

(2)

the corresponding higher-level LaTeX facilities, it does not require an additional macro to implement the ‘robustness’.

\renewrobustcmd{hcommandi}[hargumentsi][hoptarg defaulti]{hreplacement texti}

\renewrobustcmd*{hcommandi}[hargumentsi][hoptarg defaulti]{hreplacement texti}

The syntax and behavior of this command is similar to\renewcommandexcept that the redefinedhcommandiwill be robust.

\providerobustcmd{hcommandi}[hargumentsi][hoptarg defaulti]{hreplacement texti}

\providerobustcmd*{hcommandi}[hargumentsi][hoptarg defaulti]{hreplacement texti}

The syntax and behavior of this command is similar to\providecommandexcept that the newly defined hcommandi will be robust. Note that this command will provide a robust definition of the hcommandi only if it is undefined. It will not make an already definedhcommandirobust.

2.2 Patching

\robustify{hcommandi}

Redefines ahcommandidefined with\newcommandsuch that it is robust, without altering its parameters, its prefixes, or its replacement text. If thehcommandihas been defined with \DeclareRobustCommand, this will be detected automatically and LaTeX’s high-level protection mechanism will be replaced by the corresponding low-level e-TeX feature.

2.3 Protection

\protecting{hcodei}

This command applies LaTeX’s protection mechanism, which normally requires prefixing each fragile command with \protect, to an entire chunk of arbitrary hcodei. Its behavior depends on the current state of\protect. Note that the braces around thehcodeiare mandatory even if it is a single token.

2.4 Length and Counter Assignments

The tools in this section are replacements for\setcounterand\setlengthwhich support arithmetic expressions.

\defcounter{hcounteri}{hinteger expressioni}

Assigns a value to a LaTeXhcounteripreviously initialized with\newcounter. This command is similar in concept and syntax to \setcounter except for two ma- jor diVerences. 1) The second argument may be anhinteger expressioniwhich will be processed with\numexpr. The hinteger expressionimay be any arbitrary code which is valid in this context. The value assigned to thehcounteriwill be the result of that calculation. 2) In contrast to\setcounter, the assignment is local by de- fault but \defcountermay be prefixed with \global. The functional equivalent of\setcounterwould be\global\defcounter.

(3)

\deflength{hlengthi}{hglue expressioni}

Assigns a value to ahlengthiregister previously initialized with\newlength. This command is similar in concept and syntax to\setlengthexcept that the second argument may be ahglue expressioniwhich will be processed with\glueexpr. The hglue expressioni may be any arbitrary code which is valid in this context. The value assigned to the hlengthi register will be the result of that calculation. The assignment is local by default but\deflengthmay be prefixed with\global. This command may be used as a drop-in replacement for\setlength.

2.5 Additional Document Hooks

LaTeX provides two hooks which defer the execution of code either to the begin- ning or to the end of the document body. Any\AtBeginDocumentcode is executed towards the beginning of the document body, after the mainauxfile has been read for the first time. Any\AtEndDocumentcode is executed at the end of the docu- ment body, before the mainauxfile is read for the second time. The hooks intro- duced here are similar in concept but defer the execution of theirhcodeiargument to slightly diVerent locations. The hcodei may be arbitrary TeX code. Parameter characters in thehcodeiargument are permissible and need not be doubled.

\AfterPreamble{hcodei}

This hook is a variant of\AtBeginDocumentwhich may be used in both the pream- ble and the document body. When used in the preamble, it behaves exactely like

\AtBeginDocument. When used in the document body, it immediately executes its hcodeiargument.\AtBeginDocumentwould issue an error in this case. This hook is useful to defer code which needs to write to the mainauxfile.

\AtEndPreamble{hcodei}

This hook diVers from\AtBeginDocumentin that thehcodei is executed right at the end of the preamble, before the mainauxfile (as written on the previous LaTeX pass) is read and prior to any\AtBeginDocumentcode. Note that it is not possible to write to theauxfile at this point.

\AfterEndPreamble{hcodei}

This hook diVers from \AtBeginDocument in that the hcodei is executed at the very end of\begin{document}, after any\AtBeginDocumentcode. Note that com- mands whose scope has been restricted to the preamble with\@onlypreambleare no longer available when this hook is executed.

\AfterEndDocument{hcodei}

This hook diVers from\AtEndDocumentin that the hcodeiis executed at the very end of the document, after the mainauxfile (as written on the current LaTeX pass) has been read and after any\AtEndDocumentcode.

In a way,\AtBeginDocument code is part neither of the preamble nor the docu- ment body but located in-between them since it gets executed in the middle of the initialization sequence performed prior to typesetting. It is sometimes desirable to

(4)

move code to the end of the preamble because all requested packages have been loaded at this point. \AtBeginDocumentcode, however, is executed too late if it is required in theauxfile. In contrast to that,\AtEndPreamblecode is part of the preamble;\AfterEndPreamblecode is part of the document body and may con- tain printable text to be typeset at the very beginning of the document. To sum that up, LaTeX will perform the following tasks ‘inside’\begin{document}:

• Execute any\AtEndPreamblecode

• Start initialization for document body (page layout, default fonts, etc.)

• Load the mainauxfile written on the previous LaTeX pass

• Open the mainauxfile for writing on the current pass

• Continue initialization for document body

• Execute any\AtBeginDocumentcode

• Complete initialization for document body

• Disable all\@onlypreamblecommands

• Execute any\AfterEndPreamblecode

Inside\end{document}, LaTeX will perform the following tasks:

• Execute any\AtEndDocumentcode

• Perform a final\clearpageoperation

• Close the mainauxfile for writing

• Load the mainauxfile written on the current LaTeX pass

• Perform final tests and issue warnings, if applicable

• Execute any\AfterEndDocumentcode

Any\AtEndDocumentcode may be considered as being part of the document body insofar as it is still possible to perform typesetting tasks and write to the mainaux file when it gets executed.\AfterEndDocumentcode is not part of the document body. This hook is useful to evaluate the data in theauxfile at the very end of a LaTeX pass.

2.6 Environment Hooks

The tools in this section provide hooks for arbitrary environments. Note that they will not modify the definition of the henvironmenti. They hook into the\begin and\endcommands instead. Redefining the henvironmentiwill not clear the cor- responding hooks. Thehcodeimay be arbitrary TeX code. Parameter characters in thehcodeiargument are permissible and need not be doubled.

\AtBeginEnvironment{henvironmenti}{hcodei}

Appends arbitraryhcodei to a hook executed by the\begincommand at the be- ginning of a givenhenvironmenti, immediately before\henvironmenti, inside the group opened by\begin.

\AtEndEnvironment{henvironmenti}{hcodei}

Appends arbitraryhcodeito a hook executed by the\endcommand at the end of a given henvironmenti, immediately before \endhenvironmenti, inside the group

(5)

\BeforeBeginEnvironment{henvironmenti}{hcodei}

Appends arbitrary hcodeito a hook executed at a very early point by the\begin command, before the group holding the environment is opened.

\AfterEndEnvironment{henvironmenti}{hcodei}

Appends arbitraryhcodeito a hook executed at a very late point by the\endcom- mand, after the group holding the environment has been closed.

3 Author Commands

The tools in this section are geared towards class and package authors.

3.1 Definitions

3.1.1 Macro Definitions

The tools in this section are simple but frequently required shorthands which ex- tend the scope of the\@namedefand\@nameusemacros from the LaTeX kernel.

\csdef{hcsnamei}hargumentsi{hreplacement texti}

Similar to the TeX primitive\defexcept that it takes a control sequence name as its first argument. This command is robust and corresponds to\@namedef.

\csgdef{hcsnamei}hargumentsi{hreplacement texti}

Similar to the TeX primitive\gdefexcept that it takes a control sequence name as its first argument. This command is robust.

\csedef{hcsnamei}hargumentsi{hreplacement texti}

Similar to the TeX primitive\edefexcept that it takes a control sequence name as its first argument. This command is robust.

\csxdef{hcsnamei}hargumentsi{hreplacement texti}

Similar to the TeX primitive\xdefexcept that it takes a control sequence name as its first argument. This command is robust.

\protected@csedef{hcsnamei}hargumentsi{hreplacement texti}

Similar to \csedef except that LaTeX’s protection mechanism is temporarily en- abled. To put it in other words: this command is similar to the LaTeX kernel com- mand \protected@edefexcept that it takes a control sequence name as its first argument. This command is robust.

\protected@csxdef{hcsnamei}hargumentsi{hreplacement texti}

Similar to \csxdef except that LaTeX’s protection mechanism is temporarily en- abled. To put it in other words: this command is similar to the LaTeX kernel com- mand \protected@xdefexcept that it takes a control sequence name as its first argument. This command is robust.

(6)

\cslet{hcsnamei}{hcommandi}

Similar to the TeX primitive \letexcept that the first argument is a control se- quence name. Ifhcommandiis undefined,hcsnameiwill be undefined as well after the assignment. This command is robust and may be prefixed with\global.

\letcs{hcommandi}{hcsnamei}

Similar to the TeX primitive \letexcept that the second argument is a control sequence name. Ifhcsnameiis undefined, thehcommandiwill be undefined as well after the assignment. This command is robust and may be prefixed with\global.

\csletcs{hcsnamei}{hcsnamei}

Similar to the TeX primitive\letexcept that both arguments are control sequence names. If the second hcsnamei is undefined, the first hcsnamei will be undefined as well after the assignment. This command is robust and may be prefixed with

\global.

\csuse{hcsnamei}

Takes a control sequence name as its argument and forms a control sequence token.

This command diVers from the \@nameuse macro in the LaTeX kernel in that it expands to an empty string if the control sequence is undefined.

\undefhcommandi

Clears ahcommandi such that e-TeX’s\ifdefinedand \ifcsnametests will con- sider it as undefined. This command is robust and may be prefixed with\global.

\csundef{hcsnamei}

Similar to \undefexcept that it takes a control sequence name as its argument.

This command is robust and may be prefixed with\global.

\csshow{hcsnamei}

Similar to the TeX primitive\showbut takes a control sequence name as its argu- ment. If the control sequence is undefined, this command will not implicitly assign a meaning of\relaxto it. This command is robust.

3.1.2 Arithmetic Definitions

The tools in this section permit calculations using macros rather than length regis- ters and counters.

\numdefhcommandi{hinteger expressioni}

Similar to\edefexcept that the hinteger expressioni is processed with \numexpr. The hinteger expressioni may be any arbitrary code which is valid in this con- text. The replacement text assigned to thehcommandi will be the result of that calculation. If the hcommandi is undefined, it will be initialized to 0 before the hinteger expressioniis processed.

(7)

\numgdefhcommandi{hinteger expressioni}

Similar to\numdefexcept that the assignment is global.

\csnumdef{hcsnamei}{hinteger expressioni}

Similar to\numdefexcept that it takes a control sequence name as its first argu- ment.

\csnumgdef{hcsnamei}{hinteger expressioni}

Similar to\numgdefexcept that it takes a control sequence name as its first argu- ment.

\dimdefhcommandi{hdimen expressioni}

Similar to \edefexcept that the hdimen expressioni is processed with \dimexpr. The hdimen expressioni may be any arbitrary code which is valid in this context.

The replacement text assigned to the hcommandi will be the result of that cal- culation. If the hcommandi is undefined, it will be initialized to 0pt before the hdimen expressioniis processed.

\dimgdefhcommandi{hdimen expressioni}

Similar to\dimdefexcept that the assignment is global.

\csdimdef{hcsnamei}{hdimen expressioni}

Similar to\dimdefexcept that it takes a control sequence name as its first argu- ment.

\csdimgdef{hcsnamei}{hdimen expressioni}

Similar to\dimgdefexcept that it takes a control sequence name as its first argu- ment.

\gluedefhcommandi{hglue expressioni}

Similar to \edef except that the hglue expressioni is processed with \glueexpr. Thehglue expressionimay be any arbitrary code which is valid in this context. The replacement text assigned to thehcommandiwill be the result of that calculation.

If thehcommandi is undefined, it will be initialized to0pt plus 0pt minus 0pt before thehglue expressioniis processed.

\gluegdefhcommandi{hglue expressioni}

Similar to\gluedefexcept that the assignment is global.

\csgluedef{hcsnamei}{hglue expressioni}

Similar to\gluedefexcept that it takes a control sequence name as its first argu- ment.

(8)

\csgluegdef{hcsnamei}{hglue expressioni}

Similar to\gluegdefexcept that it takes a control sequence name as its first argu- ment.

\mudefhcommandi{hmuglue expressioni}

Similar to \edef except that the hmuglue expressioni is processed with \muexpr. Thehmuglue expressionimay be any arbitrary code which is valid in this context.

The replacement text assigned to the hcommandi will be the result of that cal- culation. If the hcommandi is undefined, it will be initialized to 0mu before the hmuglue expressioniis processed.

\mugdefhcommandi{hmuglue expressioni}

Similar to\mudefexcept that the assignment is global.

\csmudef{hcsnamei}{hmuglue expressioni}

Similar to\mudefexcept that it takes a control sequence name as its first argument.

\csmugdef{hcsnamei}{hmuglue expressioni}

Similar to\mugdefexcept that it takes a control sequence name as its first argu- ment.

3.2 Expansion Control

The tools in this section are useful to control expansion in an\edefor a similar context.

\expandoncehcommandi

This command expands ahcommandionce and prevents further expansion of the replacement text. This command is expandable.

\csexpandonce{hcsnamei}

Similar to\expandonceexcept that it takes a control sequence name as its argu- ment.

3.3 Hook Management

The tools in this section are intended for hook management. Ahhookiin this con- text is a plain macro without any parameters and prefixes which is used to collect code to be executed later. These tools may also be useful to patch simple macros by appending code to their replacement text. For more complex patching opera- tions, see section3.4. All commands in this section will initialize thehhookiif it is undefined.

3.3.1 Appending to a Hook

The tools in this section append arbitrary code to a hook.

(9)

\apptohhooki{hcodei}

This command appends arbitraryhcodei to a hhooki. If the hcodei contains any parameter characters, they need not be doubled. This command is robust.

\gapptohhooki{hcodei}

Similar to\apptoexcept that the assignment is global. This command may be used as a drop-in replacement for the\g@addto@macrocommand in the LaTeX kernel.

\eapptohhooki{hcodei}

This command appends arbitraryhcodei to a hhooki. The hcodei is expanded at definition-time. Only the newhcodeiis expanded, the current replacement text of thehhookiis not. This command is robust.

\xapptohhooki{hcodei}

Similar to\eapptoexcept that the assignment is global.

\protected@eapptohhooki{hcodei}

Similar to \eappto except that LaTeX’s protection mechanism is temporarily en- abled.

\protected@xapptohhooki{hcodei}

Similar to \xappto except that LaTeX’s protection mechanism is temporarily en- abled.

\csappto{hcsnamei}{hcodei}

Similar to\apptoexcept that it takes a control sequence name as its first argument.

\csgappto{hcsnamei}{hcodei}

Similar to\gapptoexcept that it takes a control sequence name as its first argu- ment.

\cseappto{hcsnamei}{hcodei}

Similar to\eapptoexcept that it takes a control sequence name as its first argu- ment.

\csxappto{hcsnamei}{hcodei}

Similar to\xapptoexcept that it takes a control sequence name as its first argu- ment.

\protected@cseapptohhooki{hcodei}

Similar to\protected@eapptoexcept that it takes a control sequence name as its first argument.

(10)

\protected@csxapptohhooki{hcodei}

Similar to\protected@xapptoexcept that it takes a control sequence name as its first argument.

3.3.2 Prepending to a Hook

The tools in this section ‘prepend’ arbitrary code to a hook, i. e., the code is inserted at the beginning of the hook rather than being added at the end.

\pretohhooki{hcodei}

Similar to\apptoexcept that thehcodeiis prepended.

\gpretohhooki{hcodei}

Similar to\pretoexcept that the assignment is global.

\epretohhooki{hcodei}

Similar to\eapptoexcept that thehcodeiis prepended.

\xpretohhooki{hcodei}

Similar to\epretoexcept that the assignment is global.

\protected@epretohhooki{hcodei}

Similar to \epreto except that LaTeX’s protection mechanism is temporarily en- abled.

\protected@xpretohhooki{hcodei}

Similar to \xpreto except that LaTeX’s protection mechanism is temporarily en- abled.

\cspreto{hcsnamei}{hcodei}

Similar to\pretoexcept that it takes a control sequence name as its first argument.

\csgpreto{hcsnamei}{hcodei}

Similar to\gpretoexcept that it takes a control sequence name as its first argu- ment.

\csepreto{hcsnamei}{hcodei}

Similar to\epretoexcept that it takes a control sequence name as its first argu- ment.

\csxpreto{hcsnamei}{hcodei}

Similar to\xpretoexcept that it takes a control sequence name as its first argu- ment.

(11)

\protected@csepretohhooki{hcodei}

Similar to\protected@epretoexcept that it takes a control sequence name as its first argument.

\protected@csxpretohhooki{hcodei}

Similar to\protected@xpretoexcept that it takes a control sequence name as its first argument.

3.4 Patching

The tools in this section are useful to hook into or modify existing code. All com- mands presented here preserve the parameters and the prefixes of the patched hcommandi. Note that\outercommands may not be patched. Also note that the commands in this section will not automatically issue any error messages if patch- ing fails. Instead, they take a hfailurei argument which should provide suitable fallback code or an error message. Issuing\tracingpatchesin the preamble will cause the commands to write debugging information to the transcript file.

\patchcmd[hprefixi]{hcommandi}{hsearchi}{hreplacei}{hsuccessi}{hfailurei}

This command extracts the replacement text of a hcommandi, replaces hsearchi with hreplacei, and reassembles the hcommandi. The pattern match is category code agnostic and matches the first occurence of the hsearchi pattern in the re- placement text of thehcommandi to be patched. Note that the patching process involves detokenizing the replacement text of the hcommandi and retokenizing it under the current category code regime after patching. The category code of the @ sign is temporarily set to 11. If the replacement text of the hcommandiin- cludes any tokens with non-standard category codes, the respective category codes must be adjusted prior to patching. If the code to be replaced or inserted refers to the parameters of the hcommandi to be patched, the parameter characters need not be doubled. If an optionalhprefixiis specified, it replaces the prefixes of the hcommandi. An empty hprefixi argument strips all prefixes from thehcommandi. The assignment is local. This command implicitly performs the equivalent of an

\ifpatchabletest prior to patching. If this test succeeds, the command applies the patch and executeshsuccessi. If the test fails, it executeshfailureiwithout mod- ifying the originalhcommandi. This command is robust.

\ifpatchable{hcommandi}{hsearchi}{htruei}{hfalsei}

This command executeshtrueiif thehcommandimay be patched with\patchcmd and if thehsearchipattern is found in its replacement text, andhfalsei otherwise.

This command is robust.

\ifpatchable*{hcommandi}{htruei}{hfalsei}

Similar to\ifpatchableexcept that the starred variant does not require a search pattern. Use this version to check if a command may be patched with\apptocmd and\pretocmd.

(12)

\apptocmd{hcommandi}{hcodei}{hsuccessi}{hfailurei}

This command appends hcodei to the replacement text of a hcommandi. If the hcommandiis a parameterless macro, it behaves like\apptofrom section3.3.1. In contrast to\appto,\apptocmdmay also be used to patch commands with param- eters. In this case, it will detokenize the replacement text of thehcommandi, apply the patch, and retokenize it under the current category code regime. The category code of the @ sign is temporarily set to 11. Thehcodeimay refer to the parameters of thehcommandi. The assignment is local. If patching succeeds, this command executes hsuccessi. If patching fails, it executes hfailurei without modifying the originalhcommandi. This command is robust.

\pretocmd{hcommandi}{hcodei}{hsuccessi}{hfailurei}

This command is similar to \apptocmd except that the hcodei is inserted at the beginning of the replacement text of thehcommandi. If thehcommandiis a param- eterless macro, it behaves like \preto from section 3.3.1. In contrast to \preto,

\pretocmdmay also be used to patch commands with parameters. In this case, it will detokenize the replacement text of thehcommandi, apply the patch, and reto- kenize it under the current category code regime. The category code of the @ sign is temporarily set to 11. Thehcodeimay refer to the parameters of thehcommandi. The assignment is local. If patching succeeds, this command executes hsuccessi. If patching fails, it executes hfailurei without modifying the originalhcommandi. This command is robust.

\tracingpatches Enables tracing for all patching commands, including\ifpatchable. The debug- ging information will be written to the transcript file. This is useful if the reason why a patch is not applied or \ifpatchable yields hfalsei is not obvious. This command must be issued in the preamble.

3.5 Boolean Flags

This package provides two interfaces to boolean flags which are completely inde- pendent of each other. The tools in section3.5.1are a LaTeX frontend to \newif. Those in section3.5.2use a diVerent mechanism.

3.5.1 TeX Flags

Since the tools in this section are based on\newifinternally, they may be used to test and alter the state of flags previously defined with\newif. They are also compatible with the boolean tests of theifthenpackage and may serve as a LaTeX interface for querying TeX primitives such as\ifmmode. The\newifapproach re- quires a total of three macros per flag.

\newbool{hnamei}

Defines a new boolean flag calledhnamei. If the flag has already been defined, this command issues an error. The initial state of newly defined flags is false. This command is robust.

(13)

\providebool{hnamei}

Defines a new boolean flag calledhnameiunless it has already been defined. This command is robust.

\booltrue{hnamei}

Sets the boolean flaghnameitotrue. This command is robust and may be prefixed with\global. It will issue an error if the flag is undefined.

\boolfalse{hnamei}

Sets the boolean flaghnamei tofalse. This command is robust and may be pre- fixed with\global. It will issue an error if the flag is undefined.

\setbool{hnamei}{hvaluei}

Sets the boolean flaghnameitohvaluei which may be eithertrueorfalse. This command is robust and may be prefixed with\global. It will issue an error if the flag is undefined.

\ifbool{hnamei}{htruei}{hfalsei}

Expands tohtruei if the state of the boolean flaghnamei is true, and to hfalsei otherwise. If the flag is undefined, this command issues an error. This command may be used to perform any boolean test based on plain TeX syntax, i. e., any test normally employed like this:

\iftest true\else false\fi

This includes all flags defined with \newif as well as TeX primitives such as

\ifmmode. The \if prefix is omitted when using the flag or the primitive in the expression. For example:

\ifmytest true\else false\fi

\ifmmode true\else false\fi

becomes

\ifbool{mytest}{true}{false}

\ifbool{mmode}{true}{false}

\notbool{hnamei}{hnot truei}{hnot falsei}

Similar to\ifboolbut negates the test.

3.5.2 LaTeX Flags

In contrast to the flags from section3.5.1, the tools in this section require only one macro per flag. They also use a separate namespace to avoid name clashes with regular macros.

\newtoggle{hnamei}

Defines a new boolean flag calledhnamei. If the flag has already been defined, this

(14)

command issues an error. The initial state of newly defined flags is false. This command is robust.

\providetoggle{hnamei}

Defines a new boolean flag calledhnameiunless it has already been defined. This command is robust.

\toggletrue{hnamei}

Sets the boolean flaghnameitotrue. This command is robust and may be prefixed with\global. It will issue an error if the flag is undefined.

\togglefalse{hnamei}

Sets the boolean flaghnamei tofalse. This command is robust and may be pre- fixed with\global. It will issue an error if the flag is undefined.

\settoggle{hnamei}{hvaluei}

Sets the boolean flaghnameitohvaluei which may be eithertrueorfalse. This command is robust and may be prefixed with\global. It will issue an error if the flag is undefined.

\iftoggle{hnamei}{htruei}{hfalsei}

Expands tohtruei if the state of the boolean flaghnamei is true, and to hfalsei otherwise. If the flag is undefined, this command issues an error.

\nottoggle{hnamei}{hnot truei}{hnot falsei}

Similar to\iftogglebut negates the test.

3.6 Generic Tests 3.6.1 Macro Tests

\ifdef{hcontrol sequencei}{htruei}{hfalsei}

Expands to htruei if the hcontrol sequencei is defined, and to hfalsei otherwise.

Note that control sequences will be considered as defined even if their meaning is\relax. This command is a LaTeX wrapper for the e-TeX primitive\ifdefined.

\ifcsdef{hcsnamei}{htruei}{hfalsei}

Similar to\ifdefexcept that it takes a control sequence name as its first argument.

This command is a LaTeX wrapper for the e-TeX primitive\ifcsname.

\ifundef{hcontrol sequencei}{htruei}{hfalsei}

Expands to htruei if the hcontrol sequencei is undefined, and tohfalsei otherwise.

Apart from reversing the logic of the test, this command also diVers from\ifdef in that commands will be considered as undefined if their meaning is\relax.

\ifcsundef{hcsnamei}{htruei}{hfalsei}

(15)

ment. This command may be used as a drop-in replacement for the\@ifundefined test in the LaTeX kernel.

\ifdefmacro{hcontrol sequencei}{htruei}{hfalsei}

Expands tohtrueiif thehcontrol sequenceiis defined and is a macro, and tohfalsei otherwise.

\ifcsmacro{hcsnamei}{htruei}{hfalsei}

Similar to \ifdefmacro except that it takes a control sequence name as its first argument.

\ifdefparam{hcontrol sequencei}{htruei}{hfalsei}

Expands tohtruei if the hcontrol sequencei is defined and is a macro with one or more parameters, and tohfalseiotherwise.

\ifcsparam{hcsnamei}{htruei}{hfalsei}

Similar to \ifdefparam except that it takes a control sequence name as its first argument.

\ifdefprefix{hcontrol sequencei}{htruei}{hfalsei}

Expands tohtrueiif thehcontrol sequenceiis defined and is a macro prefixed with

\longand/or\protected, and tohfalseiotherwise. Note that\outermacros may not be tested.

\ifcsprefix{hcsnamei}{htruei}{hfalsei}

Similar to \ifdefprefixexcept that it takes a control sequence name as its first argument.

\ifdefprotected{hcontrol sequencei}{htruei}{hfalsei}

Expands tohtrueiif thehcontrol sequenceiis defined and is a macro prefixed with

\protected, and tohfalseiotherwise.

\ifcsprotected{hcsnamei}{htruei}{hfalsei}

Similar to \ifdefprotectedexcept that it takes a control sequence name as its first argument.

\ifdefltxprotect{hcontrol sequencei}{htruei}{hfalsei}

Executeshtrueiif thehcontrol sequenceiis defined and is a LaTeX protection shell, andhfalseiotherwise. This command is robust. It will detect commands which have been defined with\DeclareRobustCommandor by way of a similar technique.

\ifcsltxprotect{hcsnamei}{htruei}{hfalsei}

Similar to\ifdefltxprotectexcept that it takes a control sequence name as its first argument.

Riferimenti

Documenti correlati

Simulation 2: variability of estimations on varying of sample size... Simulation 3: Variability of estimations on varying of individual

sapere quale di loro prevarrà: “L’attesa, che è di per sé necessaria all’Interessierend, è più grande nella lotta di due passioni piuttosto che in una passione soltanto.

The computation of chain equating coefficients is then performed in two steps: first, the calculation of direct equating coefficients between consecutive forms of a path and second,

45 As the first conviction of sexual violence based on command responsibility, this case arguably constituted a realization of the Court’s main objective of ending impunity

formatting markup, in cui il layout è controllato da comandi scritti internamente al documento digitale, ed occorre una fase di compilazione per eseguirli9. Testo

formatting markup, in cui il layout è controllato da comandi scritti internamente al documento digitale, ed occorre una fase di compilazione per eseguirli.. • La forma di

This paper considers specific housing management strategies: the self-management (Zelfbeheer in Dutch) in the Netherlands and the Integrated Social Management

Possibly different inactive ingredients (excipients, stabilizers, dyes, flavouring agents…).. Same salt, ester, complex Different salt,