(matrix) ¶(matrix, params, …) ¶Save matrix in LaTeX format (tabular or array).
The input matrix must be numeric and two dimensional.
The generated LaTeX source can be saved directly to a file with the option
file. The file can then be inserted in any latex document by using
the \input{latex file name without .tex} statement.
Available parameters are:
file: filename to save the generated LaTeX source. Requires a string
as value.
rlines: display row lines.
clines: display column lines.
align: column alignment. Valid values are ‘l’, ‘c’ and ‘r’ for
center, left and right (default).
math: create table in array environment inside displaymath
environment. It requires a string as value which will be the name of the matrix.
The basic usage is to generate the source for a table without lines and right alignment (default values):
textable (data)
⇒
\begin{tabular}{rrr}
0.889283 & 0.949328 & 0.205663 \\
0.225978 & 0.426528 & 0.189561 \\
0.245896 & 0.466162 & 0.225864 \\
\end{tabular}
Alternatively, the source can be saved directly into a file:
textable (data, "file", "data.tex");
The appearance of the table can be controled with switches and key values. The following generates a table with both row and column lines (rlines and clines), and center alignment:
textable (data, "rlines", "clines", "align", "c")
⇒
\begin{tabular}{|c|c|c|}
\hline
0.889283 & 0.949328 & 0.205663 \\
\hline
0.225978 & 0.426528 & 0.189561 \\
\hline
0.245896 & 0.466162 & 0.225864 \\
\hline
\end{tabular}
Finnally, for math mode, it is also possible to place the matrix in an array environment and name the matrix:
textable (data, "math", "matrix-name")
⇒
\begin{displaymath}
\mathbf{matrix-name} =
\left(
\begin{array}{*{ 3 }{rrr}}
0.889283 & 0.949328 & 0.205663 \\
0.225978 & 0.426528 & 0.189561 \\
0.245896 & 0.466162 & 0.225864 \\
\end{array}
\right)
\end{displaymath}
See also: csv2latex, publish.
The following code
A = [1 2 3; 4 5 6]; textable (A)
Produces the following output
ans = \begin{tabular}{rrr}
1 & 2 & 3 \\
4 & 5 & 6 \\
\end{tabular}
Package: miscellaneous