2

What I want to do: I want to take two basic LaTeX mathmode characters, take their vector picture file, and edit them together to form a new symbol, which I want to behave as any other mathmode symbol would. Then I want to make a fully functional package out of this.

What I do not ask: I am not asking how to search up if this symbol is already made by someone else (I know it isn't). I also don't want to make it by printing both characters on top of one another using \newcommand and then messing with spacing (that doesn't provide satisfactory results), and I am sure that recreating it using tikz will be very difficult (due to the complexity and letter-like style of the characters involved). These are some answers I have found on here when stuff like this was asked, and I am sure that this is not what I need to do.

My question is: Where (what directory) do I find the vector pictures of a simple mathmode character so I can edit them for my own purposes, and where do I find the package code to make my character behave exactly like any other mathmode symbol. I ask both questions together because I assume they are in similar places.


I'm trying to figure out how things work, so if you show non-trivial code, please explain what it does.

7
  • 2
    They are stored in fonts. Are you planning to make a new one?
    – egreg
    Commented Nov 29, 2018 at 16:49
  • Only if necessary. what I want to do is make a package including one symbol that is slightly tweaked but looks and behaves similarly to the \tau and \pi. I hoped this would not be difficult task. Commented Nov 29, 2018 at 16:53
  • No, it's not an easy task. Are you thinking to a three legged pi?
    – egreg
    Commented Nov 29, 2018 at 16:55
  • yup, and I have a working version using \includegraphics and a png image, but it is not ideal. I also have to use two versions: one full size and one a little smaller for use as an exponent, so hence my need for the code. A vectroised image is make-able, but I want to work from the original characters instead of screenshotting them into an editing software. Commented Nov 29, 2018 at 16:58
  • @NielsKorpel: You can change your existing \includegraphics approach to condition on the math style, thereby automating the sizing choice. For that, there's \mathchoice and \mathpalette.
    – Werner
    Commented Nov 29, 2018 at 17:05

1 Answer 1

2

The primary struggle here seems to be that you want a symbol that works with all math styles without having to adjust the spacing and size every time you use it. The solution here is to define the symbol use either \mathchoice or \mathpalette. For details on that, see

Let's assume you have some super intricate symbol

enter image description here

You may have started with a hand-drawing and traced it. Regardless, the above is a vectorized version of the symbol in the form of an image. I'll just call it a symbol.

Define your symbol via \mathchoice in the following way:

\newcommand{\mysymbol}{%
  \mathchoice
    {\includegraphics[height=1em]{super_intricate_symbol}}
    {\includegraphics[height=1ex]{super_intricate_symbol}}
    {\includegraphics[height=.7ex]{super_intricate_symbol}}
    {\includegraphics[height=.5ex]{super_intricate_symbol}}
}

This allows you to tailor the symbol's display size (and related spacing/alignment) based on the math style, even though you're only using a single image. Here's an example of a use-case:

enter image description here

\documentclass{article}

\usepackage{graphicx}

\newcommand{\mysymbol}{%
  \mathchoice
    {\includegraphics[height=1em]{super_intricate_symbol}} % \displaystyle
    {\includegraphics[height=1ex]{super_intricate_symbol}} % \textstyle
    {\includegraphics[height=.7ex]{super_intricate_symbol}}% \scriptstyle
    {\includegraphics[height=.5ex]{super_intricate_symbol}}% \scriptscriptstyle
}

\begin{document}

\[
  x\ {\textstyle x}^{x^x} \quad
  x\mysymbol\ {\textstyle x\mysymbol}^{x\mysymbol^{x\mysymbol}} \quad
  x\mysymbol\ {\textstyle x\mysymbol}_{x\mysymbol_{x\mysymbol}} \quad
  x\ {\textstyle x}_{x_x}
\]

\end{document}

What you lose using this approach is the font weight that typically is adjusted for smaller versions. Notice how the stem of the x remains fairly thick even though its written in \scriptscriptstyle. Here's a direct comparison using x as your symbol:

enter image description here

\newcommand{\mysymbol}{%
  \mathchoice
    {\resizebox{!}{1ex}{$\textstyle x$}} % \displaystyle
    {\resizebox{!}{1ex}{$\textstyle x$}} % \textstyle
    {\resizebox{!}{.7ex}{$\textstyle x$}}% \scriptstyle
    {\resizebox{!}{.5ex}{$\textstyle x$}}% \scriptscriptstyle
}

The different font weights are noticeable within \scriptscriptstyle (the superscript of the superscript). To that end, you could define different weight versions of your symbol and use them in the respective components (\...style) in \mathchoice. However, depending on the use-case and/or symbol construction, this might not be an issue.

You would follow a similar approach to the above even if you defined your symbol using an overlay of multiple symbols; that is, define appropriate spacing/layout that might depend on the math style you're in.


The fonts should be stored in your TeX Directory Structure (TDS) under a folder called fonts. If you want to know which fonts are used, then you can add \showoutput to a small document and use a symbol and look at the .log. For example, the following minimal example

\documentclass{article}

\begin{document}

\showoutput
$\alpha$

\end{document}

reveals (I've added highlights for the elements on the page; \alpha and the page number):

Completed box being shipped out [1]
\vbox(633.0+0.0)x407.0
.\glue 16.0
.\vbox(617.0+0.0)x345.0, shifted 62.0
..\vbox(12.0+0.0)x345.0, glue set 12.0fil
...\glue 0.0 plus 1.0fil
...\hbox(0.0+0.0)x345.0
..\glue 25.0
..\glue(\lineskip) 0.0
..\vbox(550.0+0.0)x345.0, glue set 539.94232fil
...\write-{}
...\glue(\topskip) 5.69446
...\hbox(4.30554+0.0)x345.0, glue set 323.56596fil
....\hbox(0.0+0.0)x15.0
....\mathon
....\OML/cmm/m/it/10  % <------------------------------- \alpha
....\kern0.03702
....\mathoff
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue 0.0 plus 1.0fil
...\glue 0.0
...\glue 0.0 plus 0.0001fil
..\glue(\baselineskip) 23.55556
..\hbox(6.44444+0.0)x345.0, glue set 170.0fil
...\glue 0.0 plus 1.0fil
...\OT1/cmr/m/n/10 1 % <--------------------------------- page number (1)
...\glue 0.0 plus 1.0fil

You'll see that \alpha uses cmm - Computer Modern Math with a italics shape in 10 point. You can then print the entire font table for cmmi10 via \fonttable:

enter image description here

\documentclass{article}

\usepackage{fonttable}

\begin{document}

\fonttable{cmmi10}

\end{document}

\show\alpha also identifies the position as \mathchar"10B.

You also lose possible kerning corrections which are specific to the font. However, all of these losses might be nothing compared to the convenience from managing content the way you want.

Related: Is there a simple way to print out all the available characters in a LaTeX font set?

You must log in to answer this question.

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