Next: version-handling, Previous: statistics, Up: Directory Index [Contents][Index]
Build a TeX table from a cell array specification.
TeX table as a string
table specification
numfmt
num2TeX() format for formatting numbers [default: "g"]
tblwidth
TeX command specifying table width [optional]
fillcols
space-filling columns: "first", "all", "byrow" or "none" [default]
fillcolrow
which row to use when setting space-filling columns with "byrow"
defcolsep
default non-space-filling column separation [default: 1]
The table specification spec is a 1-D cell array of rows, the elements of which are 1-D cell arrays of columns. Further nesting of cell arrays may be used to set up elements which span multiple columns. TeX numbers containing periods are split into 2 columns to align numbers at the period.
Run demo buildTeXTable
for some examples.
buildTeXTable({{1, 2, 3}, {4, 5, 6}})
buildTeXTable({"\\hline", {1, 2.2, 3}, {4, 5, 6}, "\\hline"})
buildTeXTable({"\\hline", {[], "A", "B"}, {[], {"A1", "A2"}, "B"}, "\\hline", {"x", {1, 2.2}, 3}, {"y", {4, 5}, 6}, "\\hline"})
Format a number in TeX format.
cell array of TeX strings (or string if numel(num) == 1)
any-dimensional array of numbers
printf()-style format string, without the leading %
prefix
": string to add at start of TeX string (default: "")
suffix
": string to add at end of TeX string (default: "")
dollar
symbol to wrap TeX string with (default: "$")
times
TeX symbol to use for times (default: "{\times}")
infstr
TeX string to use for infinity (default: "\infty")
nanstr
TeX string to use for not-a-number (default: "\mathrm{NaN}")
dbslash
double backslash characters, i.e. replace "\" with "\\"
assert(num2TeX([1.234, 5.67e-8], "g"), {"$1.234$", "$5.67{\\times}10^{-8}$"})
This function returns a valid json string that will describe object The string will be in a compact form (i.e. no spaces or line breaks)
It will map simple octave values this way:
String with the name of the function.
depends: if it’s real it will map to a string representing that number. if it’s complex it will map to an object with the next properties:
real part of the number
imaginary part of the number
A string enclosed by double quotes representing that character
And will map more complex octave values this other way:
an object with properties equal to the struct’s field names and value equal to the json counterpart of that field
it will be mapped depending on the value of the cell (for example {i} will be mapped to an object with real=0 and imag=1)
it will map them to a corresponding js array (same size) with the values transformed to their json counterpart (Note: that in javascript all arrays are like octave’s cells ,i.e. they can store different type and size variables) strings or char vectors: they will be mapped to the same string enclosed by double quotes
Other octave values will be mapped to a string enclosed by double quuotes with the value that the class() function returns It can handle escape sequences and special chars automatically. If they’re valid in JSON it will keep them if not they’ll be escaped so they can become valid
assert(object2json({1.234, 2.345}), '[1.234,2.345]')
assert(object2json({1.234, 2.345, "abcd"}), '[1.234,2.345,"abcd"]')
assert(object2json(struct("abcd", 1.234)), '{"abcd":1.234}')
Convert an Octave value x into a string expression, which can be re-used
as input, i.e. eval(stringify(x))
should re-create x.
x = [1 2 3.4; 5.67 8.9 0]; assert(isequal(x, eval(stringify(x))));
x = int32([1 2 3 7]); assert(isequal(x, eval(stringify(x))));
x = [true; false]; assert(isequal(x, eval(stringify(x))));
x = "A string"; assert(isequal(x, eval(stringify(x))));
x = @(y) y*2; assert(x(7) == eval(stringify(x))(7));
x = {1, 2, "three"; 4, 5, {6}}; assert(isequal(x, eval(stringify(x))));
x = {1, 2, "three", {4, 5, {6}, true}, 7, false, int16(9)}; assert(isequal(x, eval(stringify(x))));
x = struct("Hi","there","where", 2,"cell",{1,2,3,{4*5,6,{7,true}}}); assert(isequal(x, eval(stringify(x))));
Join the cell array of strings cstr using the separator sep and return the joined string.
assert(strcmp(strjoin({"a"},","), "a"))
assert(strcmp(strjoin({"a","b","c"},","), "a,b,c"))
assert(strcmp(strjoin({" a","b "," c "},","), " a,b , c "))
Next: version-handling, Previous: statistics, Up: Directory Index [Contents][Index]