R DT::Tufte html输出中主列中的datatable

R DT::Tufte html输出中主列中的datatable,r,dt,bookdown,tufte,R,Dt,Bookdown,Tufte,我试图使用Bookdown和knitr包将DT::datatable包含在Tufte html文档中。但是,即使我使用culomnDefs选项设置列的宽度,或者使用kintr 使用fig.fullwidth=FALSE或out.with='50%'选项输出,DT::datatable仍沿页面、主列和边距列的全宽显示!如下图所示,DT::datatable位于柱状图下方,但它应该仅放在主列中它的旁边 我的问题很简单,您知道如何仅在Tufte html书籍的主列中显示DT::datatable?您可

我试图使用
Bookdown
knitr
包将
DT::datatable
包含在Tufte html文档中。但是,即使我使用
culomnDefs
选项设置列的宽度,或者使用
kintr
使用
fig.fullwidth=FALSE
out.with='50%'
选项输出,
DT::datatable
仍沿页面、主列和边距列的全宽显示!如下图所示,
DT::datatable
位于柱状图下方,但它应该仅放在主列中它的旁边

我的问题很简单,您知道如何仅在Tufte html书籍的主列中显示
DT::datatable
?您可能会看到生成
DT::datatable

非常感谢你的帮助

如中所述,使用
DT::datatable()
中的width参数将实现以下功能:

DT::datatable(虹膜,宽度=55%,选项=list(scrollX=TRUE))
```{r high-range-cv, echo = FALSE, fig.fullwidth = FALSE}
sketch = htmltools::withTags(table(
  class = 'display',
  thead(
    tr(
      th(rowspan = 2, 'Indicator'),
      th(colspan = 2, 'Highest Variability'),
      th(colspan = 2, 'Lowest Variability')
    ),
    tr(
      lapply(rep(c('Country', 'CV'), 2), th),
      th("Diff")
    )
  )
))

diff_ind %>%
  select(ind_name, max_cty, max, min_cty, min, diff) %>%
  datatable(colnames = c("Indicator", "Country", "Max", "Country", "Min", "Diff"),
            container = sketch,
            rownames = FALSE,
            filter = 'top', 
            extensions = 'FixedColumns',
            options = list(pageLength = 6,
                           autowidth = TRUE,
                           columnDefs = list(list(width = '50px', targets = c(2, 4, 5)),
                                              list(width = '100px', targets = c(1, 3)),
                                              list(width = '300px', targets = 0)
                           ),
                           scrollX = TRUE,
                           fixedColumns = TRUE)) %>%
  formatRound(c("max", "min", "diff") , 2)
```