tags:

views:

170

answers:

4

In this article the author discusses the use of \@ to put correct spacings after full stops that are not at the end of a sentence e.g. Mr. i.e. etc.

The macro suggested

\newcommand\etc{etc\@ifnextchar.{}{.\@}}

is not quite perfect since in the case (\etc more text) it produces (etc.more text).

I have seen a lot of authors who have made their own versions of the \etc macro, mostly variations on etc.\.

What macros for \etc, \ie, \etal, \eg produce the nicest results in the most situations?

Is this something too personal in taste to be solved in general?

A: 

All LaTeX commands eliminate space after them. If you want a space, you need to escape it:

\etc\ and more

This is necessary, because you need to be clear where the command name ends. \etcno space cannot be correctly interpreted.

Svante
But you can lookahead to see if the next character is catcode 10, to see if there should have been a space: see my answer.
Charles Stewart
Yes, you can. I'm just stating how it works.
Svante
Sorry to keep nitpicking: it's actually not true that all commands eliminate space: only those composed of letters (i.e., catcode 10 characters do). Other commands defined in the normal way (i.e., not using `\csname`) are one character long control sequences and don't gobble space. This is exactly why it's a good idea to look at the next character's catcode.
Charles Stewart
I found a package `xspace` that can check to see if you need the space. Will you take a look at my answer, and see if there are any counter examples? Thanks.
Geoff
+5  A: 

Earlier I used macros for "et al.", etc., but nowadays I would discourage people from defining that kind of macros.

One problem is what you already observed: it's surprisingly tricky to get the definitions right so that they handle all special cases correctly (including the interactions with other packages – e.g., those that re-define the "\cite" command and tweak spacing before references).

But more importantly, even if you have a bunch of macros that suit your needs and you know how to use them, your co-authors are likely to be confused with exactly how to use your macros correctly in various special cases.

Hence I'd recommend that you avoid macros for trivial things such as "et al." and simply spell out everything by using standard Latex markup. After all, most cases don't need any special handling ("e.g." is often followed by a comma; "et al." is often followed by "~\cite", etc.), and whenever special handling is needed, all Latex users should know how to use commands such as "\ " and "\@".

Jukka Suomela
I agree with the "cure is worse than the disease" sentiment of your answer, but *all Latex users should know how to use commands such as "\ " and "\@"* lost me: did you know that Tex puts extra space after the period in ".)"? If you did, congratulations, you are an elite TeXnician. If not, then you didn't know the proper usage of \@, which is what led to the question. The way Tex digests your text is very tricky, tricky enough that someone like Will Robertson can get caught out.
Charles Stewart
Charles: Oh, sorry, I was referring to simpler (and much more common) cases that are covered in virtually any Latex tutorial. Sure, I agree that the case of ".)" is indeed surprising, and it was nice to learn something new from the original question. :) However, I think that intricacies like this are a good reason not to try to fix it by using macros...
Jukka Suomela
Seems this is the best way to go (at least until LaTeX3 becomes standard).
Niall Murphy
+1. Charles just pointed out a really important case that makes me think this answer is correct -- when an abbreviation ends a sentence. How can you deal with this? Is there any way a single macro of any wisdom could ever tell if the period ends a sentence?
Geoff
+2  A: 

A technical challenge! We can avoid the problem of letters after spaces by looking at the catcode of the next character and seeing whether or not it is a letter; this can be done with the Latex3's expl3 macro \peek_charcode:NTF (my first expl3 code!):

\documentclass{article}

