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.

If I understand correctly, (La)TeX assumes that a period after a lower-case letter ends a sentence while a period after an upper-case letter does not. Unfortunately, my documents usually contain plenty of acronyms and abbreviations. Unless I remember to use \@, the spacing after periods is wrong:

\documentclass[convert={density=150},varwidth]{standalone}
\begin{document}
\noindent
\makebox[0.7in][l]{Incorrect:}%
Your computer needs more RAM.  I can give you some.\\
\makebox[0.7in][l]{Correct:}%
Your computer needs more RAM\@.  I can give you some.\\
\makebox[0.7in][l]{Incorrect:}%
Colors (red, blue, etc.) are nice.\\
\makebox[0.7in][l]{Correct:}%
Colors (red, blue, etc.\@) are nice.
\end{document}

rendering of the above document

Is it possible to declare certain strings to be acronyms or abbreviations to invert this assumption? If so, this would reduce the number of spacing errors in my documents.

For example:

\documentclass[convert={density=150},varwidth]{standalone}
\usepackage{magicalacronymhelper}
\declareacronym{RAM}
\declareabbr{etc}
\begin{document}
\noindent
\makebox[0.7in][l]{Correct:}%
Your computer needs more RAM.  I can give you some.\\
\makebox[0.7in][l]{Correct:}%
Your computer needs more RAM\@.  I can give you some.\\
\makebox[0.7in][l]{Correct:}%
Colors (red, blue, etc.) are nice.\\
\makebox[0.7in][l]{Correct:}%
Colors (red, blue, etc.\@) are nice.
\end{document}

enter image description here

share|improve this question
1  
the ltugboat document class has a command \acro that corrects for the end of a sentence. (it does other things as well, such as stepping the type size down a point to de-emphasize the appearance of in-line uppercase -- we don't like how small caps look in this context --, but that's easily ignored.) you're welcome to steal the idea; look for ltugboat.cls on ctan. (it doesn't handle the "etc." case; you're on your own for that.) –  barbara beeton Jan 2 '13 at 22:45
    
The issue the with etc. is that it is an abbreviation and that it can legitimately occur at the end of a sentence. At this point you do not want to to quell the end of sentence spacing. –  ArTourter Jan 2 '13 at 23:02
    
@ArTourter: True. In that case, I'd add an \@ to force it to be interpreted as a sentence-ending period. For example: I like citrus flavors: orange, lemon, lime, etc\@. They are tasty. I rarely end sentences with an abbreviation, so inverting the default behavior of periods after abbreviations would fix more than it would break. –  Richard Hansen Jan 2 '13 at 23:22
1  
Simplest (and some would argue most typographically correct) solution is to use \frenchspacing so the issue just goes away. –  David Carlisle Jan 3 '13 at 0:08
    
@RichardHansen -- the problem with adding \@ to "etc." is that it will in any event be interpreted as ending a sentence (since it's lowercase). what you want to do is prevent it from indicating the end of a sentence in those (randomly occurring) cases where it doesn't. that's where the "slash-space" is needed. as for david's comment regarding \frenchspacing, there are situations where this can cause confusion; i've definitely seen them, though i can't put my hands on one right now -- that may call for rewriting rather than a spacing "fix". –  barbara beeton Jan 3 '13 at 13:41

1 Answer 1

up vote 9 down vote accepted

There is no way to do this automatically, unless you're willing to use XeLaTeX and the unsupported package xesearch.

The best thing you can do is to define macros \acro and \abbr:

\newcommand{\acro}[1]{#1\@}
\makeatletter
\newcommand{\abbr}{\@ifstar\@firstofone\@abbr}
\newcommand{\@abbr}[1]{#1.\@}
\makeatother

Complete example:

\documentclass{article}
\newcommand{\acro}[1]{#1\@}
\makeatletter
\newcommand{\abbr}{\@ifstar\@firstofone\@abbr}
\newcommand{\@abbr}[1]{#1.\@}
\makeatother

\begin{document}
\noindent
Your computer needs more \acro{RAM}.  I can give you some.\\
Your computer needs more RAM\@.  I can give you some.\\[3pt]
Colors (red, blue, \abbr{etc}) are nice.\\
Colors (red, blue, etc.\@) are nice.\\[3pt]
I like citrus flavors: orange, lemon, lime, \abbr*{etc}. They are tasty\\
I like citrus flavors: orange, lemon, lime, etc\@. They are tasty
\end{document}

enter image description here

share|improve this answer
    
Shouldn't \newcommand{\@abbr}[1]{#1\@.} be \newcommand{\@abbr}[1]{#1.\@}? –  Richard Hansen Jan 3 '13 at 0:17
    
@RichardHansen Yes, it should. Fixed. –  egreg Jan 3 '13 at 0:22
    
Thanks! Too bad it can't be automatically done. I'm just as likely to remember to type \abbr{} or \acro{} as I am to type \@. :) –  Richard Hansen Jan 3 '13 at 0:28
    
What's the purpose of all the \@ifstar\@firstofone business? And why do you suggest in the case of \abbr but not \acro? –  Cerran Mar 7 at 22:14
    
@Cerran \abbr is supposed to act on lowercase letters, while \acro on uppercase ones, and they require different treatment; \abbr* is for when punctuation follows. –  egreg Mar 7 at 22:21

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.