# Disable microtype for a portion of a document

## Update: 2013-04-18

After upgrading to microtype 2.5 today this specific test cases indeed runs much faster (from approximately 3:00 minutes down to 8 seconds). However, I do have another cases where the compile time has not quite improved as much: only went down from 2:05 hr to 1:30 hr.

## Question:

I would like to disable the features of the microtype package for a portion of the document. I attempted to use \microtypesetup{activate=false} but that seems to have no effect. Additional options I tried included:

\microtypesetup{expansion=false}
\microtypesetup{protrusion=false}
\microtypesetup{kerning=false}
\microtypesetup{tracking=false}


and did not seem to fix the compile time issue.

## Background:

This problem seems related to Why does the use of microtype and xfrac lead to a high compile time? as my compile time for this small document is very large if all three of the \def defined at the top are uncommented: ie.,

• The microtype package is used, and
• \sfrac from the xfrac pacakge is used, and
• My "extended" version of the \bracr macro is used

Otherwise this document compiles just fine. With %\def\UseMicrotype{} commented, and the other two \def uncommented, this produces:

The last sentence is only to show why I need the "extended" version of the \bracr macro.

## Notes:

• I am using microtype from CTAN (2.4), and will update to 2.5 once it is released (which apparently does not have this long compile time issue with \sfrac). In the mean time, if there is a way to disable microtype that would be helpful.

## Code:

%%% Problems ONLY if ALL three of these are uncommented
%\def\UseMicrotype{}%    Enable use of microtype.
\def\UseExtendedBrac{}% Enable use of "extended" version of \brac macro
\def\UseSFrac{}%        Enable use of \sfrac

\documentclass{article}
\usepackage{showframe}%
\usepackage{amsmath}%
\usepackage{xfrac}%     Provides sfrac

\ifdefined\UseMicrotype
\usepackage{microtype}%
\fi

\ifdefined\UseExtendedBrac%
\makeatletter
\newcommand{\@Brac}[3]{% #1,#3 = left/right bracket type
\ensuremath{%
\left#1\vphantom{#2}\right.% left bracket
#2% content
\left.\vphantom{#2}\right#3% right bracket
}%
}%
\newcommand{\bracr}[1]{\@Brac{(}{#1}{)}}%
\newcommand{\bracs}[1]{\@Brac{[}{#1}{]}}%
\makeatother
\else% Works if these are used
\newcommand{\bracr}[1]{\left(#1\right)}
\newcommand{\bracs}[1]{\left[#1\right]}
\fi

\ifdefined\UseSFrac
\else% No problem if we don't use \sfrac
\renewcommand*{\sfrac}[2]{\frac{#1}{#2}}%
\fi

\begin{document}
\ifdefined\UseMicrotype
\microtypesetup{activate=false}
\fi
%
\begin{align*}
f(x,y)
&= \bracr{\frac{x^{ \sfrac{3}{2}}}
y^{-\sfrac{1}{2}}}^{\!\!\!-2} \\
&= \bracr{
\bracs{
\frac{x^{ \sfrac{3}{2}}}
{y^{-\sfrac{1}{2}}}}^2}^{\!\!\!-1}
\end{align*}
%
% Reason for using the "extended" brac as it yields line wrapping.
As we can see in the following, the \verb|\bracr| wraps around lines:
$\bracr{x^{-1} + x^{-2} + x^{-3} +x^{-4} + x^{-5} + \cdots }$
\end{document}

-
Are you sure is microtype or the fact that xfrac loads the LaTeX3 packages? –  Yiannis Lazarides Apr 4 '12 at 17:56
Its the interaction between microtype and xfrac. My "extended" bracr macro just makes things much worse. If you don't use microtype things work just fine (this is how the code as posted is: disables microtype, uses \sfrac). –  Peter Grill Apr 4 '12 at 17:58
Just a note: nicefrac causes the same problems as xfrac –  Canageek Apr 18 '12 at 19:17

Just in case you're still using the rather old, yet still official version 2.4: the undocumented key disable will really turn off microtype, enable will, well, enable it again:
\microtypesetup{disable}

+1 As, this certainly helps, but not sure that it totally turns off microtype. Without your solution, and with %\def\UseMicrotype{} commented, this takes approx 3 seconds to run. With micortype enabled it takes about 3 minutes to run, which is an increase in the run time of a factor of 60x. With the addition of \microtypesetup{disable} before \begin{align*}, and \microtypesetup{enable} before \end{document}, the run time drops to 30 seconds. So, it is still takes about 10 times longer to run. –  Peter Grill Oct 7 '12 at 2:31
It does totally turn off microtype for that part of the document. The delay you experience then happens at \begin{document} resp. \end{document}. Just for the record: with microtype 2.5 it would take about 7 seconds with microtype enabled throughout (on my computer, I get similar times as you do) –  Robert Oct 7 '12 at 2:47