Is it possible to make LaTeX, or a similar software, interpret a/b as \frac{a}{b}?

Writing out (x+1)/((x)(x+2)) seems much easier than writing \frac{x+1}{(x)(x+2)}.

  • 4
    Maybe if you promise to always use the parentheses. But you didn't use them in the previous line.
    – Teepeemm
    Aug 7, 2020 at 20:48
  • In vimtex there is a command that switches between the two forms, which I personally don't use because they are graphically different and I want to use both, depending on the context.
    – Rmano
    Aug 7, 2020 at 21:29
  • My first thought is to make / active and \let/=\pver. The semantics will be a bit different: you'll need to drop the parentheses yourself and if it occurs in the middle of another expression you'd need to write, e.g., {a/b} = c but it might make you a little happier.
    – Don Hosek
    Aug 7, 2020 at 22:38
  • See my answer here: tex.stackexchange.com/questions/332012/… Aug 7, 2020 at 23:53
  • 1
    @DonHosek Typo. \let/=\over. Aug 8, 2020 at 9:34

2 Answers 2


LaTeX is one of formats of TeX. And TeX has \over primitive. The usage is $numerator\over denominator$ or $...{numerator\over denominator}...$. The LaTeX macro \frac is defined (roughly speaking) by \over primitive: \def\frac#1#2{{#1\over#2}}.

LaTeX does not hide TeX primitives, so you can write:

Writing out $x+1\over(x)(x+2)$ seems much easier than writing $\frac{x+1}{(x)(x+2)}$.

You can set the / character as "math active character" and write:

{\catcode`/=13 \global\let /=\over}

Writing out $x+1/(x)(x+2)$ seems much easier than writing $\frac{x+1}{(x)(x+2)}$.

Of course, if the scope of the fraction is less than whole formula, you must use {} in order to give this scope, for example ${a/b}=c$, as mentioned in the Don Hosek's comment.


It is really hard to crack down on all the corner cases that come with an approach using textual replacements. In general parsing such constructs requires a finite state machine to correctly render, e.g.


The syntax you are describing reminds me a lot of AsciiMath, a language to write mathematical formulae with only very few special symbols. I don't know of an implementation of AsciiMath in LaTeX, but there exists one in ConTeXt. This might be closer to what you are looking for. However, I'd like to quote Hans Hagen, the implementer of this code, from his talk at TUG 2015 (from memory)

“Writing AsciiMath is fun. You never know what output you will get.”




    a/b * alpha/omega * f(x)/g(x) * (x+1)/(a*(b+c))


enter image description here

You can actually use ConTeXt's AsciiMath in LaTeX with surprisingly little effort (but probably with limitations).

\usepackage{unicode-math} % you have to use this for AsciiMath
xml = xml or {}
lxml = lxml or {}
moduledata = moduledata or {}
statistics = statistics or { register = function() end }

function asciimath(str)
    local texmath = moduledata.asciimath.convert(str)
    assert(texmath) -- sledgehammer error handling

% Some aliases from ConTeXt

    %\enableautofences % No straightforward LaTeX equivalent
    \mathdelimitersmode="16 % Some magic number from ConTeXt




    a/b * alpha/omega * f(x)/g(x) * (x+1)/(a*(b+c))

    a/b * alpha/omega * f(x)/g(x) * (x+1)/(a*(b+c))


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .