多列布局,一侧为项目符号列表,另一侧为地图

问题描述 投票:0回答:1

我正在建立一个流程来批量生成两页报告并将它们放在一个单词文档中。在使用 gitbook 创建类似的东西之前我已经取得了成功,所以认为这个 officedown 是有意义的。

但是,我正在努力创建一个部分,其中左栏中有多个项目符号点,右侧有一张带标题的地图。我认为部分问题是我以编程方式生成要点,因为它们会随每个报告而变化。

索引.Rmd

---
title: ' '
site: bookdown::bookdown_site
documentclass: book
biblio-style: apalike
link-citations: true
---

```{r include=FALSE}
# load libraries and setup environment ####
library(dplyr)
library(here)
library(knitr)
library(magick)
library(officedown)
library(officer)
library(rmarkdown)

reference_font <- officer::fp_text(font.size = 10, font.family = "Arial", vertical.align = 'superscript')

01-多列列表.Rmd

    ---
    title: "MultiColumn Layout"
    site: bookdown::bookdown_site
    documentclass: book
    biblio-style: apalike
    link-citations: true
    ---
    
    
    ```{r include=FALSE}
    # Summary Information
    # current_lha <- "REPLACE_ME1"
    current_lha <- "My Region of Interest"
    
    img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
    # health_master_subset <- health_master %>% 
    #   filter(chsa_name == current_lha)
    # 
    # lha_title <- health_master_subset %>% pull(lha_title)
    important_num <- sprintf("%.1f%%", 18.756)
    population_statement <- paste0("Usually this is ", "a lot more complicated and will reference numbers such as ", important_num, ".")
    
    pop_projection_statement <- paste("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eu pulvinar arcu, quis aliquam dui. In at cursus ante. Vestibulum non sagittis lacus. Duis vitae iaculis dui.")
    
    fig_caption <- paste0("Figure 1: Location of ", current_lha, " which looks very nice this time of year.")
    ```
    
    # Community Profile: LHA `r current_lha` 
    
    ## 1 Population Profile
    
    ### Demographics
    
    <!---BLOCK_MULTICOL_START--->
    
    ```{r echo=FALSE}
    fpar(population_statement,
         ftext("2", prop = reference_font),
         pop_projection_statement,
         ftext("2", prop = reference_font),
         run_columnbreak(),
         ftext(fig_caption),
         external_img(src = img.file, width = 3.5, height = 4.5)
    )
    
    ```
    <!---BLOCK_MULTICOL_STOP{widths: [3,3], space: 0.2, sep: false}--->
    
    `r run_pagebreak()`
    
    ## 2 Population Profile
    
    ### Demographics
    
    <!---BLOCK_MULTICOL_START--->
    * `r fpar(population_statement, ftext("2", prop = reference_font))`
    * `r fpar(pop_projection_statement, ftext("2", prop = reference_font))`
    `r run_columnbreak()`
    ```{r echo = FALSE}
    fpar(
      ftext(fig_caption),
      external_img(src = img.file, width = 3.5, height = 4.5),
      fp_p = fp_par(line_spacing = 1,
                      word_style = "No Spacing")
    )
    ```
    <!---BLOCK_MULTICOL_STOP{widths: [3,3], space: 0.2, sep: false}--->

我的_bookdown和_output yml除了将章节名称更改为“”之外基本上都是默认的。

我的输出看起来像这样

first code attempt output

second method output

我不太确定出了什么问题或如何最好地解决。 当前的问题是我无法让左侧有项目符号点(我收到一条关于 bookdown 文件中默认 ol/ul 的错误消息,并且它们不存在。不知道如何自定义将它们放入我的模板正确,所以我通常只是从 yml 中删除它们)。

我注意到我的第一种方法总是将右侧的列向下推一行,不知道为什么。当我在第二种方法中对项目符号点使用 rmarkdown 格式时,它变得非常不稳定。

谢谢!

r-markdown officer officedown
1个回答
0
投票

您可以使用 Rmarkdown Cookbook 进行更多自定义。我建议你坚持使用 HTML 输出文档。还有一些其他选项使用

par()
。可能需要在进行过程中调整文本、图表和图的位置。

---
output: html_document
title: "this is the title header"
---

:::: {style="display: flex;"}

::: {}
# Demographics

a brief sentence about demographics. yada yada yada.

* demographics can be different
* here is more about demographics
* did you know?

:::

::: {}
```{r fig.cap= "Figure above this is a reference to the chart", echo=FALSE, fig.align='center'}
plot(iris[, -5])
```

:::

::::

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.