2

I tried the following rmarkdown code, but with no success:

---
title: 
output: 
  pdf_document:
    latex_engine: pdflatex
header-includes:
   \usepackage{multicol}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(huxtable)
```
    
```{r echo=FALSE, results='asis'}
m <- rbind(c("A","B"),
           c("C","D"))

ht <- huxtable(m)
```

\begin{multicols}{2}
\begin{enumerate}
\item `r ht`
\item `r ht`
\item `r ht`
\item `r ht`
\end{enumerate}
\end{multicols}

No table is shown as output.

Any help would be greatly appreciated. Thanks!

PaulS
  • 21,159
  • 2
  • 9
  • 26
  • If you render it to TeX, you can see what the output looks like. That may help for debugging. I think you'd be lucky to make a whole table work inside a multicol/item environment, but I'm not certain. – dash2 Jun 28 '21 at 20:29
  • Thanks, @dash2. I have just tried the creation of the table inside `multicol` environment, but with no luck. From what I have researched, the problem is caused because `huxtable` uses the float `table` environment, which is incompatible with `multicol`. Maybe from `huxtable` side there is nothing that can be done to improve the situation. – PaulS Jun 28 '21 at 22:57
  • You could try the `tabular_only` argument to `to_latex()`. (You'd probably be the first person ever to use that argument, so see how it goes...) – dash2 Jun 30 '21 at 08:08
  • Thanks, but it did not go well. The LaTeX code generated by `to_latex()` still contains `\begin{table}[ht]`. Moreover, there is a LaTeX error: `! LaTeX Error: Environment centerbox undefined.`, maybe caused because some package needs to be installed in my LaTex distribution. – PaulS Jun 30 '21 at 10:36
  • Moreover, there is a LaTeX error: `! Undefined control sequence. l.137 \arrayrulecolor {black}`, despite the fact that `huxtable` uses the package `xcolor`. – PaulS Jun 30 '21 at 11:39
  • You will probably need to manually add the relevant packages to your preamble if you are only using `tabular_only`. See `?report_latex_dependencies` for how. – dash2 Jul 08 '21 at 16:01
  • Thanks, but the problem is that `huxtable` still uses `\begin{table}[ht]` under `tabular_only` and floats are incompatible with `multicol` package! – PaulS Jul 11 '21 at 14:26
  • hmm. On the face of it that sounds like a bug, please report. – dash2 Jul 12 '21 at 20:01
  • Thanks! Done: https://github.com/hughjonesd/huxtable/issues/210 – PaulS Jul 22 '21 at 13:58

0 Answers0