4

I've inserted a "cross" (\ding{55}) from package pifont in a text but I can't insert a space after it, Latex ignores the space from the source code. Does anyone have a suggestion?

Edit:

There was some missing information. I'm using \newcommand. Here is a * not * working example ;)

\documentclass{article}
\usepackage{pifont}
\newcommand{\cross}{\ding{55}}
\begin{document}
\cross a

\cross. a

\cross . a
\end{document}
2

2 Answers 2

5

EDIT

In relation to your edit use xspace

\documentclass{article}
\usepackage{pifont,xspace}
\newcommand{\cross}{\ding{55}\xspace}
\begin{document}
\cross a

\cross. a

\cross . a
\end{document}

Why don't you get any space?

This works well:

\documentclass{article}
\usepackage{pifont}
\begin{document}
\ding{55} a

\ding{55}. a

\ding{55} . a
\end{document}

enter image description here

4
  • You're right. The space should be there! I'll delete my answer while the OP answers your question. Commented Sep 22, 2011 at 18:58
  • @GonzaloMedina: xspace was also my first try (see my revision) ;-) Commented Sep 22, 2011 at 18:58
  • Unfortunately there was some important missing information. Please, see the edit.
    – freitass
    Commented Sep 22, 2011 at 20:18
  • Great! Worked with \xspace. Thanks!
    – freitass
    Commented Sep 22, 2011 at 20:29
7

The "problem" that you encountered with the space has nothing to do with pifont or any other package. In general, with any command, you have to tell TeX/LaTeX where the command has ended. If you have a character that cannot be part of a command (like the brackets, the numbers etc, unless you change their default \catcode), occurence of such a character would automatically tell TeX/LaTeX that the command has ended before this character. This happens in the example

\cross.A

But if you write

\cross A

then TeX/LaTeX does not know that the command has ended after you wrote "\cross". It goes forward, and sees a blank space, and then it knows that the command has ended. After that, there is no space, so it does not separate the cross and the letter A. If you write

{\cross} A

you will obtain a space. Or if you write

\cross{} A

that will also do. There is no need to use packages for such simple things.

You must log in to answer this question.

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