Skip to content

Tips for transitioning from .tex to .docx output

Leah Walker edited this page Apr 17, 2026 · 7 revisions

Tips

Got questions about the transition from .tex to .docx output with csasdown?
Here are the top questions and tips for transitioning a resdoc from .tex to .docx.

  1. Pages i-ii:
    Month, report number, ISBN, cat no, and DOI are purposely left blank. Those are filled out at the end by CSAS, which they can now easily do with the .docx.
    So there is no longer a spot in the index.Rmd to fill in these values.

  2. Abstract:
    The abstract is now part of the introduction.Rmd (or could probably be its own .Rmd), it is no longer in the index.Rmd.
    An # ABSTRACT section is required for the report to render.

  3. Page Break:
    Use \newpage instead of \clearpage.

  4. Figures:
    There is currently a bug where the aspect ratio does not get automatically detected. Define the aspect ratio of the figure (i.e., the dimensions) and the size of the figure.
    e.g., fig.width=8, fig.asp=2200/3600.
    fig.width=8 seems to produce a full-width figure (presumably because the default out.width="80%")

  5. Tables:

Most information can be found here:
https://ardata-fr.github.io/flextable-book/index.html

For your ease, here are some commonly used flextable functions.

flextable(table_object) |>  
  #set_table_properties(layout = "autofit") |>         # Do not use if you are defining column width with flextable::width()
  set_caption(caption = "Table caption goes here.") |>  
  set_header_labels(values = c("Column_name_1", "Column_name_2")) |>  # Only need if different than the table_object headers
  width(width = c(4, 3), unit = "cm") |>         # For setting column widths, forces text wrapping, do not need if using "autofit"
  padding(padding.bottom = 5, part = "body") |>        # Good for text tables that need a little space between rows
  align(j = 2, align = "right", part = "body") |>      # Horizontal alignment
  valign(valign = "top", part = "body") |>             # Vertical alignment, defaults to center, use this if you prefer it aligned at the top
  ftExtra::colformat_md()                              # For using Markdown code inside header or body cells (need to install ftExtra package)
  • Currently, formats "year" columns like all other numbers (uses a comma for thousands, e.g., "2,002"). Format "year" columns as.character() to avoid this issue.
  1. Line Break:
    If two tables are printed back-to-back, there is no space between them by default.
    You can add a line break to create a space between the first table and the second table's caption.
    \ <!-- < line break > -->

  2. Landscape pages:
    Landscape pages are tricky... See: https://github.com/pbs-assess/csasdown/issues/24

  3. Equations:
    Equations will not be numbered unless you give them a label (e.g., (\#eq:label))

Clone this wiki locally