简体   繁体   English

R Markdown PDF输出中的徽标,仅在第一页上

[英]Logo in R Markdown PDF output, only on the first page

Previously I've asked a very similar question to the question I am currently trying to ask. 以前,我曾问过一个非常相似的问题 ,与我目前想问的问题类似 Actually, this question can be thought of as an extension of my previous question. 实际上,这个问题可以看作是我先前问题的扩展。

I am looking for a way to include my company's logo on the first page of a PDF R Markdown output. 我正在寻找一种在PDF R Markdown输出的第一页上包含公司徽标的方法。 As stated in the previous question, I've looked for answers online, but most of the solutions resulted in either the logo being on all the pages (not just the first) or in some redundant elements (chapter titles, horizontal lines below them etc.) being added to every page. 如上一个问题所述,我一直在网上寻找答案,但是大多数解决方案导致徽标出现在所有页面上(不仅是第一页),或者出现在一些多余的元素中(章节标题,其下方的水平线等) 。)被添加到每个页面。 This has led me to ask the previous question - how to include the logo only at the first page, with no additional elements besides the logo. 这使我问了上一个问题-如何在第一页包含徽标,除了徽标之外没有其他元素

I got my answer, which satisfied the criteria that I had posted (for details of the answer, please see the previous post). 我得到了答案,该答案满足了我发布的条件(有关答案的详细信息,请参阅上一篇文章)。 However, the problem is that if my Markdown doc contains the title, author or some other fields, the logo appears below them, whereas I want it to appear above those fields in the header. 但是,问题在于,如果我的Markdown文档包含标题,作者或其他某些字段,则徽标会出现在标题下方 ,而我希望它显示在标题中的这些字段上方

To summarize, my question is: How to print a logo in the Markdown PDF document which satisfies the following criteria: 总而言之,我的问题是:如何在满足以下条件的Markdown PDF文档中打印徽标:

  • Appears only on the first page 仅出现在第一页
  • Does not result with additional unwanted elements (chapter titles etc.) 不会导致其他不需要的元素(章节标题等)
  • Appears above the title and all other fields (eg author) in the header 出现在标题和标题中的所有其他字段(例如作者)上方

Many thanks! 非常感谢!

I was the one that originally answered your first question. 我是最初回答您第一个问题的人。

\begin{center}
\includegraphics[width=7cm]{logo.jpg} 
\end{center}

I currently use the code like this after the R Setup and the logo is centered over the title. 我目前在R Setup后使用这样的代码,徽标位于标题的中心。 Unless you mean you want your logo at the extreme top of the page it should work. 除非您想将徽标放在页面的最顶部,否则它应该起作用。

You could also use something along those lines if you want to add the title, author and more under the logo : 如果您想在徽标下添加标题,作者等内容,也可以沿这些行使用:

\title{%
\includegraphics[width=0.1\textwidth]{files/image.jpg}~ 
\\[1cm]
Title
\\more text 
}
\author{Some.Name
\\ where}
\date{August 27, 2019}
\maketitle

EDIT : If you want to have your table of contents under all of this simply add the following code under the previous code : 编辑:如果要在所有这些目录下使用目录,只需在先前代码下添加以下代码:

\pagebreak

\tableofcontents

\pagebreak

\\pagebreak will skip a page (the one with the title, logo, author...). \\pagebreak将跳过一页(带有标题,徽标,作者...的页面)。

\\tableofcontents create/put your table of contents here (you can skip another page after). \\tableofcontents在此处创建/放置目录(您可以在此之后跳过另一页)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM