【问题标题】:How to delete blank pages in Rmarkdown(pagedown)如何在 Rmarkdown(pagedown) 中删除空白页
【发布时间】:2019-10-13 17:14:12
【问题描述】:

这是我的代码:

---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
  pagedown::html_paged:
    toc: true
    toc_depth: 3
    # change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
    self_contained: false
---

# Exercises 1 {-}

# Exercises 2 {-}

# Exercises 3 {-}

如何修复这些空白页?那时我想抹去。

【问题讨论】:

标签: r r-markdown pagedown


【解决方案1】:

就像 cmets 中的人所说,解决此问题的唯一方法是使用自己的风格。如果他们将来提供一个内置选项来做到这一点,那就太好了。

/* page size */
@page {
  size: 6in 9in;
}

/* store some string variables */
.shorttitle1 {
  string-set: h1-text content(text);
}

.shorttitle2 {
  string-set: h2-text content(text);
}

/* left page */
.running-h1-title {
  position: running(runningH1Title);
  width: var(--running-title-width);
  text-overflow: ellipsis;
  overflow: hidden;
}
.running-h1-title:before {
  content: string(h1-text);
}

@page :first {
  @top-left {
    content: none;
  }
  @top-right {
    content: none;
  }
  @bottom-right {
    content: none !important;
  }
  background-image: var(--front-cover);
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}

@page :left {
  @top-left {
    content: counter(page);
  }
}

@page :right {
  @top-right {
    content: counter(page);
  }
}

/* Front cover */
.front-cover {
  break-after: page;
}

/* page breaks; aka CSS fragmentation */
.level1 {
  break-before: page;
}
.section > h1, .section > h2, .section > h3, .section > h4, .section > h5, .section > h6 {
  break-after: avoid;
}
.footnotes {
  break-before: always;
  break-after: always;
}
.figure {
  break-inside: avoid;
}

/* do not break captions */
caption {
  break-inside: avoid;
  break-after: avoid;
}

并像这样使用它:

---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
  pagedown::html_paged:
    toc: true
    toc_depth: 3
    # change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
    self_contained: false
    css:
      - custom.css
---

# Exercises 1 {-}

# Exercises 2 {-}

# Exercises 3 {-}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-28
    • 1970-01-01
    • 2014-10-04
    • 1970-01-01
    • 2015-06-29
    • 1970-01-01
    • 2021-02-23
    • 2023-03-26
    相关资源
    最近更新 更多