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.

I want to use a custom symbol in my document that is treated like any other letter or math symbol by LaTeX. I do not want to superimpose existing symbols in order to create a new one but rather create one from scratch.

Is there a way to just create the symbol using, say, Inkscape and tell LaTeX to print that when I call a specific macro? There is of course the possibility of using \includegraphics[height=1em], but I imagine that that is not a very effective approach. Can I let LaTeX use my symbol like any other math symbol?

Do I have to create an entire font (consisting of only one character) or is it possible to this in a simpler manner?

share|improve this question
1  
The \includegraphics approach can be made efficient by invoking it once to set the symbol in a saved box, and then the box can be efficiently recalled at need. –  Steven B. Segletes May 5 at 15:30
    
@StevenB.Segletes for pdflatex at least it does that anyway if you load the same image twice –  David Carlisle May 5 at 15:31
    
@DavidCarlisle I did not know that. In that case, there is nothing not "effective" about that approach, other than a \raisebox may be required if the new symbol is a descender. –  Steven B. Segletes May 5 at 15:33
    
@schtreber You could also export some svg from Inkscape using code.google.com/p/inkscape2tikz and then define a macro which you can use like here: tex.stackexchange.com/a/116324 –  LaRiFaRi May 6 at 17:01

1 Answer 1

up vote 5 down vote accepted

This solution demonstrates how an \includegraphics approach could be made to work conveniently.

If the new symbol should conform to the vertical extent of an existing glyph, then this approach will work handily. In the MWE, I make the symbol \schtreber conform to the height of a "b" and then a "g", respectively. It will scale with math style.

If the symbol is a relation or operator, the definition could include a \mathrel or \mathop.

\documentclass{article}
\usepackage{scalerel}
\begin{document}
\def\schtreber{\scalerel*{\includegraphics{schtreber}}{b}}

$ab\schtreber c \scriptscriptstyle ab\schtreber c$

$ y = x^{\schtreber}$

\def\schtreber{\scalerel*{\includegraphics{schtreber}}{g}}

$ab\schtreber c \scriptscriptstyle ab\schtreber c$

$ y = x^{\schtreber}$

\end{document}

enter image description here

If the vertical extent is to be arbitrary, a \rule may be used for the target size, where \LMpt (local-mathstyle pts) or \LMex (local-mathstyle ex's) are used to define the dimensions of the rule. Here I place the image in a \savebox initially, in the event that some flavors of TeX don't save a local copy from \includegraphics.

\documentclass{article}
\usepackage{scalerel}
\newsavebox\schtreberbox
\savebox\schtreberbox{\includegraphics{schtreber}}
\def\schtreber{\scalerel{\usebox{\schtreberbox}}{\rule[-2\LMpt]{0pt}{8\LMpt}}}
\begin{document}
$ab\schtreber c \scriptscriptstyle ab\schtreber c$\par
$ y = x^{\schtreber}$
\end{document}

enter image description here

The advantage of the former, rather than the latter approach is that the method will also work in both text and math mode, as expected:

\documentclass{article}
\usepackage{scalerel}
\newsavebox\schtreberbox
\savebox\schtreberbox{\includegraphics{schtreber}}
\def\schtreber{\scalerel*{\usebox{\schtreberbox}}{b}}
\begin{document}
$ab\schtreber c \scriptscriptstyle ab\schtreber c$\par
$ y = x^{\schtreber}$

In text\schtreber, \LARGE text\schtreber.
\end{document}

enter image description here

share|improve this answer

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.