title: Simple manual RMarkdown tables that look good in HTML, PDF and DOCX
body: <p>How can I manually and simply format a table in RMarkdown that will look good when converted to HTML (using the knitr and markdown packages), PDF (using pandoc and miktex) and docx (using pandoc)? </p>
  
  <p>I want to be able to write small tables in RMarkdown that are not a result of R functions that look good in the three formats I use most often. So far I've found a format that looks good in 2 of the 3 formats, is 3/3 possible?</p>
  
  <p>One. This looks good after Knit HTML but not good in the PDF or docx</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Eggs&lt;/td&gt;
  &lt;td&gt;Ham&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Basil&lt;/td&gt;
  &lt;td&gt;Tomato&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Two. This one looks good after Knit HTML but not good in the PDF or docx</p>
  
  <pre><code>| Tables        | Are           | Cool  |
  | ------------- |:-------------:| -----:|
  | col 3 is      | right-aligned | $1600 |
  | col 2 is      | centered      |   $12 |
  | zebra stripes | are neat      |    $1 |
  </code></pre>
  
  <p>Three. This one does not look good after Knit HTML but is good in the PDF and docx (best option so far)</p>
  
  <pre><code>V1         Tweedledee       Tweedledum
  --------   --------------   ----------------
  Age        14               14
  Height     3'2"             3'2"
  Politics   Conservative     Conservative
  Religion   "New Age"        Syrian Orthodox
  ---------  --------------   ----------------
  </code></pre>
  
  <p>Four. This looks good after Knit HTML and make PDF and docx (winner!) but is not the manual formatting I'm after. </p>
  
  <pre><code>```{r table1, echo=FALSE, message=FALSE, warnings=FALSE, results='asis'}
  require(pander)
  panderOptions('table.split.table', Inf)
  set.caption("Data on cars")
  pander(mtcars, style = 'rmarkdown')
  ```
  </code></pre>
  
  <p>This is how I'm making the PDF and docx files:</p>
  
  <pre><code>filen &lt;- "table" # name of my RMarkdown file without suffix
  knit(paste0(filen,".Rmd"))
  
  # make PDF
  system(paste0("pandoc -s ", paste0(filen,".md"), " -t latex -o ", paste0(filen,".pdf"), " --highlight-style=tango  -S"))
  
  # make docx
  system(paste0("pandoc -s ", paste0(filen,".md"), " -o ", paste0(filen,".docx"), " --highlight-style=tango  -S"))
  </code></pre>