A small inline graphic

Let's say I have the following text (a part of a paragraph):

hello world


I want to be able to typeset a small star/smiley/whatever graphic in between these two words. This graphic should of course be treated like a regular word, in the sense that we get proper spacing around it, just like for regular words.

The graphic should preferably be written right there in some MetaPost/PSTricks-like code, but I can also accept that I have to include it through an external PDF file.

How can I do this?

Edit: Come to think about it, I guess what I may be asking for is a way to create a new character, without actually having to mess with font-related stuff.

-
\includegraphics can be used anywhere. –  egreg Sep 3 '12 at 12:45
add comment

1 Answer

Simply draw the graphic or include a graphic. Pstricks should work fine, or tikz:

\documentclass{article}
\usepackage{tikz}
\newcommand\smiley{%
\begin{tikzpicture}[scale=0.5]
\fill[fill=yellow,draw=black] (0,0) circle (2ex);
\draw (210:1.3ex) arc (210:330:1.3ex);
\draw (210:1.1ex)--(210:1.5ex);
\draw (330:1.1ex)--(330:1.5ex);
\draw (135:1.1ex) circle (0.2ex);
\draw (45:1.1ex) circle (0.2ex);
\end{tikzpicture}}
\begin{document}

Hello \smiley\  World

\Huge Hello \smiley\ World
\end{document}


Result:

-
Do you know how to use a "pencircle" when drawing the lines? (So the ends are circular, not rectangular.) –  MayGodBlessKnuth Sep 3 '12 at 13:21
See 15.3.1 Graphic Parameters: Line Width, Line Cap, and Line Join of pgfmanual.pdf. –  Ulrike Fischer Sep 3 '12 at 13:31
add comment