# “Extra \fi” errors in equation environment with savetrees

I get the Extra \fi error for the line in the following code.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{savetrees}
\usepackage{amsmath}
\begin{document}
$$2+2=4$$
\end{document}


Why is that? How do I fix it?

The filelist:

 *File List*
article.cls    2007/10/19 v1.4h Standard LaTeX document class
size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
inputenc.sty    2008/03/30 v1.1d Input encoding file
utf8.def    2008/04/05 v1.1m UTF-8 support for inputenc
t1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
ot1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
omsenc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
savetrees.sty    2011/05/14 v2.0 Pack as much text as possible onto each page
xkeyval.sty    2008/08/13 v2.6a package option processing (HA)
xkeyval.tex    2008/08/13 v2.6a key=value parser (HA)
titlesec.sty    2011/12/15 v2.10.0 Sectioning titles
geometry.sty    2010/09/12 v5.6 Page Geometry
ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
ifvtex.sty    2010/03/01 v1.5 Switches for detecting VTeX and its modes (HO)
ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
calc.sty    2007/08/22 v4.3 Infix arithmetic (KKT,FJ)
microtype.sty    2010/01/10 v2.4 Micro-typography with pdfTeX (RS)
microtype.cfg    2010/01/10 v2.4 microtype main configuration file (RS)
amsmath.sty    2000/07/18 v2.13 AMS math features
amstext.sty    2000/06/29 v2.01
amsgen.sty    1999/11/30 v2.0
amsbsy.sty    1999/11/29 v1.2d
amsopn.sty    1999/12/14 v2.01 operator names
mt-cmr.cfg    2009/11/09 v2.0 microtype config. file: Computer Modern Roman (RS)

-
Welcome to TeX.SE. Seems to work if you use $ and $, but don't know what the problem is with equation environment. – Peter Grill Mar 22 '13 at 4:49
Weird. The inputenc package does not seem to cause the problem. No error occurs if the equation environment is replaced by $2+2=4$. There must be a package clash between amsmath and savetrees. Since amsmath is so useful, I advise you to forget about savetrees for the time being (until the issue gets fixed). – Jubobs Mar 22 '13 at 4:51
Can you add \listfiles to the start of your input, and edit into the question the *File List* that appears in the log. For me with an up-to-date TeX Live 2012 there seems to be no issue. – Joseph Wright Mar 22 '13 at 8:19
It looks like there is no error when align environment is used instead of equation. – g.kov Mar 22 '13 at 9:51

this is clearly a bug, and has been logged in as such in the ams bugs list. however, the bug isn't in amsmath, but in another package; see update below.

as reported in comments, there is no problem with $...$ or with the align environment.

curiously, there is no problem either with the equation* environment, which differs from equation only in the application of the equation number.

although it is not recommended to use align for single-line displays, if savetrees is a necessity, that could be used as a workaround.

i can't predict when an overhaul of amsmath will be scheduled, but the bug report has been duly logged and will be considered with all other bugs at the appropriate time. since the bug isn't in amsmath itself, all that will be done is to check that the problem doesn't recur with current versions of all used packages.

UPDATE: with @egreg's help, the source of the problem has been identified.

with the newest version of the microtype package, the test file runs through with no problems. these are the relevant components:

microtype.sty    2013/03/13 v2.5 Micro-typographical refinements (RS)
microtype-pdftex.def    2013/03/13 v2.5 Definitions specific to pdftex (RS)
microtype.cfg    2013/03/13 v2.5 microtype main configuration file (RS)
mt-cmr.cfg    2011/04/09 v2.1 microtype config. file: Computer Modern Roman (RS)


this version, included in tex live 2012, will fail:

microtype.sty    2010/01/10 v2.4 Micro-typography with pdfTeX (RS)
microtype.cfg    2010/01/10 v2.4 microtype main configuration file (RS)
mt-cmr.cfg    2009/11/09 v2.0 microtype config. file: Computer Modern Roman (RS)


anyone encountering a conflict between amsmath and savetrees should update their installation with a new version of microtype.

-
Still I don't get any error; I tried equation, align, gather and *-variant thereof. – egreg Mar 22 '13 at 12:51
@egreg -- please send me your versions list off-line. we're using tex live 2012, and i definitely get the reported error. – barbara beeton Mar 22 '13 at 13:05
The 2.5 version of microtype has been in TeX Live for some weeks. – egreg Mar 22 '13 at 16:10
Indeed, my installation had the 2.4 version. – XXYXXY Mar 22 '13 at 18:19