import os,sys import random parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0,parentdir) from texifier import structure as s from texifier import texdocument if not os.path.exists("output"): os.makedirs("output") # instantiate a new document, specifying its title and the name # of the author d = texdocument(author="Simone Mainardi", title="Yet Another \LaTeX{} report") # generate some random content randomcontent = ''.join(random.choice(' asd.,') for i in xrange(1000)) # create a section named "One section" containing the previously # generated random content d.append(s.section("One section", randomcontent)) # create another section d.append(s.section("Another Section", randomcontent)) print d.get_tex() # write the pdf file d.generate_pdf("output/simple_report.pdf")
d.append(s.abstract(randomcontent)) # add the table of contents d.append(s.tableofcontents()) # add the list of tables d.append(s.listoftables()) # add the list of figures d.append(s.listoffigures()) # create five sections, each one with an image, a table and three subsections for sec in xrange(5): # add the section ... d.append(s.section("Senseless Section %i" % (sec + 1), randomcontent)) # ... the image d.append(s.image("images/a_graph.eps", "This is the senseless graph of Section %i" % (sec+1), "width=.96\\textwidth")) # ... the table ncols = random.randint(2,5) nrows = random.randint(10,20) heads = ["Property %i"%i for i in xrange(ncols)] rows = [[random.randint(0,i) for i in xrange(ncols)] for c in xrange(nrows)] # the table has (or has not) headers: if random.randint(0,1): # with headers