4

I would like to use the standard \int and the \gammaup from the txfonts package. How can I mix these symbols?

MWE:

\documentclass{article}
\usepackage{txfonts}
\begin{document}
    Not the int I like, but the gammaup I do like:
    \[\int \gammaup\]
\end{document}
3
  • 1
    Welcome to TeX.SX! Note that the txfonts package is deprecated. You should use newtxtext and newtxmath instead. Dec 2, 2019 at 15:27
  • Thank you @PhelypeOleinik, I did not know that! Upon exchanging txfonts with newtxmath it doesn't change the \int symbol, just as i wanted. That solves my question.
    – josh
    Dec 2, 2019 at 15:33
  • Hm... Actually the symbol does change, but the integral symbol is similar (but not identical) to Computer Modern's... Dec 2, 2019 at 15:36

1 Answer 1

9

Accidental answer :-)

The txfonts package is obsolete, and you usually can replace it by newtxtext (for the text fonts) and newtxmath (for, you guessed, the math fonts). However the \int symbol for newtxmath is rather similar to Computer Modern's, so it might work for you. Here's a comparison between them (left to right: txfonts, Computer Modern, and newtxmath):

enter image description here

\documentclass{article}
\usepackage{newtxtext}% For text font
\usepackage{newtxmath}
% From txfonts
\DeclareSymbolFont{largesymbolstx}{OMX}{txex}{m}{n}
\DeclareMathSymbol{\txintop}{\mathop}{largesymbolstx}{"52}
\DeclareRobustCommand\txint{\txintop\nolimits}
% From Computer Modern
\DeclareSymbolFont{largesymbolscmr}{OMX}{cmex}{m}{n}
\DeclareMathSymbol{\cmrintop}{\mathop}{largesymbolscmr}{"52}
\DeclareRobustCommand\cmrint{\cmrintop\nolimits}
\begin{document}
  \[\txint \cmrint \int \gammaup\]
\end{document}

To find the symbols it takes a bit of digging through the sources (that's how I did it, at least; there might be a better way).

\cmrint

The Computer Modern definition of the symbols can be found in fontmath.ltx (that's where LaTeX math fonts are initialised. You can find that file by running kpsewhich fontmath.ltx in a terminal). Searching for \int in the code you'll see that it's defined as:

    \DeclareRobustCommand\int{\intop\nolimits}

which means that \int is just \intop\nolimits (\nolimits is a TeX primitive), and \intop is defined just above with:

\DeclareMathSymbol{\intop}{\mathop}{largesymbols}{"52}

which means that it is a \mathop (operator) taken from slot number "52 (that's hexadecimal 0x52) from the largesymbols font. Finally, the largesymbols font is declared at the beginning of fontmath.ltx with:

\DeclareSymbolFont{largesymbols}{OMX}{cmex}{m}{n}

which means encoding OMX, family cmex, series m(edium), shape n(ormal).

To make the example above I just renamed largesymbols to largesymbolscmr and \int(op) to \cmrint(op) to avoid conflicts.

\txint

The process is similar, except that instead of looking into fontmath.ltx we'll look at txfonts.sty (use kpsewhich txfonts.sty to find the file). Though txfonts.sty doesn't redefine \int, so the definition of the command is the same as LaTeX's original. What txfonts does redefine is the largesymbols math font:

\DeclareSymbolFont{largesymbols}{OMX}{txex}{m}{n}

so to take the txfonts version of \int we need to declare that font and make a separate copy that uses txex rather than cmex:

\DeclareSymbolFont{largesymbolstx}{OMX}{txex}{m}{n} % declare a TX copy of largesymbols
\DeclareMathSymbol{\txintop}{\mathop}{largesymbolstx}{"52} % declare a TX copy of \intop that uses the above
\DeclareRobustCommand\txint{\txintop\nolimits}

\txiint

This one is similar to the above. In txfonts.sty you'll find that \iint is defined with:

\re@DeclareMathSymbol{\iintop}{\mathop}{largesymbolsA}{33}
   \def\iint{\iintop\nolimits}

which uses largesymbolsA, defined previously with:

\DeclareSymbolFont{largesymbolsA}{U}{txexa}{m}{n}

so you can adapt (to avoid the \re@Declare... command defined in that package):

\DeclareSymbolFont{largesymbolstxA}{U}{txexa}{m}{n}
\DeclareMathSymbol{\txiintop}{\mathop}{largesymbolstxA}{"21} % 33 (decimal) = "21 (hexadecimal)
\DeclareRobustCommand\txiint{\txiintop\nolimits}

Another way you could find a glyph in a font is by using the fonttable package, for example with {U}{txexa}{m}{n}:

\documentclass{article}
\usepackage{fonttable}
\begin{document}
\xfonttable{U}{txexa}{m}{n}
\end{document}

which outputs:

enter image description here

that shows the double integral glyph in slot 33 of that font.

\cmriint

The Computer Modern font doesn't have a double integral glyph, so the approach above won't work. But there are other options:

amsmath emulates (up to) 4 integral signs with \MultiIntegral, which is defined:

\newcommand{\MultiIntegral}[1]{%
  \edef\ints@c{\noexpand\intop
    \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
    \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
    \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi
    \noexpand\intop
    \noexpand\ilimits@
  }%
  \futurelet\@let@token\ints@a
}

and then \iint is defined as:

\ams@newcommand{\iint}{\DOTSI\protect\MultiIntegral{2}}

However this will use the default \intop glyph. To change the font you can create a copy of (or even redefine) \MultiIntegral which uses (say) the \cmrintop defined above.

You can also use the esint package, which defines several types of integral signs using (a clone of) the Computer Modern glyph. To use the Computer Modern integral sign with other font packages you just have to make sure you load esint after all font packages (and after amsmath).

11
  • 1
    You should load newtxtext first and newtxmath second. Try to type a formula containing numbers with your present setup and you'll see why :-)
    – campa
    Dec 3, 2019 at 8:21
  • @campa Thanks! I didn't knew about this explicit order (though in my head was newtxtext always first, so I've never seen the problem before; not sure why I changed this time :-). Dec 3, 2019 at 12:47
  • alright, so now i wanted to use \iint, but i don't understand what you did with the Declare* lines, where can i look up the "number" of the \iint?
    – josh
    Apr 29, 2020 at 13:45
  • @josh I added an explanation how I found the glyphs in the fonts and added the declaration of \iint in txfonts, plus some tips for looking up glyphs in fonts. I hope it's understandable. Apr 29, 2020 at 23:31
  • @PhelypeOleinik yes, thank you very much, this shows what little i actually know of what latex does to work in the background
    – josh
    Apr 30, 2020 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .