首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >kableExtra::kbl用于乳胶输出的脚注中没有缩进

kableExtra::kbl用于乳胶输出的脚注中没有缩进
EN

Stack Overflow用户
提问于 2021-12-09 15:52:13
回答 2查看 225关注 0票数 2

我正在尝试删除用kableExtra创建的表的脚注部分中的缩进。我假设缩进来自在注释开始之前的\item函数(参见latex输出)。有人能帮我移除这个缩痕吗。便条中的\item前缀?

代码语言:javascript
运行
复制
library(dplyr)
library(kableExtra)

data(mtcars)
tab_data <- mtcars[1:5, 1:3]

cat(
  kbl(
    x = tab_data,
    format = "latex",
    booktabs = TRUE,
  ) %>%
    kable_styling(full_width = FALSE) %>%
    footnote(
      general = "Here is a note of the table. It is very long and I would want to remove this ugly indention on the left side of the table notes. ",
      general_title = "",
      threeparttable = TRUE
    )
)

在这里,乳胶输出:

代码语言:javascript
运行
复制
\begin{table}
\centering
\begin{threeparttable}
\begin{tabular}[t]{lrrr}
\toprule
  & mpg & cyl & disp\\
\midrule
Mazda RX4 & 21.0 & 6 & 160\\
Mazda RX4 Wag & 21.0 & 6 & 160\\
Datsun 710 & 22.8 & 4 & 108\\
Hornet 4 Drive & 21.4 & 6 & 258\\
Hornet Sportabout & 18.7 & 8 & 360\\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item Here is a note of the table. It is very long and I would want to remove this ugly indention on the left side of the table notes. 
\end{tablenotes}
\end{threeparttable}
\end{table}

还有一张PDF格式的印刷品,上面印有:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-12-09 16:50:07

您可以添加footnote_as_chunk = T

代码语言:javascript
运行
复制
library(dplyr)
library(kableExtra)

data(mtcars)
tab_data <- mtcars[1:5, 1:3]

kbl(
    x = tab_data,
    format = "latex",
    booktabs = TRUE,
  ) %>%
    kable_styling(full_width = FALSE) %>%
    footnote(
      general = "Here is a note of the table. It is very long and I would want to remove this ugly indention on the left side of the table notes. ",
      general_title = "",
      threeparttable = TRUE,
      footnote_as_chunk = T
    )

-output

票数 1
EN

Stack Overflow用户

发布于 2021-12-14 14:22:46

如果您不介意更改包,则可以使用huxtable。然后,您可以根据自己的喜好定制填充、边框等:

代码语言:javascript
运行
复制
library(huxtable)
tab_data <- cbind(model = rownames(tab_data), tab_data)
huxtable(tab_data) |> 
      set_width(0.5) |> 
      theme_article() |>
      add_footnote("Here is a note of the table. It is very long and I would want to remove this ugly indention on the left side of the table notes. ") |> 
      theme_
      set_left_padding(everywhere, 1, 0.1) # change 0.1 to whatever you prefer
      quick_pdf()

需要注意的一点是:这只是在表的底部添加了一个单元格。它不使用TeX脚注或表格。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70292836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档