document_contents.tex.j2 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ((*- extends 'display_priority.j2' -*))
  2. %===============================================================================
  3. % Support blocks
  4. %===============================================================================
  5. % Displaying simple data text
  6. ((* block data_text *))
  7. \begin{Verbatim}[commandchars=\\\{\}]
  8. ((( output.data['text/plain'] | escape_latex | ansi2latex )))
  9. \end{Verbatim}
  10. ((* endblock data_text *))
  11. % Display python error text with colored frame (saves printer ink vs bkgnd)
  12. ((* block error *))
  13. \begin{Verbatim}[commandchars=\\\{\}, frame=single, framerule=2mm, rulecolor=\color{outerrorbackground}]
  14. (((- super() )))
  15. \end{Verbatim}
  16. ((* endblock error *))
  17. % Display error lines with coloring
  18. ((*- block traceback_line *))
  19. ((( line | escape_latex | ansi2latex )))
  20. ((*- endblock traceback_line *))
  21. % Display stream ouput with coloring
  22. ((* block stream *))
  23. \begin{Verbatim}[commandchars=\\\{\}]
  24. ((( output.text | escape_latex | ansi2latex )))
  25. \end{Verbatim}
  26. ((* endblock stream *))
  27. % Display latex
  28. ((* block data_latex -*))
  29. ((( output.data['text/latex'] | strip_files_prefix )))
  30. ((* endblock data_latex *))
  31. % Display markdown
  32. ((* block data_markdown -*))
  33. ((( output.data['text/markdown'] | citation2latex | strip_files_prefix | convert_pandoc('markdown+tex_math_double_backslash', 'latex'))))
  34. ((* endblock data_markdown *))
  35. % Default mechanism for rendering figures
  36. ((*- block data_png -*))((( draw_figure(output.metadata.filenames['image/png']) )))((*- endblock -*))
  37. ((*- block data_jpg -*))((( draw_figure(output.metadata.filenames['image/jpeg']) )))((*- endblock -*))
  38. ((*- block data_svg -*))((( draw_figure(output.metadata.filenames['image/svg+xml']) )))((*- endblock -*))
  39. ((*- block data_pdf -*))((( draw_figure(output.metadata.filenames['application/pdf']) )))((*- endblock -*))
  40. % Draw a figure using the graphicx package.
  41. ((* macro draw_figure(filename) -*))
  42. ((* set filename = filename | posix_path *))
  43. ((*- block figure scoped -*))
  44. \begin{center}
  45. \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{((( filename )))}
  46. \end{center}
  47. { \hspace*{\fill} \\}
  48. ((*- endblock figure -*))
  49. ((*- endmacro *))
  50. % Redirect execute_result to display data priority.
  51. ((* block execute_result scoped *))
  52. ((* block data_priority scoped *))
  53. ((( super() )))
  54. ((* endblock *))
  55. ((* endblock execute_result *))
  56. % Render markdown
  57. ((* block markdowncell scoped *))
  58. ((( cell.source | citation2latex | strip_files_prefix | convert_pandoc('markdown+tex_math_double_backslash', 'json',extra_args=[]) | resolve_references | convert_explicitly_relative_paths | convert_pandoc('json','latex'))))
  59. ((* endblock markdowncell *))
  60. % Don't display unknown types
  61. ((* block unknowncell scoped *))
  62. ((* endblock unknowncell *))