Home | | Help | Contribute | Plug-ins | About | Contact | Search
Using TeXmacs as an interface
Manual | Top | Previous | Next

An important feature of TeXmacs is it's ability to communicate with extern systems. For computer algebra systems or other scientific computation systems, this is typically done in shell-like sessions, in which it is possible to evaluate commands and display the results in a nice, graphical way. Some systems can also be used more in the background as scripting languages.

See HelpPlug-ins for a list of existing plug-ins and more documentation on these systems.

1.Creating sessions

A session can be started from the InsertSession menu. Since TeXmacs is based on the Scheme language, it is always possible to start a Scheme session using InsertSessionScheme. On Unix systems, it is usually also possible to start Bash shell sessions using InsertSessionShell. The remainder of the items in the InsertSession menu depend on the plug-ins which are installed on your system.

A session consists of a sequence of input and output fields and possible text between them. When pressing inside an input field of a session, the text inside the environment is evaluated and the result is displayed in an output field.

When entering a command in a session, the application attempts to execute it. Several commands may be launched concurrently in the same document, but the output will only be active in the session where the cursor is and at the place of the cursor. Therefore, we recommend to use different buffers for parallel executions.

For each type of extern application, one may choose between sharing a single process by different sessions, or launching a separate process for each different session. More precisely, when inserting a session using InsertSessionOther, you may specify both a “session type” (Shell, Pari, Maxima, etc.) and a “session name” (the default name is “default”). Sessions with different names correspond to different processes and sessions with the same name share a common process.

In order to finish the process which underlies a given session, you may use SessionClose session. When pressing in the input of a non-connected system, the system will be restarted automatically. You may also use SessionInterrupt execution in order to interrupt the execution of a command. However, several applications do not support this feature.

In order to evaluate all fields of e.g. a previously created session, you may use SessionEvaluateEvaluate all. Similarly, SessionEvaluateEvaluate above and SessionEvaluateEvaluate below allow you to evaluate all field above or below the current field.

2.Editing sessions

Inside input fields of sessions, the cursor keys have a special meaning: when moving upwards or downwards, you will move to previous or subsequent input fields. When moving to the left or to the right, you will never leave the input field; you should rather use the mouse for this.

Some facilities for editing input, output and text fields are available in the SessionField menu. Keyboard shortcuts for inserting fields are (insert above) and . Keyboard shortcuts for removing matching text/input/output fields are (remove backwards) and (remove current fields).

It is possible to create “subsessions” using SessionSessionCreate subsession or . In that case, the current input-output field becomes the body of an unfolded subsession. Such a subsession consists of an explanatory text together with the subsession body. Subsessions can be folded and unfolded using resp. . Subsessions have a nice rendering on the screen when using the varsession package in DocumentUse packageProgram.

Other useful editing operations are SessionSessionClear all fields, which is useful for creating a demo session which will be executed later on, and SessionSplit session, which can be used for splitting a session into parts for inclusion into a paper.

3.Selecting the input method

By default, TeXmacs will attempt to evaluate the input field when pressing return. Multiline input can be created using S-return. Alternatively, when selecting the multiline input mode using SessionInput modeMultiline input, the return key will behave as usual and S-return may be used in order to evaluate the input field. Notice finally that certain systems admit built-in heuristics for testing whether the input has been completed; if not, then the return may behave as usual.

Certain applications allow you to type the mathematical input in a graphical, two dimensional form. This feature can be used by selecting SessionInput modeMathematical input. If this feature is available, then it is usually also possible to copy and paste output back into the input. However, it depends on the particular application how well this works.

4.Plugins as scripting languages

TeXmacs provides a few other kinds of additional interfaces to external systems in addition to shell-like interfaces. First of all, it is possible to insert a so called “executable switch” anywhere in the document using InsertFoldExecutable.

For instance, if Maxima is installed on your system, then InsertFoldExecutableMaxima should yield something like

Maxima
. You may enter a Maxima expression in the yellow part of this markup, say
Maxima diff(x^x,x)
. Using , you may now switch back and forth between the unevaluated input and the evaluated output . Using , you enable multi-line input. This kind of executable switches are very useful for plugins such as DraTeX, Eukleides, Feynmf, etc., which are mainly used for the efficient computation and insertion of special graphics inside TeXmacs documents.

Some plugins such as Maxima can even be selected as a scripting language using DocumentScriptsMaxima. When doing so, a special Maxima menu will appear, which allows for many useful operations directly on formulas. For instance, when putting the cursor inside the formula and pressing or Evaluate, the formula gets evaluated automatically to yield .

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".