I would like to be able to type things like $1/2$ instead of $\frac{1}{2}$ as this would make my code better readable. For longer equations I prefer to use \frac{}{}, but for things like 1/2 I don't like it.

This does the trick in some sense:

\catcode`/ = 13

But I don't really like the way \over works. Is it possible to redefine \over such that ab\over cd is interpreted as a\frac{b}{c}d? And such that {ab}\over{cd} is interpreted as \frac{ab}{cd}?

I know it is recommended to not use \over, but as \frac is a definition based on \over I thought that it may be possible to write another definition based on \over that give less problems than \over, but keeps the infix notation.

  • @Mico I don't want to change the definition of \over. I want to have a new definition say \newover that works like I described and then use \catcode`/ = 13 \def/{\newover} so that I can type 1/2 instead of \frac{1}{2} – Kasper Nov 7 '13 at 6:34
  • 1
    you can copy the definition of \frac but I'm sure that this will make some other package break down if not scoped properly. – percusse Nov 7 '13 at 6:48
  • I'm not sure I understand what you are saying here. How can it help me to copy the definition of \frac ? – Kasper Nov 7 '13 at 7:22
  • 1
    at the macro level there is no way to go back and pick something which came before. You can do \def\Over #1/#2{\frac {#1}{#2}}, and then make some character mathematically active (no need to make it catcode active in the whole document), let's say for example the @ and then your input will be $@3/2a+@5/3b$. – user4686 Nov 7 '13 at 8:57
  • 1
    This would be a bad idea even if it were doable. Your code will not be more readable. However, you would need ${1/2}+{1/3}={5/6}$ anyway, because of how \over works. – egreg Nov 7 '13 at 10:42

As I see it, the issue with the \over macro -- and similar TeX "primitive" commands, such as \choose and \atop -- is precisely that its infix notation lends itself to creating serious accidents unless its syntax is obeyed perfectly. This is, presumably, why the LaTeX macro \frac was created in the first place: to act as a carefully crafted "wrapper" macro around \over.

If you're confident you can handle \over's infix syntax, there's no need to create a new macro. You could simply write expressions such as

$a{{b}\over c}d$


${{ab}\over cd}$

(The extra grouping around the numerator term can be omitted if it contains only simple material, i.e., no commands that might affect the denominator term as well as the numerator.) Note that it's not enough to make / active and act like \over. It's indispensable to enclose the numerator and denominator terms suitably so that \over -- or any other command that acts like \over -- "knows" what to act on.

To me at least, the \over-based expressions don't look a whole lot more readable than $a\frac{b}{c}d$ and $\frac{ab}{cd}$ do.

  • It does become more readable if you define / as \over. You get things like {1/2}b+{1/3}a instead of \frac{1}{2}b+\frac{1}{3}a. But I was wondering if you could define an new command such that you can write 1/2 a + 1/3 b. – Kasper Nov 7 '13 at 8:51

\def\Over #1/#2{\frac {#1}{#2}}
% usage \Over stuff/{braced or single}


\mathcode`@ "8000


\[ @3/2a+@5/3b \]

\[ @314/2a+@533/3b \]


over as @

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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