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

learn more… | top users | synonyms

13
votes
1answer
406 views

Help automating calendar creation

I'm doing calendars for all the family, and I have a problem automating the process. I'm using the calendar tikz library. I need to include the moon phase in the calendar. I can do it with this code ...
4
votes
1answer
1k views

Conflict between ntheorem and amsthm

I am using etoolbox and ntheorem packages to have a custom numbering of theorems and equations. Everything works but these side errors occur: \qedhere command is unknown (EDIT: following some ...
7
votes
2answers
409 views

Auto-generating tables using etoolbox

I have a particular problem which I am trying to solve using etoolbox, but I can't figure out how. What I'm trying to do is to auto-generate a table based on information from a previous table. This is ...
9
votes
3answers
305 views

Create macro with several options

I struggle to create a macro that can take several options. What I want to create is for \mycommand[up,middle]{Macro} to output Macro with 'up' and 'middle' specified. Using etoolbox in the MWE below ...
13
votes
3answers
580 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 ...
2
votes
1answer
115 views

etoolbox patch lstlistings

This is a follow up question to empty page afterpage listings. I'm trying to work around a listings problem with etoolbox: \documentclass{scrartcl} \usepackage{listings} \usepackage{afterpage} ...
4
votes
1answer
406 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 ...
8
votes
2answers
386 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 ...
6
votes
2answers
200 views

Using etoolbox macros in tikz foreach loops

I am trying to wrap my head around etoolbox for use with TikZ. In this example (I know there are probably simpler ways to do this), I would like to draw a series of rectangles that are next to each ...
3
votes
2answers
335 views

Make a PDF bookmark point towards title

I've been using the bookmark package to add custom PDF bookmarks to my thesis. More specifically, I started using this package because I didn't want the the ToC, LoF and LoT to appear in the ToC, but ...
11
votes
1answer
205 views

Using etoolbox to automatically generate input for \xymatrix

I'd like to make a command \exactseq such that, for example, \exactseq{A,f,B,g,C} corresponds to \xymatrix{A \ar[r]^{f} & B \ar[r]^{g} & C} and such that this works for inputs of ...
6
votes
2answers
313 views

Using \notblank in etoolbox's \ifboolexpr statment

As the title says, I am currently trying to use etoolbox's \ifboolexpr statment on \notblank conditions but I am having issues with it. The code concerned looks like this : \ifboolexpr{% test ...
2
votes
1answer
306 views

Phantom and etoolbox iftoggle

Is there a way to conditionally 'phantom' parts of my document (without typing the same 'phantomed' text twice)? Currently, I am using the etoolbox package, newtoggle/settoggle, and iftoggle to ...
1
vote
1answer
78 views

In output PDF, first letter after \iftoggle condition is removed

When iftoggle condition is used, first letter after the condition is removed in the output. Consider below code \documentclass{article} \usepackage{etoolbox} \begin{document} \newtoggle{test} ...
3
votes
0answers
200 views

Sorting list with etoolbox [closed]

I would like make a listing of shortseries fields in my .bib file. I see etoolbox can help make to made a list of themes and to loop on them. My idea is : for each entry, add the shortseries and ...
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 ...
11
votes
1answer
233 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
415 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
146 views

Append the contents of an environment to a hook using \gappto

I have a global hook (=macro) that should be appended to whenever an environment is executed. (Here, defined by the \bhook-\ehook pair.) However, I was unable to derive a working solution. ...
8
votes
1answer
162 views

On pitfalls of robust commands

These days, I’m more and more defining robust commands, e.g., using \newrobustcmd (etoolbox package) or \NewDocumentCommand (xparse package). Robust commands seem advantageous to me in many respects ...
3
votes
1answer
158 views

multiple lists in etoolbox

I'm trying to have a number of lists using etoolbox that I process near the end of a document. There may be a large number of these lists, and I do not know how many I will have beforehand, so I have ...
4
votes
2answers
236 views

l3prop property stores and etoolbox loops: weird results

I'm writing a class for handling multi-language jargon formulas. My idea is to use l3prop to store, for each formula, its language variations -- i.e., a sort of hash table. Building on one of the ...
8
votes
1answer
312 views

Is there a workaround for this limitation of \patchcmd?

The \patchcmd command of the well-known etoolbox package has a minor limitation: Patching seems to fail whenever \patchcmd is used in the argument of another command and the search/replacement texts ...
6
votes
4answers
567 views

Illegal parameter number with \docsvlist

I'm trying to define a macro that take as an input a CSV list and create an item list. etoolbox comes just handy for this and the macro I'm using is \begin{itemize} \renewcommand*{\do}[1]{\item[] ...
10
votes
2answers
576 views

Why using a backslash in command definitions?

I want to know the reasoning behind the (La)TeX inferface for defining commands with leading backslashes. I see why a backslash has to be used to call (expand) a command (macro), but I do not ...
4
votes
1answer
491 views

etoolbox: trouble with boolean expressions

I'm new at making macros and am in the process of building a package to produce course outlines. I want the user to input room/day/time information as below (where everything has been simplified to ...
1
vote
1answer
146 views

Using toggles from etoolbox to switch Sweave Schunks of code on and off

I would like to use the toggles from etoolbox to direct Sweave to evaluate or not evaluate chunks of code. Example: \newtoggle{FirstTime} \toggletrue{FirstTime} %\togglefalse{FirstTime} ...
6
votes
1answer
967 views

Switch Between Bibliography and Appendix in fancyhdr

What I am trying to accomplish is a fancyhdr that places Appendix or Bibliography in the header with one single definition. So if I am in the bibliography it should display Bibliography, but should ...
8
votes
3answers
390 views

error when patching with etoolbox \apptocmd: “the patching command seems to be nested in the argument to some other command”

The \apptocmd command from etoolbox is giving me an error I don't understand. I know how to work around the error in this particular case, but I'd like to understand what it's complaining about so ...
3
votes
1answer
434 views

Create a macro that appends some code an existing command, with arguments

As I am working on improving my answer to Different approach to literate programming for LaTeX, I have created a macro that automatically processes two arguments and formats indexes accordingly. The ...
7
votes
2answers
256 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 ...
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 ...
3
votes
1answer
204 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
883 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
549 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
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
2answers
2k 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
458 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
1k 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
603 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
554 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
424 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
204 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
442 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
227 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
206 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
299 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 ...
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}, % ...
1
vote
1answer
599 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 ...