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.

Is there a general way to change the font of a particular symbol without switching packages?

For example, suppose I'm using Computer Modern for my entire document, but I want the "subset" operator to look as it does in mathabx. How can I redefine it to appear in this way?

share|improve this question
1  
Possible Duplicate: The standard \cup vs. the mathabx \cup –  Leo Liu Mar 28 '11 at 4:34
add comment

2 Answers

up vote 33 down vote accepted

There's sort of a general way, but it involves knowing your way around the various bits of the other font packages. You can then take just the bits you need. So for your particular example, you could do the following:

\documentclass{article}
% Setup the matha font (from mathabx.sty)
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
      <5> <6> <7> <8> <9> <10> gen * matha
      <10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
      }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}

% Define a subset character from that font (from mathabx.dcl)
% to completely replace the \subset character, you can replace
% \varsubset with \subset

\DeclareMathSymbol{\varsubset}{3}{matha}{"80}
\begin{document}

Computer Modern subset
\[
A \subset B
\]

\texttt{mathabx} subset

\[
A \varsubset B
\]

\end{document}

This code is copied from the mathabx package.

sample

share|improve this answer
    
This is exactly what I'm looking for; I can infer the general way from here, since there is a pretty good guide: latex-project.org/guides/fntguide.pdf. Just a couple of questions: where can I find the "loading-settings" for mathabx, i.e., where did you get \hyphenchar\font45 (in the \DeclareFontFamily command) from? How about the loading-settings used in the \DeclareFontShape command? Thanks a lot. –  Nick Strehlke Mar 28 '11 at 1:45
    
I mention this in the commented code: the first part is from mathabx.sty and the second from mathabx.dcl. These files are located in TeXLive in /usr/local/texlive/2010/texmf-dist/tex/generic/mathabx/. (I assume somewhere similar in MikTeX.) –  Alan Munn Mar 28 '11 at 2:00
    
Thanks, this is absolutely perfect. –  Nick Strehlke Mar 28 '11 at 2:15
    
I borrowed your code at tex.stackexchange.com/questions/113437/stealth-arrow-in-math/… for different symbols from mathabx. While my adaptation seems to work, please let me know if I screwed it up somehow. –  Steven B. Segletes May 9 '13 at 19:42
add comment

There's another way to cope with a single symbol without wasting a precious math alphabet resource (there are only 16 of them).

\usepackage{pifont}
\makeatletter
\newcommand\Pimathsymbol[3][\mathord]{%
  #1{\@Pimathsymbol{#2}{#3}}}
\def\@Pimathsymbol#1#2{\mathchoice
  {\@Pim@thsymbol{#1}{#2}\tf@size}
  {\@Pim@thsymbol{#1}{#2}\tf@size}
  {\@Pim@thsymbol{#1}{#2}\sf@size}
  {\@Pim@thsymbol{#1}{#2}\ssf@size}}
\def\@Pim@thsymbol#1#2#3{%
  \mbox{\fontsize{#3}{#3}\Pisymbol{#1}{#2}}}
\makeatother

After these one can choose a particular symbol and give it a sensible name, for example

\newcommand{\varsubset}{\Pimathsymbol[\mathrel]{matha}{"80}}

The optional argument gives the type of the symbol, in this case a binary operation symbol; the first mandatory argument is the name of the font family and the second one the number of the symbol's slot in the font.

Unfortunately, mathabx doesn't provide .fd files, so one has also to declare the family as explained in Alan's answer, but, since now the mathabx are also in Type1 format, one may scale them:

\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
  <-6> matha5 <6-7> matha6 <7-8> matha7
  <8-9> matha8 <9-10> matha9
  <10-12> matha10 <12-> matha12
  }{}

Any symbol in any font may be used in math and it will scale properly in subscripts and superscripts.

share|improve this answer
    
How about accents? Could this be adapted to use the wide bar accent from mathx without "wasting" a math alphabet as in this answer: tex.stackexchange.com/questions/16337/… –  kahen May 3 '12 at 8:58
1  
@kahen I'm afraid it's not possible, as the growing accents are used only in math fonts. –  egreg May 3 '12 at 9:02
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.