tags:

views:

239

answers:

5

I want LaTeX to automatically replace strings like " a ", " s ", " z " with " a~", " s~", " z~", because they can't be at line end. Any suggestions?

+1  A: 

Click Find and Replace (or similiar) in the menu of your text editor and do it.

Alexey Malistov
+1  A: 

I'm afraid (to the best of my knowledge) this is basically impossible with LaTeX. A LuaTeX-based solution might be possible, though.

It's not actually clear to me, however, that " a ", for example, shouldn't appear at the end of a
line. Although I might be used to different typographic rules.

(Is there anything wrong with the line break in the last paragraph? :))

Will Robertson
A: 

As far as I know there is no way to do this in LaTeX itself. I'd go for automating this with some external tools, as my typical setup involves a Makefile handling the LaTeX run by itself. This makes it rather easy to run tools like sed on the sources and do some replacements using regular expressions, and a simple rule would do this for your case.

If you use some LaTeX editor that does everything for you you should check the editors regular expression search and replace functionality.

bluebrother
A: 

Yes, this is the age old argument of data processing vs. data composition. We have always done these things in a pre-processor environment responsible for extracting the information from its source environment, SQL or plain-text, and created the contents of a \input(file.tex).

But yes, it is possible (TeX is after all a programming language) but you will have to become a wizard. Get the 4 volume set TeX in Practice by Stephan von Bechtolsheim.

The approach would be to begin an environment (execute a macro) whose ''argument'' was all text down to the end of the environment. Then just munge though the tokens fixing the ones you want.

Still, I don't think any of us are advocating this approach.

Don
+2  A: 

For Czech typographic rules, there is a preprocessor called "Vlna" by Petr Olšák - download it at ftp://math.feld.cvut.cz/pub/olsak/vlna . The set of (usually prepositions in czech) is customizable - so it might be usable for other languages as well.

Mirek Simek
It seems you interpreted *why* the OP wanted this behavior and approached the problem with that in mind. Seems like a very useful link.
Paul Lammertsma