4

I'm thinking about building a new symbol library and I need to test out the command set. I slapped together a quick set of math symbols using a set of commands

\newcommand{\example}{\includegraphics[height=\height]{example.jpg}}

and a scanner. It works fine for a kludge, but the problem is that I would like the \height argument to be set equal to the value 1em in the current display style (i.e., smaller for subscripts and superscripts, etc.) I can't find any information and don't know if there's a way to do this (it's not exactly what the graphicx package was designed for). Any suggestons?

Werner
  • 603,163

2 Answers2

2

The height you are looking for is \fontdimen6\textfont2: the length of a \quad (1em by definition) in the text style of the current symbol font (family 2). Of course, if you are in scriptstyle or scripscriptstyle you want \scriptfont or \scriptscriptfont, and you can use a different family (up to 15; I am not sure what their significance is but if you are designing a font perhaps you are).

I should mention that if you use this before the first time a math $ $ pair is used, the symbol font won't be loaded and you will get a mysterious error about \nullfont.

Ryan Reich
  • 37,958
  • Is there a different flavor of your answer for vertical heights, i.e., the height of an x in the current mathstyle, rather than a horizontal measure like em? Or will they always be defined as proportional, as would seem to be indicated by this answer: http://tex.stackexchange.com/questions/8260/what-are-the-various-units-ex-em-in-pt-bp-dd-pc-expressed-in-mm/113513#113513? – Steven B. Segletes Sep 25 '13 at 14:57
2

You need to use the \mathchoice prinitive to set in each of the math sizes:

\def\something{\mathchoice
  {\includegraphics[height=\fontdimen6\textfont2]{...}}%
  {\includegraphics[height=\fontdimen6\textfont2]{...}}%
  {\includegraphics[height=\fontdimen6\scriptfont2]{...}}%
  {\includegraphics[height=\fontdimen6\scriptscriptfont2]{...}}%
}

(using graphicx package for the graphics inclusion)

or more simply let the AMS take care of you , use amstext package and then:

 \def\something{\text{\includegraphics[height=1em]{...}}%
David Carlisle
  • 757,742