📜 ⬆️ ⬇️

How once was Emacs from Octave in Latex formula dragged

Quite often it is necessary for the university to carry out various simple calculations of laboratory, calculated and, in this semester, thesis work of the bachelor. For each of them it is necessary to draw up a report in which all calculations must be given, both in symbolic form and in numerical form. Sometimes it was possible to re-type the report three times again, when the teacher detected error after error at the very beginning.

The report is twenty pages, of which fifteen are calculations. No reasonable activity, just a dull and painstaking set of formulas with your fingers.

When I started to write a bachelor's work, it became clear that every ten or hundreds of formulas were driven into the report ten times each, there was no desire, but there was a desire to learn more about the possibilities of Emacs and Emacs Lisp. So it was decided that this very formulas to program.

')

Latex, Octave, Emacs



If someone does not know - in Word a disgusting set of formulas. Slightly better situation
This is the case in OpenOffice, where formulas must be typed in a special language.

In both of these applications, you need to download a hefty and, accordingly,
slow program, suffer using the mouse; no way
automate the assembly of documents. Therefore, for the report set I use
Latex.

Latex, if you do not use clever words, this is such a scientific markup language
texts. The entire document is typed in plain text, which is then fed.
parser and gives some convenient for printing or reading format; in my
case - pdf.

I generally love everything that is stored as plain text files; always here
there is room for programmer fantasy: the document can be tormented by regular
expressions, automatically create scripts, easy to create and edit
templates without additional formalities.

It is reasonable to use Octave for automation of graduation calculations - free
Matlab clone. The program uses a very simple language, fully compatible.
with the language of the original program; extra effort on mastering me not
it took.

Well, all this is combined with a special glue - a universal super-duper editor
Emax, in which I write all my code and text. In it as a child
process, the Octave code interpreter is launched, and for typing and previewing
Formulas - Auctex special mode.

Emax is a so-called Lisp machine. All his features, even
the most basic, are scripted on a simplified version of the functional language Lisp. AT
at any time you can write a small function, feed Emax and immediately
pin to any key to use.

Subtasks



So, the program should solve the following tasks:


Decision



The first three points are decided by a simple parser on Elisp; the last point is very
it is easy to execute, as in the standard flow of any child process (in
in this case, the Octave interpreter), you can send any string, and receive
standard output. That is, after Octave executed my file with
calculations, you can simply send the names of the variables, and get their numerical
values.

That's all. Put the cursor on the line with the formula in the file Octave, click a pair
keys - the formula is inserted into the report file as symbols, then as
numbers, and finally the result.

See illustrations!

It was

So it became

Preview formulas in Emax

Possible improvements



To insert a single formula, thus, you just need to move the cursor and press
a couple of keys. In principle, one could go even further and make a report assembly.
completely independent of me. Let's say mark with a special comment with
For example, in the report, the place where the formula should be inserted, and in the calculation file the same
an example to put next to the calculated expression. Then it will be enough to write
“build-report” command, and after - watch how the document is filled.

But somehow my hands did not reach ... :) Yes, and with the university, I like while I finish,
further the program is not useful. But the experience is definitely positive, diploma
began to move much faster. It's a pity the faculty is not about me
programming, for such things on the head no one thinks to stroke.

In general, for a collection of Latex documentation, Elisp code, and explanations to
him, you can contact me personally at the appropriate address. With pleasure
help with Emacs whenever possible; although, of course, to the level of the guru, I am still very
and very far; the problem is generally the first experience of Elisp programming.

Source: https://habr.com/ru/post/27545/


All Articles