3

I am trying to create a publication quality table, that describes the variables I have used in the analysis. Thus the table has two columns and say 20 rows. The first column is short as it contains the variable name and the second column is rather long as it gives the explanation of the variable.

I want the following:
- sideways table, aka horizontally rotated
- fits to one page (letter or a4)
- automatically breaks lines in column 2 to adjust for long descriptions (to not have text flowing "over the page")

I have tried both pander::pandoc.table and xtable. They only get me to 80% of the way. with pander I can get adjustable cell heights but not a rotated table and with stable I get a rotated table, but the table does not fit one page.

Here is the code so far:
print(xtable::xtable(variablesused, auto = TRUE, caption = "Variable Definitions"), floating = TRUE, floating.environment = "sidewaystable", sanitize.text.function = force, include.rownames = FALSE)

I don't want to use scale box, as this would just make the overall table smaller. With line breaks in the second column and correspondingly "bigger" rows the table would look perfect.

Thank you so much!

  • If you want to heavily customize how a table is rendered in PDF, then it's better to generate LaTeX (eg `xtable`) and forget about markdown (like `pander` or `kable`). What I try to say is that I think your question is more of LaTeX than R markdown. – daroczig Feb 27 '17 at 23:36
  • I am fine with using xtable and LaTex output, but still the above gets me a long way (sideways table +, nice alignment + ) but not the whole way. xtable does not create a table that fits on one letter/a4 page where the second column has a fixed length and breaks lines accordingly – thoughtsnippet Feb 28 '17 at 10:07

0 Answers0