4

I would like to import the equilateral triangle symbols \medtriangleup, \medtriangleright, \medtriangleleft, \medtriangledown from the fdsymbol package, without it screwing up \nabla and changing it into a big black dot.

I've found similar answers about importing symbols from this package but I'm having trouble parsing the information to work out how to adapt it for my needs.

Can anyone point me towards any relevant documentation or help me understand what the steps involved are for my particular task?

Or, a workaround, does anyone know a package with nice-looking triangles like those found in fdsymbol, that I can import without messing up \nabla??

2
  • The unicode-math, stix and stix2 packages are especially comprehensive.
    – Davislor
    Commented Dec 10, 2020 at 0:02
  • Do you mean fdsymbol?
    – Davislor
    Commented Dec 10, 2020 at 0:26

3 Answers 3

5

The file fdsymbol.sty defines all symbols sequentially and one has to count lines or exploit some other trick: fonttable is our friend.

First of all, look for \medtriangleright, to find

\fdsy@DeclareSymbol{\medtriangleright}{symbols}{\mathbin}
  \fdsy@DeclareAlias{\triangleright}{symbols}{\mathbin}
\fdsy@DeclareSymbol{\medtriangleup}{symbols}{\mathbin}
  \fdsy@DeclareAlias{\triangle}{symbols}{\mathbin}
  \fdsy@DeclareAlias{\vartriangle}{symbols}{\mathbin}
\fdsy@DeclareSymbol{\medtriangleleft}{symbols}{\mathbin}
  \fdsy@DeclareAlias{\triangleleft}{symbols}{\mathbin}
\fdsy@DeclareSymbol{\medtriangledown}{symbols}{\mathbin}
  \fdsy@DeclareAlias{\triangledown}{symbols}{\mathbin}

so we know that we need the symbols math font:

\DeclareSymbolFont{symbols}{U}{FdSymbolA}{m}{n}

OK, look for FdSymbolA

\DeclareFontFamily{U}{FdSymbolA}{}
\DeclareFontShape{U}{FdSymbolA}{m}{n}{
    <-7.1> s * [\fdsy@scale] FdSymbolA-\fdsy@mweight@small
    <7.1-> s * [\fdsy@scale] FdSymbolA-\fdsy@mweight@normal
}{}

Now it's apparent that \fdsy@scale is a scale factor; use 1 to begin the study; what are the other commands? They depend on options given to the package:

\fdsy@choicekey{normalweight}{book,regular,auto}{%
  \ifcase\@tempb\relax
    \renewcommand\fdsy@mweight@normal{Book}%
    \renewcommand\fdsy@mweight@small{Book}%
  \or
    \renewcommand\fdsy@mweight@normal{Regular}%
    \renewcommand\fdsy@mweight@small{Regular}%
  \or
    \renewcommand\fdsy@mweight@normal{Book}%
    \renewcommand\fdsy@mweight@small{Regular}%
  \fi
}

I'd go with the book choice. So we can start:

\DeclareFontFamily{U}{FdSymbolA}{}
\DeclareFontShape{U}{FdSymbolA}{m}{n}{
    <-7.1> s * [1] FdSymbolA-Book
    <7.1-> s * [1] FdSymbolA-Book
}{}
\DeclareSymbolFont{fdsymbols}{U}{FdSymbolA}{m}{n}

One must use a different name than symbols.

Oh, well, there's no point in separating the fonts, so we can do

\DeclareFontFamily{U}{FdSymbolA}{}
\DeclareFontShape{U}{FdSymbolA}{m}{n}{
    <-> s * [1] FdSymbolA-Book
}{}
\DeclareSymbolFont{fdsymbols}{U}{FdSymbolA}{m}{n}

Now we need to define the symbols and we need to find the slots. It's not really difficult: make a simple file

\documentclass{article}
\usepackage{fonttable}

\DeclareFontFamily{U}{FdSymbolA}{}
\DeclareFontShape{U}{FdSymbolA}{m}{n}{
    <-> s * [1] FdSymbolA-Book
}{}

\begin{document}

\xfonttable{U}{FdSymbolA}{m}{n}

\end{document}

and run LaTeX on it. You'll find the symbols laid out with codes!

enter image description here

Now we can finish up.

\documentclass{article}

%%% define symbols from fdsymbol
\DeclareFontFamily{U}{FdSymbolA}{}
\DeclareFontShape{U}{FdSymbolA}{m}{n}{
    <-> s * [1] FdSymbolA-Book
}{}
\DeclareFontShape{U}{FdSymbolA}{m}{b}{
    <-> s * [1] FdSymbolA-Medium
}{}
\DeclareSymbolFont{fdsymbols}{U}{FdSymbolA}{m}{n}
\SetSymbolFont{fdsymbols}{bold}{U}{FdSymbolA}{m}{b}

\DeclareMathSymbol{\medtriangleright}{\mathbin}{fdsymbols}{86}
\DeclareMathSymbol{\medtriangleup}{\mathbin}{fdsymbols}{87}
\DeclareMathSymbol{\medtriangleleft}{\mathbin}{fdsymbols}{88}
\DeclareMathSymbol{\medtriangledown}{\mathbin}{fdsymbols}{89}
%%%

\begin{document}

