Please use code blocks, otherwise this is very complicated to copy-paste the code you are posting (see https://scilab.discourse.group/t/welcome-to-the-scilab-discourse-forum).
Likely, you didn’t understand the different mechanisms in place: you don’t have to call yourself table2latex
(it is automatically called by prettyprint
). So the whole code of your example should be:
function str = table2latex(t)
[_,m] = size(t);
head = strcat(t.props.VariableNames," & ") + " \\ "
data = strcat(strcat(string(t)," & ","c")," \\ ")
str = [ sprintf("\\begin{tabular}{%s}",strcat("r"(ones(1,m)),"|"))
head; "\hline"; data; "\end{tabular}" ];
str = strcat(str," ");
endfunction
WI.school=["BHF","FFHS","FHNW","HEIG-VD","HSLU","SUPSI","OST","ZHAW"];
WI.place=["Quellgasse 21 2501 Biel","Schinerstrasse 18 3900 Brig","Bahnhofstrasse 6 5210 Windisch","Route de Cheseaux 1, 1400 Yverdon-les-Bains","Technikumstrasse 21 6048 Horw","Via la Santa 1 6962 Lugano-Viganello","Rosenbergstrasse 59 9000 St.Gallen","Technikumstrasse 9 8400 Winterthur"];
WI.teacher=["Prof. Dr. Stefan Grösser","CAO Simon Ruff","Prof. Jörg Lageman","Prof. Jean-Michel Schulz","Prof. Thomas Schwank","Prof. Paolo Pedrazzoli","Prof. Sonderegger Urs","Prof. Dr. Richard Bödi"];
Table_WI=struct2table(WI);
pp = prettyprint(Table_WI)
titlepage(pp)
gce().interpreter = "latex"
The alignment of strings within the columns can be changed, e.g. if you want to center strings just change "r"
line 6 of table2latex
by "c"
(center) or "l"
(left).