首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Rmarkdown(pagedown)中删除空白页

如何在Rmarkdown(pagedown)中删除空白页
EN

Stack Overflow用户
提问于 2019-10-14 01:14:13
回答 1查看 1.4K关注 0票数 8

这是我的代码:

代码语言:javascript
运行
复制
---
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 {-}

如何修复这些空白页?我想把它擦掉。

EN

Stack Overflow用户

回答已采纳

发布于 2019-10-22 18:47:20

就像人们在评论中说的那样,解决这个问题的唯一方法就是使用自己的风格。如果他们在将来提供一个内置的选项来做这件事,那就太好了。

代码语言:javascript
运行
复制
/* 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;
}

并像这样使用它:

代码语言:javascript
运行
复制
---
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 {-}
票数 4
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58365933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档