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.

Suppose I need some crazy custom symbol for personal use.

e.g. when I write \foobar, LaTeX should show

.

How do I achieve this?

Update: I was writing Klingon writing system for fun. Thank you very much you all. Looks like this now enter image description here

share|improve this question
1  
Metafont fonts for Klingon can be found on CTAN: ctan.org/search/?search=klingon&search_type=description. :) –  Caramdir May 26 '11 at 0:45

3 Answers 3

up vote 16 down vote accepted

Simplest way would be to save it as a pdf (or eps if you're using latex) and then define

\newcommand*\foobar{\includegraphics{crazycustomsymbol}}
share|improve this answer
    
save what as a pdf? –  Pratik Deoghare Mar 16 '11 at 9:36
    
@MachineCharmer: Your "crazy custom symbol." –  TH. Mar 16 '11 at 9:38
    
Will it work if I use crazycustomsymbol.png instead of crazycustomsymbol.pdf? –  Pratik Deoghare Mar 16 '11 at 10:01
    
@MachineCharmer: Sure! –  TH. Mar 16 '11 at 10:05
    
Thank you very much! :) –  Pratik Deoghare Mar 16 '11 at 10:06

As TH mentioned, you can create a graphic in an external program and include it as a picture. Preferably you would use a vector drawing software such as adobe illustrator or the (free) software inkscape. This way scaling the image will not change the quality (don't use raster graphics such as jpg).

Of course you can also use a code based approach e.g. with the tikz or pstricks package

\documentclass{scrartcl}

\usepackage{tikz}

\newcommand{\foo}[1]{%
\begin{tikzpicture}[#1]%
\draw (0,0) -- (1ex,1ex);%
\draw (0.5ex,0) -- (1.3ex,0.8ex);%
\end{tikzpicture}%
}
\begin{document}
Some text and the symbol \foo{} or scaled \foo{scale=2}
\end{document}

enter image description here

share|improve this answer
    
I'm glad you mentioned this. I was going to, but as I don't actually know TikZ or pstricks, I figured I'd let someone else. –  TH. Mar 16 '11 at 10:05
    
I do exactly this! I have customised \Implies and \Iff to make them a bit larger and longer for presentations. –  Loop Space Mar 16 '11 at 10:31
1  
I gues that tikz will re-compute the symbol each time you use it. Is it possible to "evaluate" the tikzpicture once and then reuse it? –  Bruno Le Floch Mar 16 '11 at 11:11
    
Yes it will. You can of course create a pdf picture from your tikz drawing and include it. Also tikz has a externalize library that will evaluate the picture once, creates a pdf from it and inlcudes the pdf-picture in future compiling processes. I guess this would be a bit much for a symbol, so if you like tikz, create the symbol in an extra document and use pdfcrop to trim the resulting pdf. –  Martin H Mar 16 '11 at 11:19
    
@Bruno, Martin H: You could use a \savebox to store the rendered picture and reuse it. This way it is only drawn once. –  Martin Scharrer Mar 16 '11 at 13:14

Yet another way of including custom symbols is by composing new ones through superimposing glyphs, which is demonstrated in the symbols-a4 manual on page 103.

Here's an example:

\newcommand{\starcup}{$\sqcup$\kern-0.58em{$\star$}}

Which gives:

starcup is an all new glyph

As Martin Scharrer points out, the use of ex or em as a unit for kerning respects the font size. You can also use (as I did in the first revision of this example) points for absolute positioning.

share|improve this answer
3  
You could use ex or em as unit for the \kern to get font size relative kerning. Also \rlap could be used to simply lap the second symbol over the first. –  Martin Scharrer Mar 16 '11 at 10:51
    
@Martin Scharrer: Thanks, I have updated my answer to use proportional units. I attempted to use \rlap but for some reason the glyphs were set on different lines. Moreover, the glyphs were (predictably) left-aligned and thus the star was off-centre and in need of kern. As such I am not sure that \rlap constitutes a better method. –  Richard Terrett Mar 16 '11 at 11:04
    
Yes, \rlap alone only works well when the symbols have approximately the same width. See this answer of mine where I use a box to center one symbol on top of another one. –  Martin Scharrer Mar 16 '11 at 11:10
    
@Martin Scharrer: would using muskips be better/worse? –  Bruno Le Floch Mar 16 '11 at 11:13
1  
@Bruno: in general, using relative units in the same mode or direction is always a good idea. so, in math, mu, in horizontal text mode, em, and in vertical text mode, ex. then they will scale properly when you change the base size. –  barbara beeton Mar 16 '11 at 12:53

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.