PhDavey
PhDavey

Reputation: 416

Multicolumn layout with one side bullet list other side map

I am setting up a process to bulk produce two page reports and put them together in a single word doc. I've had success before using gitbook to create something similar, so thought for this officedown would make sense.

However I'm struggling to create a section where I have multiple bullet points in a left column and a map on the right side with caption. I think part of the problem is I generate the bullet points programmatically as they will change with each report.

index.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-multicolumn-lists.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}--->

my _bookdown and _output yml are basically default other than changing chapter name to " ".

My output looks like this

first code attempt output

second method output

I'm not quite sure what is wrong or how best to fix. The current issue is I can't get the left hand side to have bullet point (I get an error message about the default ol/ul in the bookdown file as well that they don't exist. Not sure how to custom get those into my template correctly, so I just usually remove them from the yml).

I've noticed my first approach always pushes down the right hand column by a single line, not sure why. While when I use rmarkdown formatting for the bullet points in my second approach it gets real wonky.

Thanks!

Upvotes: 0

Views: 42

Answers (1)

Daniel_j_iii
Daniel_j_iii

Reputation: 3252

you can do more customizing using the Rmarkdown Cookbook. i'd suggest you stick with an HTML output doc. there are some other optiosn using par(). Might have to play around with the position of text, charts, and figs as you go along.

---
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

Upvotes: 0

Related Questions