TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Detect beginning of a sentence in a macro for capitalization

Is it possible to write a macro that is able to determine if it is used at the beginning of a sentence? For example, imagine

This \location is nice. \location has its charm.

A simple and silly one, but anyway, you get the idea. I want the second street to be "Street." How would one do this? I am using lualatex, so if only a lua-specific solution is possible, I'd be happy with it. If it is not possible then I would have to do it manually, but that would be a lot of work in my text :-(

share|improve this question

marked as duplicate by Werner, Hendrik Vogt, Gonzalo Medina, clemens, Harish Kumar Jul 21 '12 at 23:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 9 down vote accepted

A quick test on \spacefactor works:

enter image description here

This \location\ is nice. \location\ has its charm.

The \spacefactor differs depending on the preceding punctuation: 3000 after a period.

Since I'm unfamiliar with \spacefactor, I'm not sure how robust it is.

share|improve this answer
That's really nice, it fails, if \frenchspacing is set though. With nonfrenchspacing set before ifnum it seems to work with frenchspacing too. – Peter Breitfeld Jul 21 '12 at 20:04
Ha! And I was thinking that this was nearly impossible within LaTeX and required perhaps some lua magic! – Gonzalo Medina Jul 21 '12 at 20:07
+1 and a (virtual) 'Sneaky Badge'! ;) – Count Zero Jul 21 '12 at 20:41

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