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

learn more… | top users | synonyms

5
votes
1answer
639 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 ...
15
votes
1answer
858 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 ...
10
votes
5answers
2k 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 ...
12
votes
2answers
233 views

Patching arguments inside a macro

Consider the following example of a patch using etoolbox and a dummy macro \abc: \documentclass{article} \usepackage{etoolbox}% http://ctan.org/pkg/etoolbox \newcommand{\abc}[2]{#1\ #2}% Magic ...
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 ...
27
votes
2answers
334 views

What's the difference between the various methods for producing for loops?

I've been wondering about the various methods available for looping over a comma separated list and the like. In particular, I was wondering about their various strengths and weaknesses. In other ...
6
votes
2answers
906 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 ...
16
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 ...
17
votes
6answers
2k 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
1answer
313 views

Macro to automatically save section name of previous section and next section

EDIT: I've edited the code that reproduces the anomalies, but I'll work on the code to more accurately depict the problem later on the day. Weird spacing in index Index doesn't appear in footlinks / ...
17
votes
2answers
1k views

Difference between \newbool and \newtoggle from etoolbox package

Paul Gaborit's answer to How to detect if option provided via \tikzset uses \newbool to define a new boolean \booltrue to set a boolean, and \ifbool to perform a conditional operation all from ...
11
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}, % ...
9
votes
1answer
527 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 ...
3
votes
2answers
410 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 ...
11
votes
1answer
214 views

Problems with mathtools package

The following code produces an error. If the mathtools package is removed, it works. Why? \documentclass{report} \usepackage{mathtools} \usepackage{etoolbox} \newbool{shorttoc} \makeatletter ...
8
votes
2answers
349 views

How to append code to a section?

In my scrartcl document I want to change the spacing between sections and the first paragraph. Since I am using the parskip package, the parskip is set to a non-zero value. The \section command uses ...
8
votes
2answers
393 views

Trouble changing font size in figure legends

I'm trying to set the font size smaller in the legends for all of my figures and tables. The way I was trying to do this was using \AtBeginEnvironment but that doesn't seem to do anything at all. This ...
4
votes
1answer
572 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 ...
17
votes
6answers
985 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: ...
13
votes
3answers
550 views

Get n-th element of a list (with etoolbox, or not)

I'm defining a list and I need to obtain the n-th element of this list. I was surprised that etoolbox doesn't provide a way to obtain it. The way I found to obtain the n-th element is along these ...
9
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 ...
9
votes
2answers
126 views

Provide boolean from two arguments case insensitives

In most publications scientific names are abbreviated except the first time. Moreover, the names must be in italics and only the first letter of the generic name should be upper-case. The biocon ...
8
votes
2answers
168 views

Append \centering to \begin{subfigure} (from subcaption package)

How can I append \centering to \begin{subfigure} (from subcaption package)? I tried using the etoolbox , but for some reason it won't work for the subfigure enviroment (only working for the figure ...
11
votes
3answers
313 views

Understanding etoolbox \ifdefempty and \ifdefvoid

I am trying to understand the etoolbox \ifdefempty and \ifdefvoid macros. The documentation says that \ifdefempty Expands to true if the control sequence is defined and is a parameterless macro ...
6
votes
1answer
286 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 ...
5
votes
2answers
111 views

Boolean key value in xkeyval fails

It is possible to hand over a boolean key value stored in a macro to a command such as \edef\SomeKeyValue{true}% \DummyCommand[DummyBooleanKey=\SomeKeyValue]%%% where DummyBooleanKey is a boolean ...
18
votes
3answers
637 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 ...
11
votes
2answers
179 views

How to process a list and ignore spaces?

This question is part of a new package: metrix. Typeset metric/prosodic symbols standalone and above syllables. I’m wrinting a new package and I need to process a list (using etoolbox at the ...
7
votes
2answers
249 views

Incompatibility between etextools and etoolbox command \dolistloop (\forlistloop)?

The following code uses the etoolbox package to convert a list a,b,c into an internal list (called \mylist) and then typesets that with colons: a:b:c:. However, when I load the etextools package (by ...
6
votes
1answer
1k views

Command \AtBeginEnvironment already defined

I am pretty new to LaTeX. With windows, Miktex/Texmaker pretty-much takes care of package installation whenever needed, but on Ubuntu I have been downloading needed packages from CTAN and installing ...
6
votes
2answers
574 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.) ...
6
votes
1answer
849 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 ...
6
votes
3answers
589 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 ...
4
votes
1answer
377 views

etoolbox's iftoggle vs verbatim

My problem is that I can set up toggles, using etoolbox's \newtoggle{x}, set it to true with \toggletrue{x} and even use it with iftoggle{x}{this for true}{this for false}. However, if I try to put a ...
3
votes
1answer
60 views

Auto generate list-items within table from string with delimiter

This is a follow-up on this question: Creating bullet-list from string with delimiters I have a CSV file where I genereate some tables from. Some of those table cells will have items that should be ...
3
votes
1answer
56 views

Wrong placement for \preto using etoolbox

I'm observing that the adding a text to a list of tables (or figures) through \preto from etoolbox does not work properly when the table is placed on the next page if it does not fit the page where it ...
3
votes
1answer
201 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} ...
3
votes
1answer
413 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 ...
3
votes
1answer
226 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: ! ...
1
vote
1answer
248 views

Hyperref link jumps to the first entry of the bibliography entry rather than to its title [duplicate]

This is a follow-up question to Gonzalo Medina's answer of Bibliography in table of contents. One of his solutions for including the bibliography in the ToC is to use the following code: ...