Module: IRuby::LaTeX
Instance Method Summary collapse
Instance Method Details
#matrix(m, row_count, column_count) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/iruby/formatter.rb', line 11 def matrix(m, row_count, column_count) s = "$$\\left(\\begin{array}{#{'c' * column_count}}\n" (0...row_count).each do |i| s << ' ' << m[i,0].to_s (1...column_count).each do |j| s << '&' << m[i,j].to_s end s << "\\\\\n" end s << "\\end{array}\\right)$$" end |
#vector(v) ⇒ Object
5 6 7 8 9 |
# File 'lib/iruby/formatter.rb', line 5 def vector(v) x = 'c' * v.size y = v.map(&:to_s).join(' & ') "$$\\left(\\begin{array}{#{x}} #{y} \\end{array}\\right)$$" end |