PDF creator#

This class mangaes PDF creation via LaTeX.

class PDFviaLaTeX(fname, package=[], style='normal', pt=10, no_page=False, landscape=False, english=False, dir='')[source]#

Bases: object

PDF creator class.

Parameters:
  • fname (str) – file name without “.tex”.

  • package (list, optional) – package [(name,option)].

  • style (str, optional) – margin style (narrowest/narrow/normal/wide/widest).

  • pt (int, optional) – default point (8/9/10/11/12/14).

  • no_page (bool, optional) – no page number ?

  • landscape (bool, optional) – landscape ?

  • english (bool, optional) – english mode ?

  • dir (str, optional) – output directory.

build()[source]#

Create PDF.

equation(eqs, num=False, long=False)[source]#

Add equation.

Parameters:
  • eqs (str or list) – equation or list of eqs.

  • num (bool, optional) – with eq. number ?

  • long (bool, optional) – long eq. ? (single eq. only).

figure(fname, width=0.8, pos='c', caption='')[source]#

Add figure (not in the figure environment, if caption is empty).

Parameters:
  • fname (str) – file name of figure.

  • width (float, optional) – figure width relative to page width.

  • pos (str, optional) – position (c/l/r) (center/left/right).

  • caption (str, optional) – caption of figure.

simple_table(tbl, cols=None, cpos=None, tmath=False)[source]#

Add simple table.

Parameters:
  • tbl (list) – content of table (1d or 2d).

  • cols (int, optional) – number of columns.

  • cpos (str, optional) – position of each cols. default is center.

  • tmath (bool, optional) – math mode ?

table(tbl, row, col, rc='', hl=[], caption='', stretch=1.0, cpos=None, rcmath=False, rmath=False, cmath=False, tmath=False, long=False, center=True)[source]#

Add table (reshaped by using number of col).

Parameters:
  • tbl (list) – content of table [[str]].

  • row (list) – row name [str].

  • col (list) – column name [str].

  • rc (str, optional) – row-col name.

  • hl (list, optional) – position with horizontal line [int]. if True, use horizontal lines for all lines.

  • caption (str, optional) – table caption.

  • stretch (float, optional) – baseline stretch (ratio).

  • cpos (str, optional) – column position. default is center.

  • rcmath (bool, optional) – math mode for row-col name ?

  • rmath (bool, optional) – math mode for row name ?

  • cmath (bool, optional) – math mode for column name ?

  • tmath (bool, optional) – math mode for table ?

  • long (bool, optional) – long table ?

  • center (bool, optional) – centering ?

text(content='')[source]#

Add text.

Parameters:

content (str or list, optional) – text.

title(title, size='LARGE', pos='c')[source]#

Add title.

Parameters:
  • title (str) – title.

  • size (str, optional) – font size (large/Large/LARGE/Huge).

  • pos (str, optional) – position (c/l/r) (center/left/right).

list_to_table(lst1d, col, p=None)[source]#

Convert from list to table.

Parameters:
  • lst1d (list) – 1d list.

  • col (int) – number of columns.

  • p (any, optional) – padding value (no padding for None).

Returns:

  • (list) – 2d list.

regularize_table(lst2d, padding=None)[source]#

Regularize an irregular table.

Parameters:
  • lst2d (list) – 2d list with different number of columns.

  • padding (any, optional) – padding value.

Returns:

  • (list) – regularized 2d list.

wrap_string(a, left='', right='')[source]#

Wrap array elementwise with left and right strings.

Parameters:
  • a (array-like) – array.

  • left (str, optional) – left string to wrap.

  • right (str, optional) – right string to wrap.

Returns:

  • (array-like) – wrapped array.