en fr

Sysquake Pro – Table of Contents

Sysquake – Table of Contents

Sysquake for LaTeX – Table of Contents

Package sysquake.sty

This section documents the LaTeX package sysquake.sty. This package permits to embed in LaTeX source files (.tex suffix) fragments of code written in LME, the programming language of Sysquake. All these fragments are evaluated successively in the same context: definitions and variables can be reused across multiple fragments.

Package options

The package is imported in the main LaTeX source file with \usepackage:


Several options can be specified in a comma-separated list in square brackets; for example


Here is a list of all supported options.

By default, text in graphics is embedded in EPS files without further processing. In addition to axis scale labels, graphical commands which display explicit text are label, legend, text, and title.
With option latexingraphics, all the text which appears in graphics in handled by LaTeX. This has two benefits: first, text font and size mix much better with the document text, for a higher overall quality. Second, LaTeX constructs can appear anywhere in graphics, with greek letters, math symbols and equations. A small drawback is that some characters, such as \ and $, have a special meaning for LaTeX which make the code incompatible with other versions of Sysquake.
Each time the document is typeset, Sysquake code fragments which have been extracted during the previous iteration are evaluated by a platform-dependant program, sysquakelatextool. This program produces output data fragments which are inserted in the document, and EPS files which contain graphics.
With option noexec, sysquakelatextool is not executed. The typesetting result will still be correct if all its output files (.lmeout and .eps files) already exist and code fragments, and the size of all text strings displayed in graphics if option latexingraphics is used, are not modified.
The main purpose of this option is to let an author make minor modifications on a platform where sysquakelatextool is not supported.
By default, standard error channel used when evaluating Sysquake code fragments is redirected to a file whose base name is the same as the main .tex file and the suffix is .lmelog. This file can be opened after typesetting to check that all code fragments were executed correctly. This is especially important when an error occurs, when a code fragment is replaced with ??sysquake?? in the typeset result.
The noseparatelogfile option merges the Sysquake standard error channel with other LaTeX messages.
Instead of storing error and warning messages in a separate file (default) or in the main log file (option noseparatelogfile), with option includelog, this information is appended directly to the typeset output (PDF or DVI file). A reference is added to the code fragment result, which becomes ??sysquake?? (see LME log). If the package hyperref is used, the words LME log are a hypertext link to the error and warning messages.

Additional options with arguments can be set with special LaTeX commands:

Specifies the amount of memory allocated to Sysquake for LaTeX in megabytes. For special purposes such as large images, a large amount, such as 128 or 256, can be specified.
Specifies the normal line width in EPS files, in 1/72 inch. The default value is 1.
Specifies the list of paths where libraries are searched; each path is separated with a semicolon. By default, libraries are searched where the installer has placed the standard libraries distributed with Sysquake for LaTeX, and in the same directory as the .tex file being processed.

Other packages

Package sysquake.sty depends on other packages for some tasks. You should also import them with \usepackage if necessary.

Used to include EPS graphics generated by Sysquake for LaTeX.
Used by pdflatex to convert EPS graphics to PDF. pdflatex cannot include directly EPS files.
Used for hypertext links created by writing text markup to file descriptor 4.
Used for listings of LME functions inserted with sqlxsource.

The preamble of an article which needs all these packages could be as follows. There is no harm in importing superfluous packages.



Any text output produced by code fragments is inserted in the LaTeX source code. It is subject to further evaluation by LaTeX.


\sqeval{code} evaluates code fragment code, which is processed as LaTeX code before being evaluated by Sysquake for LaTeX; hence characters aimed at Sysquake which have a meaning in LaTeX, such as \ and $, must be escaped.


Simple value:

The result is \sqeval{disp(1+2);}.

Passing a LaTeX counter:

The square root of \arabic{n} is \sqeval{disp(sqrt(\arabic{n}));}.


\sqexpr{expr} evaluates expression expr, formats it for LaTeX and inserts it in the result. The expression should not be terminated by a semicolon or comma.

Currently, the following types are supported: real or complex double, scalar or 2-dim arrays, and strings. Options set by format are used; scientific notation is displayed with the mathematical notation (a multiplication by 10 to some integer power) instead of the classic computer notation.

\sqexpr can be used in text as well as in math mode. It is a fragile command; to use it in a moving argument, such as the argument of \caption, put \protect right before it.


Scalar value in an equation:

Some small number:
$\frac{\pi}{e^{10}} = \sqexpr{pi/exp(10)}$.

Magic square of size 5:

M_5 = \sqexpr{magic(5)}

Fragile command:

\caption{Simulation with $\alpha=\protect\sqexpr{2*3.9}$}


\begin{sysquake} ... \end{sysquake}

Text in the sysquake environment is interpreted verbatim as LME code. All LaTeX constructs are ignored, except for the terminating string \end{sysquake}. Standard output produced by functions like disp and fprintf is inserted in the output, where it is processed by LaTeX.

Remark: the sysquake environment uses the verbatim package. In the beamer class, the [fragile] option should be added to frames where it is used. See below for an example.


In the fragment below, the eigenvalues of a magic square are computed and displayed in a loop. Function fprintf is used to display symbols with and sqlxvalue to format the numbers.

$R$'s eigenvalues $\lambda_i$ are
R = magic(3);
lambda = eig(R);
for i = 1:length(lambda)
  fprintf('\\[ \\lambda_%d = %s \\]\n', i, sqlxvalue(lambda(i)));

\begin{sysquake}(w,h) ... \end{sysquake}

\begin{sysquake}(w,h) starts an environment where sysquake code is evaluated, like \begin{sysquake}. In addition, an EPS file with width w and height h is created with all the output produced by graphical commands the code fragment contains. This EPS is inserted in the LaTeX document in a picture environment with the \includegraphics command of package graphicx.


The fragment below defines a floating figure with the step response of the transfer function 1/(s^3+2s^2+3s+4). We assume the latexingraphics option of the sysquake package, so that text is processed by LaTeX (see above).

step(1, [1,2,3,4]);
legend('$\\psi(t)=\\int_0^\\infty g(\\tau)s(t-\\tau){\\rm d}\\tau$');
\caption{Step response}

Here is an example of a plot in a document with class beamer. Note the use of the option [fragile] required by the frame environment.

\begin{frame}[fragile] \frametitle{Graphics}
fplot(@(x) (x+0.3)^2+7.2*exp(-3*x^2), [-2,3], 'r');