$a\medtriangleright b\medtriangleup c\medtriangleleft d \medtriangledown e$

\boldmath

$a\medtriangleright b\medtriangleup c\medtriangleleft d \medtriangledown e$

\end{document}

Test with different scale factors until you're satisfied. I added support for bold math.

enter image description here

Just for completeness, here's the output with [1] changed into [0.8] to get reduced size for the symbols:

\DeclareFontShape{U}{FdSymbolA}{m}{n}{
    <-> s * [0.8] FdSymbolA-Book
}{}
\DeclareFontShape{U}{FdSymbolA}{m}{b}{
    <-> s * [0.8] FdSymbolA-Medium
}{}

(no other change).

enter image description here

1
  • Very helpful! Thank you!
    – seldon
    Commented Sep 24, 2021 at 21:24
3

The unicode-math, stix and stix2 packages have all of these, but the official names are not very consistent. A MWE:

\documentclass{article}
\usepackage{unicode-math}

\setmathfont{Latin Modern Math}
\setmathfont{STIX Two Math}[
  range ={ \bigtriangleup, \bigtriangledown, \triangleleft, \triangleright,
           \vartriangle, \triangledown, \smalltriangleleft, \smalltriangleright },
  Scale = MatchUppercase ]

\begin{document}
Triangles: \( \bigtriangleup \bigtriangledown \triangleleft \triangleright
              \vartriangle \triangledown \smalltriangleleft \smalltriangleright
              \nabla \increment \Delta \)
\end{document}

STIX Two Math sample

The command to import these symbols from fdsymbol (which I did here with their standard names and math classes) is more complex. The package is not set up to make it easy to copy and paste only a piece of it.

\documentclass{article}

\DeclareFontFamily{U}{FdSymbolA}{}

\DeclareFontShape{U}{FdSymbolA}{m}{n}{
  <-7.1> s * [1.0] FdSymbolA-Book
  <7.1-> s * [1.0] FdSymbolA-Book
}{}

\DeclareFontShape{U}{FdSymbolA}{b}{n}{
  <-7.1> s * [1.0] FdSymbolA-Bold
  <7.1-> s * [1.0] FdSymbolA-Bold
}{}

\DeclareSymbolFont{fdsymbols}{U}{FdSymbolA}{m}{n}
\SetSymbolFont{fdsymbols}{bold}{U}{FdSymbolA}{b}{n}

\DeclareMathSymbol{\vartriangle}{\mathbin}{fdsymbols}{87}
\DeclareMathSymbol{\triangledown}{\mathord}{fdsymbols}{89}
\DeclareMathSymbol{\smalltriangleleft}{\mathbin}{fdsymbols}{88}
\DeclareMathSymbol{\smalltriangleright}{\mathbin}{fdsymbols}{86}

\begin{document}

Triangles: \( \vartriangle \triangledown \smalltriangleleft \smalltriangleright
              \nabla \Delta \)

\end{document}

fdsymbol sample

You can, if you prefer, change the lines like

<-7.1> s * [1.0] FdSymbolA-Book

to change the scale parameter [1.0] or set the m weight to FdSymbolA-Regular and the b weight to FdSymbolA-Medium, and get the same effect as the package options to fdsymbol.

2
  • The first method seems the most straightforward but a warning for future readers: unicode-math doesn't play well with pdfLaTeX.
    – jms547
    Commented Dec 17, 2020 at 20:56
  • @jms547 I’ve added a sentence about that, in case anyone here doesn’t already know.
    – Davislor
    Commented Dec 17, 2020 at 21:17
2

Everything is in the documentation of fdsymbol, but indeed if you have never read the source files of a font package you might have a hard time trying to understand what's going on.

Here's an example to load only the commands you want from fdsymbol. I simply took the relevant definitions from the source files. The output is the four triangle symbols, and a \nabla to verify it has not changed.

\documentclass{article}
\DeclareFontFamily{U}{FdSymbolA}{}
\DeclareFontShape{U}{FdSymbolA}{m}{n}{
    <-7.1> FdSymbolA-Book
    <7.1-> FdSymbolA-Book
}{}
\DeclareSymbolFont{FdSymbols}{U}{FdSymbolA}{m}{n}
\makeatletter
\newcommand\fdsy@nextslot{\advance\@tempcnta 1\relax}
\newcommand\fdsy@@DeclareSymbol[4]{\DeclareMathSymbol{#2}{#3}{#4}{#1}}
\newcommand\fdsy@DeclareSymbol[3]{%
    \if\relax\noexpand#1\let#1\undefined\fi
    \expandafter\fdsy@@DeclareSymbol\expandafter{\the\@tempcnta}{#1}{#3}{#2}%
    \fdsy@nextslot
}
\@tempcnta 86
\fdsy@DeclareSymbol{\medtriangleright}{FdSymbols}{\mathbin}
\fdsy@DeclareSymbol{\medtriangleup}{FdSymbols}{\mathbin}
\fdsy@DeclareSymbol{\medtriangleleft}{FdSymbols}{\mathbin}
\fdsy@DeclareSymbol{\medtriangledown}{FdSymbols}{\mathbin}
\makeatother
\begin{document}
\(\medtriangleright\medtriangleup\medtriangleleft\medtriangledown\nabla\)
\end{document}

You must log in to answer this question.

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