Skip to content

Can't figure out to make margin and padding work #100

Closed

Description

@xtimbeau

In the doc, it is suggested that style item margin and padding set spacing between paragraph in a text. However, I can't figure how to make it work.

The following chunk attempt to reproduce what I can't do; changing padding top or bottom does not seem to change anything. The same with margin.

ggplot()+
   labs(caption = "test line 1  \nline 2  \nline 3")+
   theme(
     plot.caption = element_marquee(
        margin = margin(t=40, b=20), 
        style = classic_style(
           padding = trbl(top = em(1), bottom = em(2), left = 0, right = 0)
            )
         )
      )

Activity

  1. teunbrand commented on Dec 4, 2025

    @teunbrand
    Contributor

    I think element_marquee() replaces the padding with the margin setting, so the padding is out of commission in this context.

  2. xtimbeau commented on Dec 4, 2025

    @xtimbeau
    Author

    OK, fair enough. But margin does not induce anything for top or bottom (it works for left and right fields) and does not create spacing between paragraphs marked by 2 spaces and \n:

    library(ggplot2)
    library(marquee)
    library(stringr)
    s <- str_c(str_c(rep("test line 1", 10), collapse = " "), "line 2",  "line 3", sep = "  \n")
    
        ggplot()+
            labs(caption = s )+
            theme(
                plot.caption = element_marquee(
                   width=unit(6, "cm"),
                   style = classic_style(
                       padding = trbl(top = em(10), bottom = em(20), left = 0, right = 0)
                       )
                   )
                )

    Created on 2025-12-04 with reprex v2.1.1

  3. teunbrand commented on Dec 4, 2025

    @teunbrand
    Contributor

    margin does not induce anything for top or bottom

    It does in my hands when using the element_marquee(margin) setting. The padding in your example doesn't work because of aforementioned reason. I don't know how paragraph spacing ought to work, so I can't advise on that part.

  4. xtimbeau commented on Dec 4, 2025

    @xtimbeau
    Author

    You are right for the element_marquee(margin) setting. This adds some margin around the text box and works as expected. My understanding (and my hope) of the style setting was that it could set the spacing between paragraphs inside the text box.

  5. added a commit that references this issue on Nov 11, 2026
    e05e0ad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions