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?

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.

  • 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: tex.stackexchange.com/questions/8260/…? – 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]{...}}%
  • Don't you need a \fontdimen for those heights? – Ryan Reich Jun 18 '12 at 19:18
  • @RyanReich yes, will fix, thanks:-) – David Carlisle Jun 18 '12 at 19:30
  • I hope amstext does the trick, but if not I'll have \mathchoice on reserve. Thanks very much! – user15340 Jun 19 '12 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.