{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
185 views

How do I use the etoolbox package to check if an argument to a macro was defined?

I saw this answer, which uses the etoolbox package to create a macro with an optional argument. Unfortunately, I can't get it to work. Here is a minimal working example: \documentclass[12pt]{article} ...
5
votes
2answers
70 views

How to combine \ifdefstring (etoolbox) with \multicolumn

I need to make tabulars with either norwegian or english column heading above the numbers. I have defined a command, \ReportLanguage, that can be set to either of two values, "no" for norwegian, and ...
5
votes
1answer
68 views

Error output using \ifdefempty

I'm using TeX 3.1415926 (TeX Live 2013) and when I execute \documentclass{article} \usepackage{etoolbox} % contents \newcommand{\contentdesc}[2]{\item \ifdefempty{#2}{\textbf{#1}}{\textbf{#1}: ...
27
votes
2answers
338 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 ...
4
votes
1answer
97 views

Loop Multi-Contingency using etoolbox

I want to use the etoolbox package to manage some loop contingencies over a counting index. In particular, I'd like to do something different on the first and last times through the loop. Now I can ...
7
votes
1answer
128 views

I'm confused about how expansion is happening here

I was really pleased that I could come up with a means of building the contents of a tabular environment using \foreach \x in {...} {...} structure. But I was curious about what exactly it would take ...
11
votes
2answers
175 views

How to create a macro “environmentally-dependent”

Yesterday I was reading the etoolbox documentation where there are defined some new document commands such as: \Before<Begin/End>Environment{<envir>}{<code>} % ...
20
votes
2answers
228 views

Is there an easy way to patch commands containing ^^J?

I'm currently looking at various questions related to multicol and try giving answers to some of them. Often enough the answer would involve patching \balance@columns or similar macros and in that ...
4
votes
1answer
136 views

e-Tex and TexWriter

I'm using TexWriter as a LaTeX editor on my iPad. When I try to compile a document I get the following error:"!package etoolbox Error: Not running under e-TeX." I'm also using enumitem package. Is ...
7
votes
2answers
217 views

Incompatibility between etoolbox and hyperref

I tried to compile Werner's second answer from Automatically number inequalities with the hyperref package. However, the first run will give me the error below: Runaway argument? {\@firstoffive }\fi ...
5
votes
1answer
154 views

Package etoolbox Warning: Patching '\begin' failed!

After updating my MiKTeX 2.9 package, .tex files which compiled perfectly with 0 error 0 warning now gives 0 error 1 warning: Package etoolbox Warning: Patching '\begin' failed! (pdflatex) ...
6
votes
2answers
113 views

etoolbox ifblank error with xkeyval

I am trying to create my first class, which is basically just my ordinary preamble with a set of options. These options are handled by xkeyval using the following syntax: \NeedsTeXFormat{LaTeX2e} ...
5
votes
1answer
130 views

How to implement the macros style with mixed chars and floats in a csv file?

I would like to implement macros to generate multiple tables in a document. Some inspiration comes from here: usage-of-longtable-or-equivalent-and-pgfplotstabletypeset The input csv file and ...
11
votes
2answers
182 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 ...
5
votes
2answers
193 views

Transforming string into tabular row

Trying to have a command converting a string into a (tabular) row, where each cell of the row is (a function of) each character of the string. (\tilerow is my attempt, \tiletext is just for ...
1
vote
1answer
184 views

threeparttable - appending commands to \TPTnoteSettings does not work if package called with flushleft option

In the tablenotes environment defined by the threeparttable package, I wanted to resize my notes globally throughout my document. I have found this answer to a question somebody posted in regards to ...
10
votes
1answer
201 views

Is \AfterEndPreamble really executing code after any \AtBeginDocument code?

The babel package loads the (last) language at begin document, thanks to an \AtBeginDocument command (lines 12.256 and 12.257 of its kernel): \AtBeginDocument{% ...
5
votes
3answers
307 views

Using \ifstrequal in a fontspec macro

Here is my Minimal Failing Example: \documentclass{article} \usepackage{fontspec,etoolbox} \setmainfont{TeX Gyre Schola} \begin{document} \newcommand\Stretch[1]{ \ifstrequal{#1}{narrow}{0.6}{} ...
5
votes
1answer
180 views

Why is \patchcmd not working when also using \@ifclassloaded? [duplicate]

Why do these two MWEs produce different effects? \documentclass{article} \usepackage{etoolbox} \makeatletter \def\aeloaded{Not loaded} \def\aechanged{Not changed} \patchcmd{\l@section} ...
3
votes
0answers
32 views

Integer operations on cross references [duplicate]

I would like to perform integer operations on a cross reference. \documentclass{article} \usepackage{etoolbox} \begin{document} hello \label{here} \ifnumequal{\pageref{here}}{1}{You are on the 1st ...
9
votes
2answers
127 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 ...
1
vote
1answer
452 views

Solutions in exam class

I'm trying to write up solutions to some exercises, using the exam class. In order to align equations correctly, I'm also using the aligned environment from amsmath. To avoid too much repetitious ...
6
votes
2answers
106 views

Chapter count not increasing

Consider the following MWE: \documentclass[12pt,twoside,letterpaper]{report} \usepackage{etoolbox} \newcounter{totchapters} \providecommand\totchap{} \makeatletter \AtEndDocument{% ...
12
votes
2answers
239 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 ...
2
votes
1answer
127 views

Empty page on the Part page

I'm using this on my document (scrartcl documentclass): \usepackage{etoolbox} \pretocmd{\section}{\cleardoubleevenemptypage}{}{} \pretocmd{\part}{\cleardoubleevenemptypage}{}{} This makes me get ...
11
votes
3answers
320 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 ...
8
votes
4answers
214 views

Special macro definition (2opt, 1mand)

How can you define a macro \cmd in TeX primitives using two optional arguments (and a mandatory one) that fulfills the property that calling \cmd[opt]{mand} is equivalent to \cmd[][opt]{mand}. Yet, I ...
8
votes
2answers
119 views

Getting \let definitions from inside a group, inside a loop

I have the following nested loop situation: \begingroup \def\do##1{% \begingroup \def\do####1{% \csletcs{somemacro@##1@####1}{someothermacro@##1@####1}}% ...
1
vote
0answers
44 views

Creating a csname from a macro [duplicate]

Say I have a macro \bob and that macro is passed to another macro as an argument: \makemacro{\bob} I want \makemacro to create another macro, based on the name of the passed macro, say \bob@two. ...
6
votes
1answer
102 views

set pdfauthor using complex list-processing macro

I have created a macro, \joinlist, that adds commas or other delimiters between the elements of an etoolbox internal list. It has special handling for lists of just two elements ("a and b"). It also ...
6
votes
1answer
129 views

Why doesn't font family change take effect when using AtBeginEnvironment{figure} together with memoir?

I'm trying to use \AtBeginEnvironment{figure} to customize the font family and font size used in figures. However, it doesn't seem to have any effect. Here is a minimal example: ...
5
votes
2answers
917 views

Upright bold greek with condition in math mode

Good day! I googled the whole stackechange, but was not able to find the answer. I'm quite new to Latex, so my approach is not proper. I try to define a macro, that should format greek letter as ...
6
votes
2answers
169 views

Delaying command expansion that appears in \begin handler until \end handler executes

I have a custom environment for handling a code interface declaration that is specified as: \begin{decl}{FOO} \param{in}{bar} the bar input parameter \param{out}{baz} the baz input parameter ...
3
votes
1answer
66 views

\setbool not respected in footnote?

Can someone explain why \setbool (from etoolbox) is not respected when used in a command only used in a footnote? \documentclass[12pt]{article} \usepackage{etoolbox} \newcommand{\longshort}[1][]{% ...
3
votes
1answer
140 views

Preprocessing without compiling with etoolbox

I want to know if it is possible to do preprocessing without compiling with the etoolbox package. Basically, I want to do the following. Given a file of the following format: ...
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 ...
7
votes
1answer
159 views

Getting a random sublist from a given list

The etoolbox package provides macros to handle list, which can be useful to package/class writers, however it miss macros to get random sublists. So I want to define the following macros: ...
3
votes
1answer
95 views

how to comment text depending on a number

I have a latex document with 24 questions labeled with numbers from 1 to 8. I want to give a number x between 1 and 8 to latex in the preamble so that all the questions become commented except the ...
9
votes
2answers
112 views

Ease the handling of labels

I want to ease the handling of labels in my document, and I want to show the label for a section if define a "variable". Currently I'm doing it like this Setting the up the "variable": ...
1
vote
1answer
253 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: ...
6
votes
1answer
767 views

Applying condition around \intertext and \shortintertext leaves excess vertical space

When I try to make either \intertext or \shortintertext conditional I get excess vertical spacing prior to the conditional text as per the MWE below. Note the excess vertical spacing prior to "Albert ...
8
votes
2answers
514 views

Patch tabular environment with colorbox

I'm trying to quickly add a colored background using colorbox to all tables as shown in this answer. While I could just update all the TeX by hand, I am trying to patch the tabular environment to ...
1
vote
1answer
136 views

Problem if csv list is stored in macro for later use with \forcsvlist

I need to store a csv list for later use in the end code part of an environment. Can somebody explain me what's going wrong in the following example? \documentclass{article} \usepackage{etoolbox} ...
1
vote
1answer
169 views

generalize \iftoggle in etoolbox

I am using nested loop conditional \iftoggle of etoolbox, is there any other generalized conditional? Usually it works as: \newtoggle{name} \settoggle{name}{true} \iftoggle{name}{do if name is ...
11
votes
1answer
127 views

Save an etoolbox list to a file … and read it after

I have a problem. I would like : to construct an etoolbox list to save this list in a temp file to read this list from this file at the next run to use this file. For any reason, I can't see the ...
5
votes
3answers
295 views

Correct way of test blank element in array

I'm trying to test whether an element in a defined list (array) is "empty." I tried using the \empty macro, or putting white spaces inside the quote, but nothing seems to work. I'm testing the ...
13
votes
1answer
395 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
406 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
300 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 ...