Skip to content

Comment on Essential LaTeX packages

Comments

I would recommend everyone look at xspace.

It only has one tiny aim - to deal with spaces after commands.

Given: \newcommand{\S}{Bob} then \S is \S. expands to:

    Bobis Bob.
While: Given: \newcommand{\S}{Bob } expands to
    Bob is Bob .
One can write: \newcommand{\prog}{\textsc{prog}\xspace}. Then we get:
    Bob is Bob.

Is there anything wrong with the simple approach of just adding \<space> after the command? For example: \newcommand{\T}{Mike} \T\ is \T. Which will give you: Mike is Mike.

The problem with hard coding the space is there are times it is not wanted/needed. I am stealing the following from xpsace documentation.

Input with "\newcommand{\gb}{Great Britain\xspace}":

  \gb is a very nice place to live.\\
  \gb, a small island off the coast of France.\\
  \gb\footnote{The small island off the coast of France.} 
  is a very nice place to live.
Results in the output
  Great Britain is a very nice place to live.
  Great Britain, a small island o the coast of France.
  Great Britain[^1] is a very nice place to live.

There is nothing wrong, except I feel I shouldn't have to remember to make sure I do a \<space> after commands instead of just a space. Why should I have to remember where to put <space> and where to put \<space>, that's what computers are for!

I've been having this problem for months now and I never figured out a way around it. Thank you so much for this!

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.