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.

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.

share|improve this question
4  
\includegraphics can be used anywhere. –  egreg Sep 3 '12 at 12:45
add comment

1 Answer 1

up vote 7 down vote accepted

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:

result

share|improve this answer
    
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
1  
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

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.