R bookdown中标题之前的封面和版权声明? [英] Coverpage and copyright notice before title in R bookdown?

查看:11
本文介绍了R bookdown中标题之前的封面和版权声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早在 3 月,我就在 R bookdown 呈现的 pdf 文档中包含封面页提出了一个问题并得到了答案:

Back in March, I asked a question and got an answer to including coverpage in a pdf document rendered by R bookdown:

R bookdown - 封面和附录

我尝试了解决方案并得出以下结果:

I tried the solution and came up with the following results:

在 index.rmd 中使用 yaml:

using in index.rmd yaml:

output:
  pdf_document:
    includes:
      before_body: frontpage.tex
    number_sections: yes
    toc: yes
    toc_depth: 3
site: bookdown::bookdown_site
documentclass: book
classoption: letterpaper

标题仍然出现在封面之前,并且章节标题中的章节措辞"(即章节标题的实际单词之前的第 1 章")消失了.并且每章的章节编号以0等开头.

The title still appeared before the coverpage AND the Chapter 'wording' in chapter titles (ie 'Chapter 1' before the actual words for chapter title) disappeared. And the section numbering in each chapter began with 0 etc.

如果我去掉上面标题中的包含子句,作者作为第一页出现,然后是目录,所有章节标题和章节编号都会正确显示 - 但是当然没有封面或版权页.

If i take out the includes clause in the above- title and author come up as first page, followed by table of contents and all chapter headings and section numbering come out properly- but then of course no coverpage or copyright page.

frontpage.tex 如下所示:

frontpage.tex was like the following:

frontmatter

includegraphics {coverpage.png}

This edition first published August 2017 etc

如何在标题之前获得封面,在标题之后和目录之前获得版权页,并让章节标题,即(章节标题之前的单词章节和编号以该顺序正确呈现.

How do I get coverpage ahead of title, copyrightpage after title and before table of contents, and have the chapter headings ie (the word chapter and number ahead of chapter title render in that order and properly.

到目前为止,R bookdown 在书籍布局和格式方面做得非常出色,但我似乎无法做出这些典型的工作所需的东西.

R bookdown has done an amazing job in book layout and formatting so far but I can't seem to make these typical things which would be needed to work.

谢谢...

推荐答案

要在 bookdown 生成的 pdf 文件中获取标题页之前的封面,诀窍是关闭 LaTeX 的 maketitle命令,创建封面页,然后重新打开 maketitle 并在需要标题页时执行它.

To get a cover page before the title page in a pdf file generated by bookdown, the trick is to turn off LaTeX's maketitle command, create the cover page, then turn maketitle back on and execute it if you want the title page as well.

从标准的bookdown demo开始,将以下两行添加到preamble.tex

Starting with the standard bookdown demo, append the following two lines to the end of preamble.tex

letoldmaketitlemaketitle
AtBeginDocument{letmaketitle
elax}

这会将maketitle 命令保存为oldmaketitle,然后关闭原来的maketitle.在同一目录中,现在创建一个 before_body.tex 文件,其中包含以下几行

This saves the maketitle command as oldmaketitle and then turns off the original maketitle. In the same directory, now create a before_body.tex file that contains the following lines

	hispagestyle{empty}
egin{center}
{Huge A BOOK}
includegraphics{cover.png}
{huge by Me}
end{center}

letmaketitleoldmaketitle
maketitle

这会在输出 pdf 的开头插入一个页面,然后将 maketitle 返回到其原始状态,然后执行它.如果您已经有 before_body.tex 文件,只需将行添加到末尾.在上面的例子中,我在图片前后添加了一些文字,只是为了表明可以.

This inserts a page at the beginning of your output pdf, then returns maketitle to its original state and then executes it. If you already have a before_body.tex file, just add the lines to the end. In the above example, I've included some text before and after the image, just to show that one can.

最后,您需要将封面图片文件 (cover.png) 放在同一目录中.并构建您的 pdf_book.这将生成一个带有标题(A BOOK")的封面,然后是封面图片,然后是作者(by Me").

Finally you need to place your cover image file (cover.png) in the same directory. and build your pdf_book. This will produce a cover page with a title ("A BOOK") followed by the cover picture and then the author ("by Me").

在此示例中,我使用了 png 文件,但 pdf 或 jpg 文件也可以正常工作.如果您有更复杂的目录结构,如标准 bookdown 示例,您可能需要修改必要文件的路径,例如latex/preamble.tex"而不是preamble.tex".

In this example I've used a png file, but pdf or jpg files also work fine. If you have a more complicated directory structure, as in the standard bookdown example, you may have to modify the path to the necessary files, e.g. "latex/preamble.tex" instead of "preamble.tex".

这篇关于R bookdown中标题之前的封面和版权声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