Module: Export::TeX

Defined in:
lib/cless/export.rb

Constant Summary collapse

Questions =
[]

Class Method Summary collapse

Class Method Details

.export(io, nb_col, lines, headers, opts = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cless/export.rb', line 64

def self.export(io, nb_col, lines, headers, opts = {})
  io << "\\begin{tabular}{|" << (["c"] * nb_col).join("|") << "|}\\hline\n"
  if headers
    io << headers.join(" & ") 
    io << "\\tabularnewline\\hline\\hline\n"
  end
  lines.each { |a|
    a.map! { |t| t && t.gsub(/\&/, '\&').gsub(/\\/, "\\textbackslash{}") }
    io << a.join(" & ") << "\\tabularnewline\\hline\n"
  }
  io << "\\end{tabular}\n"
end