Package: vertex2tex
VerTeX: Verbal TeXDo you find anything cumbersome about TeX syntax? For example,If instead of this...you'd prefer to type this...a_0, a_1, \ldots, a_{n-1}a0, a1, ddd, an-1\alpha, \beta, \gamma, ...alpha, beta, gamma, ...\mathfrak{p} \in \mathbb{Z}frp in bbZn^\mathrm{th}n eth\frac{2}{3}frac 2 over 3;\left| x \right|abs x;f^{(n)}f supp n;f^{-1}f inv\sum_{n=0}^\infty a_nsum over n from 0 to infty; an...then VerTeX may be for you!VerTeX is pronounced "ver-tech," and stands for "Verbal TeX," i.e. TeX
in which what you type is often much closer to what yousaywhen you read
mathematics aloud.I developed VerTeX while I was translating German mathematics into English,
and I wanted to be able to type symbolic expressions as quickly as I could
type words.Therefore one of the goals of VerTeX is to help you keep your
fingers over the home row. This leads to some verbal equivalents that may
appeal to some, but not to others.However, another feature of VerTeX is that -- with a few key exceptions
(see below) -- ordinary TeX syntax passes through unaltered, so that you may
use as many or as few of the features of VerTeX as you wish.UsageTranslateVerTeX --> TeXusing thetranslate_snippetfunction:>>> from vertex2tex import translate_snippet
>>> translate_snippet('bbQ(alp)')
'\\mathbb{Q}(\\alpha)'You can also process an entire document withtranslate_document.
The contents of each math mode will be
translatedconditionally: If the math mode begins or ends (or both) with a "@"
character, then we translateVerTeX --> TeX, after stripping the "@" char(s).>>> from vertex2tex import translate_document
>>> translate_document('Would you prefer $pie$ or $pie@$?')
'Would you prefer $pie$ or $\\pi$?'The purpose of the indicator character "@" is to let you decide in each
math mode whether you want to use VerTeX or not. Since it can come last
(just before the closing "$"), you can decide after the fact whether you
needed VerTeX or not.If you are certain that you want VerTeX translation to be applied ineverymath mode, and don't want to have to add "@" characters, you can passNoneto thekeycharargument oftranslate_document:>>> translate_document('Would you like $pie$?', keychar=None)
'Would you like $\\pi$?'Finally, withcond_translate_snippetyou can translate a single snippet of
math mode text, but according to the same conditional rules about "@"
characters used bytranslate_document:>>> from vertex2tex import cond_translate_snippet
>>> cond_translate_snippet('@alp')
'\\alpha'
>>> cond_translate_snippet('alp@')
'\\alpha'
>>> cond_translate_snippet('@alp@')
'\\alpha'
>>> cond_translate_snippet('alp')
'alp'The VerTeX LanguageSlash the Backslashes!When you are writing mathematics, how often do you want a Greek letter alpha, and how
often do you want to multiply the variables a, l, p, h, and a together, in that
order? Why then should$alpha$give you a sequence of Roman letters, while
the Greek letter requires a backslash?In VerTeX,$alpha$yields the Greek letter, and if you really want the product of variables,
simply put spaces between the letters, as in$a l p h a$.In general, VerTeX keywords are not strings of letters preceded by a backslash,
but simply strings of letters uninterrupted by whitespace.
Conceptually, the keywords in VerTeX may be divided into the following four
kinds, according to the role they play in avoiding backslashes.Types of VerTeX keywords:bsmebuilt-inbracket wordfont prefixIf you want to see (and perhaps alter locally) the lists of keywords, just
consult theconfig.pymodule in thevertexpackage.bsmes"bsme" stands for "backslash me," and a bsme keyword is
one that is exactly the same as a keyword in TeX, except without the backslash.
It produces the exact same result as the corresponding TeX keyword.
For the list of all bsme keywords, consult theconfig.pymodule.built-insThe so-called “built-in” keywords do not correspond to any existing TeX keywords.
They do not take any arguments, but simply translate directly into some
string of TeX, and their purpose is to in one way or another give an easier way
to type certain commonly used TeX strings.In particular, one of the goals of VerTeX is to give you the option to keep
your fingers over the home row while typing, and for this reason the built-in
keywords provide many alphabetical equivalents to TeX strings that ordinarily
involve non-alphabetical characters. For example,inv(for “inverse”) produces^{-1}, andsqu(for “squared”) produces^2.For the list of all built-ins, consult theconfig.pymodule.Going GreekGreek letters are near and dear to our heart in mathematics. They should
be easy to type.
In VerTeX,everyGreek letter -- including the variants -- has athree-letter name. And yes, this even includes the letters whose names
are ordinarily only two-letters long, like pi and mu!For example, you may typealpfor alpha,lamfor lambda, orLamfor capital Lambda.You may typevepforvarepsilon(everybody's favorite epsilon),
andvphforvarphi.As for pi, xi, mu, and nu, these letters have funny three-letter spellings
(anyone forpie?) in order to get around the auto-subscripting mechanism
discussed below.As usual, consultconfig.pyfor the full lists.You do not have to use these abbreviations if you don't want to.
Every Greek letter whose name is ordinarilymorethan two letters long
is also absmekeyword, so just go right ahead and spell it out if you
want to, whether it'salpha,lambda, orOmega.bracket wordsIn TeX there are many constructions in which a keyword takes arguments
surrounded by braces{ }. For example,\frac{\pi}{4}yields the sum of the Bhaskara-Leibniz Series. In VerTex, the same
construction is achieved byfrac pie over 4;In this example,frac,over, and the final semicolon;serve asbracket words.In general, when a construction takes arguments, then the arguments
are to be surrounded by the appropriate bracket words. For the most part, the
final bracket word will be a semicolon.The list of all such constructions in VerTeX can be found inconfig.py,
under theunarynodes,binarynodes,tertiarynodes, andrangenodesdefinitions. It includes many popular constructions, such as
sets, sequences, floors, ceilings, absolute values, "mod" expressions,
Legendre symbols, binomial coefficients, sums, products, and more.font (and decorator) prefixesTechnically font prefixes are not “keywords” in and of themselves. They are
two- or three-character prefixes which, when followed by a letter of the alphabet,
produce that letter in the appropriate font. The prefixes and the fonts that they
correspond to can be found inconfig.py.For example, instead of\mathfrak{p} \mathsf{M} \mathbf{v} \mathbb{Q} \mathcal{O} \mathscr{B}you may typefrp sfM bfv bbQ calO scrBto achieve the same thing.You can also use prefixes to get things like hats and tildes. For example,
instead of\hat{x}just typehatx.Auto-Subscripts (and Superscripts)In mathematics, subscripted variables are the coin of the realm, and therefore it
ought to be easy to type them. VerTeX makes it fast and easy to get subscripts
and superscripts. For example,Cumbersome TeX......is easy in VerTeXa_1, a_2, \ldots, a_{n+1}a1, a2, ddd, an+1x_{i_1}, x_{i_2}, \ldots, x_{i_m}xivv1, xivv2, ddd, xivvma_{i j}^2aijuu2Thesemiautomatic subscripting and superscripting(henceforth SSS) mechanism of
VerTeX is very handy, and, as the examples in the table show, makes it
much easier to type certain common kinds of subscripts and superscripts.While many subscript and superscript combinations can be achieved through
SSS, some things are not possible. In such cases, you can use thesubandsupbracket words, or can even fall back on standard TeX syntax.The complete description of the SSS process is a bit complex, but for most
common purposes it is quite simple. Therefore before we give a detailed
specification of the process, we consider the main ideas.First we need some terminology. We all know what subscripts and superscripts
are, but what do we call the letter they get attached to? Let's call it the "base".In most cases, the process is simple: VerTeX will take a wordwand split it asw = bs, wherebis the longest initial segment ofwthat matches as a letter
name, andsis everything that remains. Thenbwill be the base, andswill be the subscript.Examples (and one non-example):VerTeXTeXpip_ialphan\alpha_nbbZm\mathbb{Z}_mcn+1c_{n+1}ai,ja_{i,j}zeta\zetaThere are several things to note about these examples:It was so thatpicould be available for automatic subscripting that we gave
the Greek letter pi the (admittedly somewhat silly) spellingpie. Writingp_iis a perhaps daily occurrence for anyone who works with prime numbers, and
this includes a lot of mathematicians.Letters with extended names, likealpha, and letters with a font prefix in
front of them, likebbZ,willindeed be counted as initial letters.Commas, as well as plus and minus signs, are considered part of the word.What happened withzeta? Perhaps we were hoping this would translate
toz_\eta, but of course VerTeX instead matched the entire word zeta as the base.
There is a way to get around this, which we discuss below. Preview: You may typezvvetain order to getz_\eta.The DetailsTo the VerTeX parser, a "word" consists of alphanumeric characters, as well
as commas and the plus and minus symbols. It must begin with an alphabetical
character. (In other words a “letter,” but this means one of the ASCII letters in
the character class[A-Za-z], and is not to be confused with all things
that may be considered "letters" in VerTeX, which includes, for example,
Greek letters, and letters with font prefixes.)For those familiar with regular expressions, this means that words
are built on the character class[A-Za-z0-9+-,]The last three symbols are included in the character class because they are
common in subscripts.
(However, this means that if you do not want to accidentally trigger a subscript,
you need to put whitespace on at least one side of these characters!)Now suppose thatwis the next word that VerTeX has to process. Ifwfails
to match as any kind of
keyword – bsme, built-in, bracket word, or font-prefix-letter combination -- thenwis
submitted to the SSS process.VerTeX first matches the longest possible letter name at the beginning ofw,
as discussed above. Let the wordwconsist of initial letterbfollowed by
remainders, that is,w = bs. Thenbwill be the base, andswill give one or
more subscripts and/or superscripts.In the simplest case,ssimply represents a subscript. It is possible however to
switch between subscripts and superscripts using the special character sequencesvv,uu, andUU.NEW in Version 0.3.3: As alternatives to the character sequencesvv,uu, andUU, you may also use, respectively,__,^^, and^^^.A few examples illustrate all the ways to use these control sequences:VerTeXTeXauura^raiuura_i^rauurvvka^{r_k}aivvja_{i_j}aivvjuura_{i^r_j}aivvjUUra_{i_j}^rzvvetaz_\etaThe rules are:Sequencevvopens a deeper subscript. In TeX it is as though you typed_{.Sequenceuucloses a subscript and opens a superscript. In TeX it is as
though you typed}^{.SeuqneceUUclosestwosubscripts and opens a superscript. In TeX it is as
though you typed}}^{.One special exception is that ifvvis used at the very beginning ofs,
it merely keeps you at the first subscript level. Thus,zvvetaprovides a way
to producez_\eta, whilezetasimply gives\zeta.Again, use of these special control sequences may appeal to some, but not to
others. They facilitate fast typing, but are perhaps not as good when it comes
time toreadthe code later. Of course, you can still use the
ordinary^and_of TeX if you prefer.Use only what you wantVerTeX is 99% transparent to ordinary TeX.
That means you can type (almost) any ordinary TeX you want, and it will pass
through the VerTeX filter unaltered. So, use as many or as few of the features
of VerTex as you wish.What are the gotchas?The main gotchas are keywords and automatic subscripting; but the solution
is always very simple: Add spaces!If a sequence of characters has been matched as a VerTeX keyword but this
is not what you wanted, just put one or more spaces between those characters.Likewise, if automatic subscripting is taking place when you don't want it,
the solution is the same: separate the characters with spaces.Safety netAs a “safety net,” any word whatsoever may be prefixed with a double
backslash\\in order to allow that word to pass through VerTeX unaltered.
To be precise, if there is any remainderwto the word, then this, minus the two
backslashes, is what will pass through. If just two backslashes alone are typed,
they will pass though unaltered (which is useful in TeX table environments).
Meanwhile, any word beginning with a single backslash is passed through VerTeX
completely unaltered, i.e. with the leading backslash still intact.
In summary:\\w  -->  w
\\   -->  \\
\w   -->  \wwherewis a word at least one character long.But you probably won't need to use this anyway. In using VerTeX for over ten years,
I cannot recall needing it once.Enjoy!