forked from caenrigen/LatexKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Create Manual String.js
39 lines (31 loc) · 937 Bytes
/
Create Manual String.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function create_manual_string(spec) {
// Get the arguments from object spec
var range = spec.range;
var matrix = spec.matrix;
var colFeats = spec.colFeats;
var new_range = range.offset(-1, range.getNumColumns() , range.getNumRows()+1 , 1)
var new_range_value = new_range.getValues();
var manualColSpec = spec.manualColSpec;
var output = '';
var colAlign = '';
if(manualColSpec !== ''){
// Use users specification in case the cell above the table corner is
// not empty
colAlign = manualColSpec;
} else {
colAlign = columns_align(colFeats);
}
output += "\\begin{tabular}";
output += "{" + colAlign + "}\r\n" + new_range_value[0][0] + '\r\n';
var i,j;
for(i=0;i<matrix.length;i++)
{
for(j=0;j<matrix[i].length;j++)
{
output+=matrix[i][j].pvalue;
}
output+='\\\\' + new_range_value[i+1][0] + '\r\n';
}
output+= "\\end{tabular}\r\n";
return output;
}