John Blischak Adjust the width of the verbatim code blocks so that the text fits on the page.  over 8 years ago

Commit id: 0950dc240cb6c31c577a43d13e5ea03f68d84851

deletions | additions      

       

import textwrap  import glob  def write_file(fname, blankline = 1): 1, code_adjust = -0.5):  """Write contents of file to standard out.  Args:  fname - the filename (str)  blankline - the number of blank lines to add after the text (int)  code_adjust - the number of inches to adjust the width of the code  blocks (float)  """  handle = open(fname, "r")  for line in handle:  if "Table 1" in line:  line = line.replace("Table 1", "Table \\ref{tab:resources}")  if "begin{verbatim}" in line:  sys.stdout.write("\\begin{adjustwidth}{%.2fin}{0in}\n"%(code_adjust))  sys.stdout.write(line)  if "end{verbatim}" in line:  sys.stdout.write("\\end{adjustwidth}\n")  handle.close()  sys.stdout.write("\n" * blankline)  def write_figure(caption, label):  """Write labeled figure with the provided caption.