【问题标题】:How do I center a markdown (.Rmd) file in a {shiny} application?如何在 {shiny} 应用程序中将 markdown (.Rmd) 文件居中?
【发布时间】:2020-11-24 00:26:36
【问题描述】:

我正在尝试将包含在 shiny 应用程序中的降价文档居中。

最小示例:使用名为 markdown_file.Rmd 的文件,其中包含以下文本:

---
output: html_document
---

# Test file

This is some text.

和一个非常基本的shiny 应用程序:

library(shiny)
ui <- navbarPage(
    title = "Test app",
    tabPanel(
        "First tab",
        mainPanel(
            fluidPage(
                includeMarkdown('markdown_file.Rmd')
            )
        )
    )
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

我们可以看到markdown文档在app中自动向左对齐。我希望它位于页面的中心,但文档中的文本仍然左对齐。我在这里尝试了最佳答案Centering images horizontally in a shiny fluidRow,但它只是将我在降价文档中的文本居中对齐,将实际文档留在页面左侧shiny。非常感谢这里的任何帮助!

【问题讨论】:

    标签: r shiny format r-markdown markdown


    【解决方案1】:

    这使我的页面中心达到了大约 3/8。让我知道这对你有用。如果你知道 HTML 来组织你的输出,你也可以在 Shiny 中添加 html。记住闪亮只​​有 12 列

    fluidPage(
        column(12, align="center",
        includeMarkdown('markdown_file.Rmd'))
    
    

    如果我这样做了

    fluidPage(column(8, align="right",
                    includeMarkdown('markdown_file.Rmd')
                ))
    

    我实际上得到了一个更居中的 Rmarkdown

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-16
      • 1970-01-01
      • 2019-01-07
      • 1970-01-01
      • 2019-03-04
      • 2017-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多