\usepackage{expl3}
\ExplSyntaxOn
\newcommand\latinabbrev[1]{
  \peek_meaning:NTF . {% Same as \@ifnextchar
    #1\@}%
  { \peek_catcode:NTF a {% Check whether next char has same catcode as \'a, i.e., is a letter
      #1.\@ }%
    {#1.\@}}}
\ExplSyntaxOff

%Omit final dot from each def.
\def\eg{\latinabbrev{e.g}}
\def\etal{\latinabbrev{et al}}
\def\etc{\latinabbrev{etc}}
\def\ie{\latinabbrev{i.e}}

\begin{document}

Maybe a list, \eg, a, b, c, and d.  Which is to say (\ie) a, b, \etc.  Consider Knuth, \cf The TeXbook.

\end{document}

Jukka's advice I think is sound, though: I'd say the problem Will works around with his \etc macro we should see as a bug in Tex's implementation of double spacing (Will Robertson should ask for his cheque): if you know the bug is there, you can workaround it directly by putting in \@ in cases such as ".)", or you can have tricky code that means you don't have to think in this case, but you have added complexity to the way you typeset which is not going to work for you with the next unexpected glitch, one you probably have introduced yourself.

Postscript Previous version fixed, thanks to Joseph Wright noticing a stupid error at tex.stackexchange.com.

Charles Stewart
It is "et al.", short for "et alii".
Svante
Also, I believe there should be a little, unbreakable space in "i.e." and "e.g.".
Svante
@Svante: *et al.* - indeed, fixed; *Little, unbreakable space* - I've never heard of that, and I can't see it in any book I've looked at: are you sure?
Charles Stewart
@Charles Stewart: I am not entirely sure, but I think that actually, it should be "i. e.". One would not like to have this broken at a linebreak, so it has become customary to type it "i.e." in "computer texts", but in TeX, it would better be "i.~e.". It might be a good idea to make this space a little smaller, but eliminating it entirely does not look right.
Svante
I don't think that the way Tex handles ".)" is (strictly speaking) a bug. (Consider a parenthetical remark – like this – that consists of several sentences and ends with a full stop. I think Tex does the right thing if it adds extra space after the closing parenthesis.) That said, I guess I would be happier if Tex didn't try to guess anything and there was simply a special markup that denotes end of sentence, but it's a bit too late to change that...
Jukka Suomela
@Svante: I'm looking at the Chicago MoS, 5.202, "i.e.; e.g." and it looks to me that there's quite a bit less horizontal space in "i.e." (in bold) between the dot and the "e" than between the "i" and the dot. It appears that they're using microtypography to reduce the space.
Charles Stewart
@Jukka: Look at this fragment of your answer, where I use underscore to inicate space: "closing_parenthesis.__)_That_said". Do you really want more space before the parenthesis than after? So that the closing parenthesis is grouped with the following sentence?
Charles Stewart
@Charles: Tex typesets it like "closing_parenthesis.)__That_said", not "closing_parenthesis.__)_That_said".
Jukka Suomela
@Charles Nice, though the whole academic publishing paradigm will probably be overturned before LaTeX3 becomes common enough with publishers. I havnt yet found how to trigger the "Check if next char is a letter" clause. For example `\eg an example`.
Niall Murphy
@Jukka: Sorry, yes, you are quite right and I had confused myself. In fact, the point Will made in his weblog post is precisely that ".) " is spaced as if it is the end of the sentence (i.e., ".)__"), even though the dot doesn't end the sentence. I wasn't confused in my answer, though, and I still say it is in bug territory, but I'll leave it at that for now.
Charles Stewart
@Niall: Err, yes, my code doesn't work in this crucial case. I'll look at it when I have a bit more time.
Charles Stewart
@Niall - fixed.
Charles Stewart
I just found a package called `xspace` that seems to give the functionality you implemented (without needing `expl3`). Would you please check the examples in my answer? Thanks.
Geoff
+1  A: 

Have you tried using the xspace package?

Example macro:

\def\etc{etc.\@\xspace}

Some tests:

Cat, dog, \etc. And so on.   \\
Cat, dog, \etc! And so on.   \\
Cat, dog, \etc, and so on.   \\
Cat (dog, \etc). And so on.  \\

Produces:

alt text


From the documentation:

The xspace package provides a single command that looks at what comes after it in the command stream, and decides whether to insert a space to replace one "eaten" by the TeX command decoder.

Geoff
You need to gobble the abbreviation's period in your first test (i.e., not "etc.."), so you need to test the next character as well. But you are quite right, the xspace package can be used instead of explicitly testing ahead for catcode 10.
Charles Stewart
Oh. Wow, good point. So the first example is wrong. I wasn't aware of this grammar rule somehow.
Geoff
So, in your example `Maybe a list, \eg,` a list should be `Maybe a list, \eg.,` since your macro does not have the ending period in it. I see now why you don't include the ending period in your macro. Thanks.
Geoff
@Geoff: The first is explicitly forbidden in all the guides I've looked that talk about abbreviations at the end of sentences, e.g., Butcher (2009) Copy-editing lists it among *Common faults of punctuation*. The second is problematic: I'd contract the ".!" to "!", but I don't know of any guide that says you must. My code doesn't treat this case.
Charles Stewart