{etoolbox} is a package which provides several macros which take advantage of the {e-tex} extension of (La)TeX.

learn more… | top users | synonyms

8
votes
3answers
1k views

Extract number from string and compare problem

I try to extract the year, month and day from a string and write different text depending on the given date. I thought I could use xstring and etoolbox, but I can'st get it to work. Here's the code ...
3
votes
1answer
194 views

Code fails when loading boolexpr

I use this code to check for existing column style (see also this question) But it fails as soon as I load the package boolexpr. Is this incompatible with etoolbox? \documentclass[]{scrbook} ...
15
votes
1answer
776 views

biblatex: Is it possible to patch macros created with \newbibmacro?

This question led to a new feature in a package: xpatch The etoolbox package provides various tools that "are useful to hook into or modify existing code" (etoolbox manual, section 3.4). The ...
9
votes
1answer
473 views

Hiding section titles when the section is empty

I have created a macro like this: \newcommand{\showsection}[2]{ \ifstrequal{#2}{}{}{\section{#1} #2} } It should be used like this in the document: \showsection{Books}{ Do you know any ...
17
votes
6answers
1k views

Checking if a number is a multiple of 4

Using etoolbox, ifthen, or another form of conditional checking, how can I check if a value is a multiple of 4? E.g. if the number is 4, 8, 12, 16, etc., then it returns "true".
9
votes
2answers
1k views

Checking if two conditionals are met

I am using the etoolbox package to check some variables. I can use \ifnumless{a}{b}{True}{False} to check if "a" is less than "b" and output "True" if true and "False" if false". How can I check if ...
9
votes
5answers
399 views

How can I undo an etoolbox patch?

Suppose I patch an environment using an etoolbox command such as \AtBeginEnvironment or \AfterEndEnvironment, etc. How can I undo these changes at a later stage? \documentclass{article} ...
17
votes
6answers
876 views

Placing many conditionals in a series

I frequently need to do something like this: IF x < 1, DO a ELSE IF x < 2, DO b ELSE IF x < 3, DO c ELSE, DO d Using etoolbox, I end up nesting a lot of ifnumless, like this: ...
6
votes
2answers
523 views

etoolbox: environment hooks in boolean switch

What did I wrong, that the following does not work here: (Edit: I mixed up the true and false parts, but I don't want to change the code, because the answers refer to this in a way confusing one.) ...
4
votes
1answer
507 views

Current section title macro using titlesec

I have a macro that contains the title for the current section, however when using the titlesec package, it no longer works for \section and \subsection. I know titlesec redefines the functions I'm ...
3
votes
1answer
380 views

latex @temps(wa) commands

I would like to know more about the temporary commands of LaTeX, such as \@tempa, \@tempswatrue especially for the following construct, where I wonder if my replacement is correct: % Provide bool for ...
7
votes
1answer
187 views

Patching a song environment

I'm having some fun with another songbook project, and this one has a particular feature: in the header, the range of song numbers is displayed, in order to ease the searching (similar to a ...
5
votes
2answers
388 views

Special handling of first and/or last item in an etoolbox list

Is there a simple way of handling the first and/or the last item in an etoolbox-based list in a special way? Here’s a simple example: \documentclass{article} \usepackage{etoolbox} \begin{document} ...
3
votes
1answer
218 views

Undefined control squence \Hy@writebookmark upon patching section command in beamer

I attempted to provide a solution to Renew section command to wrap whole section in an environment and thought the best way was to use etoolbox to patch the \section command. But this leads to: ! ...
2
votes
1answer
194 views

Firsttitlemarks does not appear consistently in header

I am using this code for my header marks, but as you can see it misses the very first mark for the subsection which should be the first verse. % definition of the page style with required headers ...
6
votes
1answer
261 views

Why am I processing a comma-separated list incorrectly when using etoolbox and kvoptions?

I'm trying to pick something out of a list that has been passed from some package options by kvoptions, but docsvlist doesn't appear to be recognising the commas. I suspect this may be something to ...
10
votes
1answer
3k views

Comparing an argument to a string when argument is a result of a command with etoolbox

I've got an example like that: \documentclass{article} \usepackage{etoolbox} \newcommand{\ab}{a} \newcommand{\aORb}[1]{% \ifstrequal{#1}{a}{"a" was given}{not a}, % ...
1
vote
1answer
519 views

Modify chapter command (and KOMA-script addchap)

Is there something like etoolbox's \appto, that also works for \chapter and \addchap? edit: I intend to use it to re-enable page numbering (which may or may not be disabled using ...
24
votes
3answers
2k views

How can I use \patchcmd with commands with optional arguments?

This question led to a new package: xpatch This is likely a simple question, but I'm getting stuck on the small details. I have an internal command, defined by a package as ...
2
votes
3answers
710 views

TeX Nested Loops With \iftoggle

This forum has helped me understand how to use nested loops in TeX, but now I am having trouble using \iftoggle (from the etoolbox package) with loops. My goal is to have a toggle that can keep track ...
18
votes
3answers
593 views

Should LaTeX counters always be modified globally?

In this answer, egreg states that "LaTeX counters should always be modified globally". However, the etoolbox package provides the \defcounter macro which will assign a value to a previously ...
5
votes
1answer
608 views

Changbars to indicate location of conditional text

I am using etoolbox as per this question on LaTeX conditional expression, and would like to modify the conditional to print some sort of indicator (like a vertical change bar in the margin) to show ...
6
votes
2answers
818 views

Package incompatibilites: etoolbox, hyperref, and bm, standalone?

I am trying to transition to using the etoolbox package, but seem to have run into some difficulties and they appear related to the hyperref and bm packages which to me seem totally unrelated. The ...
8
votes
3answers
502 views

\expandafter, \csname issue related to test for macro being defined

Just when I think I starting to understand \expandafter I run into this problem where I am trying to test if \ConditionG, \ConditionH, etc are defined in a loop. I tried all the combinations I could ...
5
votes
1answer
308 views

Biblatex: Idiom for testing contents of list field

I am creating a Biblatex bibliography style for legal citations. In one particular case, I need to format the citation (of a court decision, i.e. jurisdiction) differently depending on the particular ...
10
votes
5answers
1k views

How to test if a number is negative

Is there an easy way to test if a number is negative? I don't need a general solution, but it does need to be able to handle a floating point value. I was using this solution from tex.ac.uk until I ...
6
votes
1answer
258 views

Using ted (or another package) instead of etoolbox for patching commands in memoir?

Another question related to my university's odd ToC style requirements. Regular chapters in the ToC need to have all-caps titles, and appendices need regular-case titles. I have a perfectly elegant ...
4
votes
1answer
486 views

Hyperref breaks my all-caps ToC entries

I started out on this earlier question. I now have a simple and elegant etoolbox solution to making all-caps chapter entries, but leaving appendix entries untouched. Simple, elegant, and incompatible ...
6
votes
1answer
768 views

Making memoir Chapter entries in ToC all-caps and Appendix entries regular case, without breaking hyperref

I have a thesis style working, but around 10% of my code is a copy of memoir's \def\@chapter that lets me put all regular chapter entries in all caps, and keep appendix entries in regular case. This ...
3
votes
2answers
391 views

Run macro before each slide in beamer

Following on from this question, is there an easy way to call a macro before each slide? So that question answers how to get at each frame, but I want finer control... I want a macro that sets a ...
4
votes
1answer
409 views

Booleans fail in tabular environment

I've got a workaround for this problem, but maybe someone knows a cleaner way to fix it. I'm using the standard packages in TexLive 2009. Here's the code that doesn't work: \documentclass{article} ...
6
votes
3answers
571 views

etoolbox conditional causes unwanted empty row in tabular

This code leaves an empty row at the bottom: \documentclass{article} \usepackage{etoolbox} \def\somedef{foo} \begin{document} \begin{tabular}{|l|} \hline First row, not important \\ \hline ...
15
votes
4answers
2k views

Making switch/case with etoolbox's \ifdefequal

I've got a define such as \def\doctype{SomeString}. \doctype can take on one of five values. I want to do something like a switch statement in a programming language, i.e. (pseudocode): switch ...