latex_table.tpl 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {% if environment or parse_wrap(table_styles, caption) %}
  2. \begin{% raw %}{{% endraw %}{{environment if environment else "table"}}{% raw %}}{% endraw %}
  3. {%- set position = parse_table(table_styles, 'position') %}
  4. {%- if position is not none %}
  5. [{{position}}]
  6. {%- endif %}
  7. {% set position_float = parse_table(table_styles, 'position_float') %}
  8. {% if position_float is not none%}
  9. \{{position_float}}
  10. {% endif %}
  11. {% if caption and caption is string %}
  12. \caption{% raw %}{{% endraw %}{{caption}}{% raw %}}{% endraw %}
  13. {% elif caption and caption is sequence %}
  14. \caption[{{caption[1]}}]{% raw %}{{% endraw %}{{caption[0]}}{% raw %}}{% endraw %}
  15. {% endif %}
  16. {% for style in table_styles %}
  17. {% if style['selector'] not in ['position', 'position_float', 'caption', 'toprule', 'midrule', 'bottomrule', 'column_format'] %}
  18. \{{style['selector']}}{{parse_table(table_styles, style['selector'])}}
  19. {% endif %}
  20. {% endfor %}
  21. {% endif %}
  22. \begin{tabular}
  23. {%- set column_format = parse_table(table_styles, 'column_format') %}
  24. {% raw %}{{% endraw %}{{column_format}}{% raw %}}{% endraw %}
  25. {% set toprule = parse_table(table_styles, 'toprule') %}
  26. {% if toprule is not none %}
  27. \{{toprule}}
  28. {% endif %}
  29. {% for row in head %}
  30. {% for c in row %}{%- if not loop.first %} & {% endif %}{{parse_header(c, multirow_align, multicol_align, siunitx, convert_css)}}{% endfor %} \\
  31. {% endfor %}
  32. {% set midrule = parse_table(table_styles, 'midrule') %}
  33. {% if midrule is not none %}
  34. \{{midrule}}
  35. {% endif %}
  36. {% for row in body %}
  37. {% for c in row %}{% if not loop.first %} & {% endif %}
  38. {%- if c.type == 'th' %}{{parse_header(c, multirow_align, multicol_align, False, convert_css)}}{% else %}{{parse_cell(c.cellstyle, c.display_value, convert_css)}}{% endif %}
  39. {%- endfor %} \\
  40. {% if clines and clines[loop.index] | length > 0 %}
  41. {%- for cline in clines[loop.index] %}{% if not loop.first %} {% endif %}{{ cline }}{% endfor %}
  42. {% endif %}
  43. {% endfor %}
  44. {% set bottomrule = parse_table(table_styles, 'bottomrule') %}
  45. {% if bottomrule is not none %}
  46. \{{bottomrule}}
  47. {% endif %}
  48. \end{tabular}
  49. {% if environment or parse_wrap(table_styles, caption) %}
  50. \end{% raw %}{{% endraw %}{{environment if environment else "table"}}{% raw %}}{% endraw %}
  51. {% endif %}