Ejemplo n.º 1
0
def figuretable(rows, cols, placement="t", label=None, caption=None):
    if label is None:
        label = randomref()

    Context.variables['cell'] = np.array([[Context(myparent=Context.context, indent=Context.context.indent+4) for c in range(0, cols)] for r in range(0, rows)], dtype=Context)

    latex("\\begin{figure*}[%s]" % (placement))

    Context.context.add()

    #latex("\hline")
    for r in range(0, rows):
        for c in range(0, cols):
            Context.variables['cell'][r, c].add()
        latex("\\\\")

    if not caption is None:
        latex("\caption{%s}" % caption)
        BookKeeping.add_label(label, "figure")

    latex("\label{%s}" % label)
    latex("\end{figure*}")

    return label
Ejemplo n.º 2
0
def figure(image, caption=None, label=None, placement="t", scale=1.0):
    if label is None:
        label = randomref()

    latex("\\begin{figure}[%s]" % (placement))

    Context.context.add()

    includegraphics(image, scale)

    if not caption is None:
        latex("\caption{%s}" % caption)
        BookKeeping.add_label(label, "figure")

    latex("\label{%s}" % label)
    latex("\end{figure}")

    return label
Ejemplo n.º 3
0
def latexblock(blockname, full_width=False, label=None):
    if label is None:
        label = randomref()
    if full_width:
        blockname.append('*')
    latex("\\begin{%s}" % blockname)
    Context.context.add()
    latex("\label{%s}" % label)
    latex("\end{%s}" % blockname)
    BookKeeping.add_label(label, "equation")
    return label
Ejemplo n.º 4
0
def subfigure(image, caption=None, label=None, placement="t", scale=1.0, width=None):
    if label is None:
        label = randomref()

    if width is None:
        width = str(1.0/Context.variables['cols']-0.01) + "\\textwidth"

    latex("\\begin{subfigure}[%s]{%s}" % (placement, width))

    Context.context.add()

    includegraphics(image, scale)

    if not caption is None:
        latex("\caption{%s}" % caption)

    latex("\label{%s}" % label)
    latex("\end{subfigure}")

    #BookKeeping.add_label(label, "figure") # we should get this by getting the ref of parent, i.e. figuretable
    return label
Ejemplo n.º 5
0
def item():
    latex("\item")
    Context.context.add()
Ejemplo n.º 6
0
def end_document():
    latex("\end{document}")
Ejemplo n.º 7
0
def begin_document():
    latex("\\begin{document}")
Ejemplo n.º 8
0
def documentclass(documenttype):
    latex("\documentclass{%s}" % documenttype)
Ejemplo n.º 9
0
def make_title(title, author):
    latex("\\title{%s}" % title)
    latex("\\author{%s}" % author)
    latex("\maketitle")
Ejemplo n.º 10
0
def center():
    latex("\center")
Ejemplo n.º 11
0
def includegraphics(image, scale=1.0):
    latex("\includegraphics[scale=%f]{%s}" % (scale, image))
Ejemplo n.º 12
0
def table(rows,
          cols,
          width="\textwidth",
          placement="t",
          caption=None,
          label=None):

    if label is None:
        label = randomref()

    Context.variables['cell'] = np.array([[
        Context(myparent=Context.context, indent=Context.context.indent + 4)
        for c in range(0, cols)
    ] for r in range(0, rows)],
                                         dtype=Context)
    #Context.variables['rows'] = rows
    #Context.variables['cols'] = cols

    latex("\\begin{table*}[%s]" % placement)
    Context.context.add()
    latexl("\\begin{tabular}{|c")
    for c in range(1, cols):
        latexl("|c")
    latex("|}")

    #context.evaluate()
    latex("\hline")
    for r in range(0, rows):
        for c in range(0, cols):
            Context.variables['r'] = r
            Context.variables['c'] = c
            Context.variables['cell'][r, c].add()
            if c < cols - 1:
                latexl("&")
        latex("\\\\ \hline")
    latex("\end{tabular}")
    maybe_caption(caption)
    latex("\label{%s}" % label)
    latex("\end{table*}")

    if caption is not None:
        BookKeeping.add_label(label, "table")
    return label
Ejemplo n.º 13
0
def raggedleft():
    latex("\\raggedleft")
Ejemplo n.º 14
0
def raggedright():
    latex("\\raggedright")
Ejemplo n.º 15
0
def add_bibliography(bibfile, bibstyle):
    latex("\\bibliography{%s}" % bibfile)
    latex("\\bibliographystyle{%s}" % bibstyle)
Ejemplo n.º 16
0
def url(url_string):
    latex("\url{%s}" % url_string)
Ejemplo n.º 17
0
 def __init__(self, name, nesting=0):
     self.name = name
     self.nesting = nesting
     subsub = "sub" * self.nesting + "section"
     BookKeeping.add_label(name, subsub)
     latex("\\" + subsub + "{%s}" % self.name)
Ejemplo n.º 18
0
def centering():
    latex("\centering")