Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I found an incompatibility between onlyamsmath and tabu, related to the redefinition of the $-sign. (Its is an active char, and thus breaks inside tabu columns specifiers). This is triggered with:

\documentclass{article}
\usepackage{amsmath}
\usepackage[all,error]{onlyamsmath}
\usepackage{tabu}
\begin{document}
\begin{tabu} to 0.6\textwidth{X[c]X[c]X[$c]} 
a & b & c\\ 
\end{tabu} 
\end{document}

If I could restore the original definition of $ at the beginning of the document I could work around the bug. Note that I want to include this 'bugfix' in a package and can not rely on the correct loading order. So I do not want to enforce loading before onlyamsmath.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

You can patch the tabu environment so that it sets the correct catcode

\usepackage{tabu}
\usepackage{etoolbox}
\AtBeginEnvironment{tabu}{\catcode`$=3 }

In this way the "protection" given by onlyamsmath is disabled only inside the tabu environment.

share|improve this answer
add comment

You need to set the catcode of $ back to its normal value of 3. However, onlyamsmath does this at-begin-document and you need to change it back after that. In order to ensure that, you can use the filehook package and then:

\AtEndOfPackageFile*{onlyamsmath}{\AtBeginDocument{\catcode`\$=3\relax}}

Which will install the required code in the at-begin-document hook at the end of onlyamsmath, if it gets loaded or immediately, if it was already loaded.

Full example (both orders work):

\documentclass{article}
\usepackage{amsmath}

\usepackage{filehook}
\AtEndOfPackageFile*{onlyamsmath}{\AtBeginDocument{\catcode`\$=3\relax}}

\usepackage[all,error]{onlyamsmath}
\usepackage{tabu}

%\usepackage{filehook}
%\AtEndOfPackageFile*{onlyamsmath}{\AtBeginDocument{\catcode`\$=3\relax}}

\begin{document}
\begin{tabu} to 0.6\textwidth{X[c]X[c]X[$c]} 
a & b & c\\ 
\end{tabu} 
\end{document}
share|improve this answer
    
This disables many of the features of onlyamsmath. –  egreg Nov 17 '11 at 11:39
    
@egreg: I guessed so, but I simply delivered as ordered. –  Martin Scharrer Nov 17 '11 at 12:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.