On Thu, 25 Oct 2012 20:02:22 +0200, Otared Kavian
Hi Philipp,
Thanks to you, Dalyoung and Hans for the nice example using luacode. I was wonedring how would you modify your code in order to be able to change the name of the matrix if necessary. For instance, how to modify your code in such a way that upon saying \ctxlua{document.print_matrix(b,3)} one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}.
Thanks in advance: OK
Something like this?
································································· document.print_matrix = function (x, y, name) local name = name or "a" if not y then y = x end -- default to square context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"} local schema = name .. "_{%d%d}" -- %d: prints integer part for i=1, x do for j=1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end ·································································
Call with: \ctxlua{document.print_matrix(3, 3, "b")} Best regards, Lukas