多元环境(knitr)

问题描述 投票:0回答:1
否,我面临的问题是,该情节的开始高于表,导致两个元素之间的错位。理想情况下,我希望两者都在页面上的相同级别对齐。

米:

#```{r config, include=FALSE} newslide <- function(content) { code <- deparse(substitute(content)) cat(sep = "\n", knitr::knit_child( quiet = TRUE, text = c("```{r dpi=600, warning=FALSE, message=FALSE, echo=FALSE, results='asis', escape = TRUE}", code, "```") ) ) } #``` #```{r latex, echo=FALSE, results = 'asis', escape = "TRUE"} plot_list <- list() category <- c("A","B","C") for (cat in category){ fit <- survfit(Surv(time, status) ~ sex, data = lung) p <- ggsurvplot(fit, data = lung) plot_list[[cat]] <- p } for (cat in category){ plot1 <- plot_list[[cat]]$plot #I've also tried without "$plot" table1_latex <- kable(head(lung), format = "latex") newslide( content = { cat("\\begin{multicols}{2}\n") cat("\\noindent\n") print(table1_latex) cat("\\columnbreak\n") cat("\\begin{center}\n") print(plot1) cat("\n") cat("\\end{center}\n") cat("\\end{multicols}\n") } ) }

您可以从我的原始代码中的屏幕截图中看到,该图甚至在标题之前重叠:

感谢您的任何建议!

Picture of the problem, where the plot is higher than the table next to it 我放弃并使用了这样的微型:

newslide( content = { cat("\\begin{minipage}{0.4\\textwidth}\n") print(table2) cat("\\end{minipage}") cat("\\hspace{0.1\\textwidth}") cat("\\begin{minipage}{0.4\\textwidth}\n") print(plot1) cat('\n\n') cat("\\end{minipage}") } )

r ggplot2 latex knitr kable
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.