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

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

问题描述

3月份,我问了一个问题,并得到了将封面包括在R bookdown呈现的pdf文档中的答案:

R预订-封面和附录

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

在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等开头.

如果我删除上面标题中的include子句,然后将作者显示为第一页,然后显示目录,所有章节标题和章节编号都会正确显示-但当然没有封面或版权页面. /p>

frontpage.tex如下所示:

\frontmatter

\includegraphics {coverpage.png}

This edition first published August 2017 etc

如何获得标题之前的封面,标题之后和目录之前的版权页面,并具有章节标题,即(按顺序正确地显示了章节标题之前的单词章节和编号.

到目前为止,R bookdown在书籍的排版和格式方面做得非常出色,但是我似乎无法做出需要工作的典型内容.

谢谢...

解决方案

要在书本生成的pdf文件中的标题页之前获得封面,诀窍是关闭LaTeX的 \ maketitle 命令,创建封面,然后再次打开 \ maketitle 并执行(如果需要标题页的话).

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

\let\oldmaketitle\maketitle
\AtBeginDocument{\let\maketitle\relax}

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

\thispagestyle{empty}
\begin{center}
{\Huge A BOOK}
\includegraphics{cover.png}
{\huge by Me}
\end{center}

\let\maketitle\oldmaketitle
\maketitle

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

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

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

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

R bookdown - cover page and appendix

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

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

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

Thanks...

解决方案

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.

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

\let\oldmaketitle\maketitle
\AtBeginDocument{\let\maketitle\relax}

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

\thispagestyle{empty}
\begin{center}
{\Huge A BOOK}
\includegraphics{cover.png}
{\huge by Me}
\end{center}

\let\maketitle\oldmaketitle
\maketitle

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.

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").

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书中标题前的封面和版权声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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