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.

In my previous question I ended up with

\DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}

But now I'm using the fontspec package which redefines : with \AtBeginDocument itself. So as my own definition comes before fontspec is loaded, even putting it in \AtBeginDocument won't help.

Is there a way to say “Execute this after fontspec has loaded!” or “Execute this at the very end of \AtBeginDocument!”?

share|improve this question

3 Answers 3

up vote 15 down vote accepted

According to the documentation of afterpackage this should work

\usepackage{afterpackage}
\AfterPackage{fontspec}{%
  \AtBeginDocument{\DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}}%
}
share|improve this answer
    
Great, thank you! –  canaaerus Jul 24 '12 at 9:53

There's also the scrlfile package from KOMA-script:

\usepackage{scrlfile}
\AfterPackage{fontspec}{%
    \AtBeginDocument{\DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}}%
}

It has a bunch of other useful commands.

share|improve this answer
1  
Actually I do use scrartcl. So that clears up why I got “\AfterPackage already defined” on \usepackage{afterpackage}. –  canaaerus Jul 24 '12 at 11:58

Put it in \AtBeginDocument after you load fontspec any commands saved by that command are executed in order, so if you do it that way your saved commands will be executed after the packages.

share|improve this answer
1  
Well, that is exactly what I didn't want to do. Actually I'm issuing \DeclareMathSymbol in my document class, which I then \dump with the rest of the preamble to speed up compilation. fontspec can not be dumped, so I put it right before \begin{document}. –  canaaerus Jul 24 '12 at 9:39
2  
ah well an alternative is to patch \document to add your hook stuff just after it runs \@begindocumenthook –  David Carlisle Jul 24 '12 at 9:41

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.