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.

The following code produces wrong output:

\documentclass{article}
\usepackage{amsmath, esint, kpfonts}

\begin{document}
\[\int_a^b f(x) dx \]
\end{document}

If I change the loading order of the packages everything works:

\usepackage{kpfonts,esint}

Why is this happening? It seems such a simple case.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

It is a simple case (or it seems to be, see later on). The esint package overrides integral signs; but also kpfonts changes the default math fonts; so you want to override kpfonts, not the default math fonts and the order must be

\usepackage{kpfonts}
\usepackage{esint}

The sad truth is that the two packages are incompatible, as they both define a math symbol font with the same name (which explains the bizarre symbol you get when using the wrong loading order): they both use the same identifier largesymbolsA.

Here's what happens.

  1. If you load first esint and then kpfonts, the math symbol font declared by kpfonts overrides the one declared by esint with the same name. This font has different symbols than esint's; since kpfonts doesn't redefine \intop (the command responsible for printing the integral sign), LaTeX will choose the corresponding slot in the font declared by kpfonts, which happen to have that strange symbol in it.

  2. If you load first kpfonts and then esint, the largesymbolsA font defined by kpfonts will be overridden, so commands that rely on it will print random symbols.

In both cases you lose something.

Here's a workaround, but really esint should change the identifier for its symbol font. Maybe also kpfonts should, avoiding too generic names.

\documentclass{article}
\usepackage{amsmath}
\usepackage{kpfonts}

\makeatletter
\let\ORG@DeclareSymbolFont\DeclareSymbolFont
\def\DeclareSymbolFont#1#2#3#4#5{%
  \ORG@DeclareSymbolFont{largesymbolsesint}{#2}{#3}{#4}{#5}
  \def\re@DeclareMathSymbol##1##2##3##4{%
    \let##1=\undefined
    \DeclareMathSymbol{##1}{##2}{largesymbolsesint}{##4}}%
}
\makeatother

\usepackage{esint}

\makeatletter
\let\DeclareSymbolFont\ORG@DeclareSymbolFont
\makeatother


\begin{document}
\[\int_a^b f(x) dx \]
\end{document}
share|improve this answer
    
I really feel that some day CTAN/TUG/TeX.SX/etc. should organize a big treasure hunt for package conflicts, make a database of them and then start fixing them one at a time... I might even start learning TeX programming if there was a big "everybody fix TeX" initiative. –  marczellm Jun 8 '13 at 19:23
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.