Coverpage and copyright notice before title in R bookdown?

穿精又带淫゛_ 提交于 2019-12-05 18:11:45

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!