diff --git a/cal_tools/cal_tools/tools.py b/cal_tools/cal_tools/tools.py index 5560953613b32229c0a87e6fbbc6be637933c3c5..eb791019f6f999153743651fda93e2c57688d7cc 100644 --- a/cal_tools/cal_tools/tools.py +++ b/cal_tools/cal_tools/tools.py @@ -173,9 +173,10 @@ def make_timing_summary(run_path, joblist): with open("{}/timing_summary.rst".format(run_path), "w+") as gfile: - table = tabulate.tabulate(pars_vals, tablefmt='latex', - headers=pars_name) - gfile.write(dedent(tmpl.render(table=table.split('\n')))) + if len(pars_vals)>0: + table = tabulate.tabulate(pars_vals, tablefmt='latex', + headers=pars_name) + gfile.write(dedent(tmpl.render(table=table.split('\n')))) def make_report(run_path, tmp_path, out_path, project, author, version, @@ -226,6 +227,7 @@ def make_report(run_path, tmp_path, out_path, project, author, version, with open("{}/conf.py.tmp".format(run_path), "w") as mf: latex_elements = {'extraclassoptions': ',openany, oneside', + 'preamble': r'\usepackage{longtable}', 'maketitle': r'\input{titlepage.tex.txt}'} mf.write("latex_elements = {}\n".format(latex_elements)) mf.write("latex_logo = '{}/{}'\n".format(module_path, diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py index ec2aa7835113a4451aef7f3245f75d9c862bc39d..0cf3139c6967e85c2e7999b23336cd68550a3de5 100755 --- a/xfel_calibrate/calibrate.py +++ b/xfel_calibrate/calibrate.py @@ -532,35 +532,34 @@ def make_par_table(parms, temp_path, run_uuid): :param run_uuid: inset of folder name containing job output """ - # Add space in long strings without line breakers ` ,-` to + # Add space in long strings without line breakers ` ,-/` to # wrap them in latex def split_len(seq, length): - lbc = set(' ,-') + lbc = set(' ,-/') line = '' for i in range(0, len(seq), length): sub_line = seq[i:i + length] - line += sub_line + line += sub_line.replace('/', '/\-') if not any(c in lbc for c in sub_line): - line += ' ' + line += '\-' return line # Prepare strings and estimate their length l_parms = [] len_parms = [0, 0] - max_len = [30, 30] + max_len = [20, 20] for p in parms: name = p.name.replace('_', '-') if len(name) > max_len[0]: len_parms[0] = max_len[0] name = split_len(name, max_len[0]) - value = str(p.value) + value = tex_escape(str(p.value)) if len(value) > max_len[1]: len_parms[1] = max_len[1] value = split_len(value, max_len[1]) if p.type is str: value = "``{}''".format(value) - value = tex_escape(value) comment = tex_escape(str(p.comment)[1:]) l_parms.append([name, value, comment]) @@ -574,16 +573,16 @@ def make_par_table(parms, temp_path, run_uuid): tmpl = Template(''' Input of the calibration pipeline ================================= - - .. math:: - - \\begin{tabular}{ {% for k in p %}{{k}}{%- endfor %} } + + .. raw:: latex + + \\begin{longtable}{ {% for k in p %}{{k}}{%- endfor %} } \hline {% for k in lines %} {{ k[0] }} & {{ k[1] }} & {{ k[2] }} \\\\ {%- endfor %} \hline - \end{tabular} + \end{longtable} ''') f_name = "{}/slurm_tmp_{}/InputParameters.rst".format(temp_path, run_uuid)