1

I am creating a document about a project whose name is "Go for it!" with an exclamation point. I am fairly new to Latex, but I figured that there should be a command to print the project name, with the exclamation mark and everything. So I did:

\newcommand{\goforit}{Go for it!}

The problem is the exclamation mark, since Latex prints a space after it, and in case I want to say "Go for it!, due to its awesomeness[...]", it will print a space before the comma, which is undesirable.

From what I've read, I can append "\ " to it, but that will indeed still print a space before the comma.

  • latex does not add space after ! (and xspace does not remove space) If you are getting a space you must have a space in the source. – David Carlisle Aug 31 '13 at 19:21
1

You could use the \xspace macro of the eponymous package. Consider the following MWE (minimum working example):

\documentclass{article}
\usepackage{xspace}
\newcommand{\gfi}{Go for it!\xspace}
\begin{document}
\gfi Yes, \gfi, right now.
\end{document}

enter image description here

Of course, nothing's ever perfect, and that applies to \xspace as well. To read up on some of its potential shortcomings (which I generally find too dreadful), you may want to read the posting Drawbacks of xspace.

  • Xspace should not be relevant here, the OP said latex was printing space... (despite the fact that it's accepted answer:-) – David Carlisle Aug 31 '13 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.