Tools for generating Latex code fragments
The latex-tools gem is a collection of classes that facilitate the writing of various elements of Latex code. It is not designed for authoring entire Latex files, merely their component parts. Right now, it only consists of one such ‘tool’, LatexTable, which provides an easy and convenient way of outputting Latex code for tables from data in a ruby script.
Install the gem just like any other gem:
gem install latex-tools
The classes (right now only LatexTable) should be documented well enough to get started, but individual class methods are mostly undocumented. This documentation will (hopefully) be added in the future.
The LatexTools module wraps everything in this package. For convenience of use (i.e. unless you have a good reason not to do so), you should include the following line at the beginning of your source code:
include LatexTools
Not doing so will result in much more verbose and much harder to read code, which is not how this module was intended to be used. For instance, when the module is included properly, use of the LatexTable class becomes quite clean and “c++ like”:
t = LatexTable.new(3) t << " " << "Height" << "Weight" << endl t << hline t << "Person 1" << '156 cm' << '55 kg' << endl t << "Person 2" << '183 cm' << '62 kg' << endl t << hline t.to_s
(See the LatexTable class documentation for more.)
# File lib/latex_table.rb, line 576
576: def cline(begincol, endcol)
577: return LatexTable::Cline.new(begincol, endcol)
578: end
# File lib/latex_table.rb, line 560
560: def fill_to_end(alignment_or_content, content = nil)
561: if(content.nil?)
562: return LatexTable::MultiColumn.new(:fill, :c, alignment_or_content)
563: else
564: return LatexTable::MultiColumn.new(:fill, alignment_or_content, content)
565: end
566: end
# File lib/latex_table.rb, line 568
568: def hline
569: :hline
570: end
# File lib/latex_table.rb, line 551
551: def multicolumn(ncol, alignment_or_content, content = nil)
552: if(content.nil?)
553: return LatexTable::MultiColumn.new(ncol, :c, alignment_or_content)
554: else
555: return LatexTable::MultiColumn.new(ncol, alignment_or_content, content)
556: end
557: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.