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.

One thing I find annoying about (La)TeX is that there are too many special characters. To have any of \ $ % & # _ ~ ^ { } in a text in the document we have to escape it using \.

Personally I think this is stupid - after all we are writing a text document and not doing programming.

I think it would be great if there was a mode where we only have one escape character (and \ would suite me just fine) and all commands and control sequences would have to be preceded by \. Comments would be (e.g.) \% math could be introduced with \$ etc.

Are there any packages/hacks/modifications that allow this?

share|improve this question

3 Answers 3

up vote 10 down vote accepted

I can't answer your question about any packages that do that. Some of those parameters could be changed. For example, if you alway use \( ... \) instead of $...$, then you could make $ just be a normal punctuation symbol (or you could use \$). Likewise, \&, \_ and \^ could easily be swapped with their nonslashed counterparts. There's no need for ~ to be active, you could easily define \~ to have the same effect. As Will notes in the comments, # can be made a symbol.

I wasn't able to get comments working. I can't figure out how to get a macro to expand to an end of line token. Actually, I'm not even sure that's one of the tokens that gets to TeX's "stomach."

The real problem would come with braces. You really do need two additional characters to act as groupings. You could make two characters you don't frequently use be those.

So barring braces being special and not having line comments (although it'd be easy to define a block comment like \def\%#1\relax{} which might be sufficient for your purposes), this seems to work.

\newenvironment{plaintext}{%
        \catcode`\$12
        \def\&{&}%
        \catcode`\&12
        \def\_{_}%
        \catcode`\_12
        \def\^{^}%
        \catcode`\^12
        \catcode`\#12
        \catcode`\%12
        \let\~~%
        \catcode`\~12
}{}

Use it like

\begin{plaintext}
Here is some test text % ^ & _ $ # &.

How about some math \(x\_y\^z\). You're still out of luck with braces
though.
\end{plaintext}
share|improve this answer
    
You could use \begingroup...\endgroup. Shows why you shouldn't, really. –  Charles Stewart Sep 10 '10 at 11:07
    
Don't forget #, which can be turned into a letter as soon as your macro definitions are all done with. (Well, this might perhaps break some obscure code that uses \scantokens, but you're probably safe.) –  Will Robertson Sep 10 '10 at 11:08
    
@Charles: I don't think \begingroup will work in this way. –  Will Robertson Sep 10 '10 at 11:10
    
@Charles: Do you mean \bgroup...\egroup? This didn't work for me. I can never remember the rules for when you can use implicit braces, but I don't believe this is one of those times. –  TH. Sep 10 '10 at 11:17
    
"you could make $ just be a normal punctuation symbol" ... how would I do this? Link appreciated :-) –  Martin Sep 10 '10 at 11:20

In ConTeXt, we are discussion adding a macro \asciimode which will set catcodes such that only \, {, } and spaces (tab, newlines, and pagefeed) have their usual meaning. Everything else (including % and $) are set to other.

You can enter into math mode using \math{...}, display math mode using \startformula, comments using \starthidden, etc. Inside the math mode, _ and ^ have their usual meaning. There will be a dedicated 'programming' environment that will restore the traditional TeX catcodes.

A preliminary version is at the end of http://source.contextgarden.net/tex/context/base/catc-ctx.tex (although commented out at present)

share|improve this answer
1  
It looks to me like ~ is left active. –  Charles Stewart Sep 10 '10 at 20:22

LuaTeX defines primitives for single char control sequences used in TeX:

\Usuperscript           ^
\Usubscript             _
\Ustartmath             $
\Ustopmath              $
\Ustartdisplaymath      $$
\Ustopdisplaymath       $$

So one can use these primitives in a way or another and set the catcode of those special characters to normal. This leaves percent sign, but I think if really needed, one can define a different comment character to replace it.

share|improve this answer

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.