【问题标题】:Body text after latex title page not showing, Rmarkdown乳胶标题页后的正文未显示,Rmarkdown
【发布时间】:2021-09-07 06:54:29
【问题描述】:

我已经成功地将乳胶标题页添加到我的 Rmarkdown 文件中,但文档的其余部分没有出现。这是我的 YAML:

---

output:
  pdf_document:
    includes:
      in_header: title.tex
---

我没有更改 Rmarkdown 文件中的任何其他内容,它的标准文本开头为:这是一个 Rmarkdown 文档等。我包括我的 title.tex 文件:


\usepackage{graphicx}
\begin{document}

\begin{titlepage}
    \begin{center}
    
    \includegraphics{UCTLogoLong.jpg} 
        \vspace*{2cm}
        
        \textbf {\Huge Applied Spatial Data Analysis} % MAIN TITLE
        \vspace{0.5cm}
        
        {\LARGE Assignment 1} % SUBTITLE
        \vspace{1cm}
        
        \noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}} 
        
        {\LARGE Geostatistics}
        \noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}} 
        \vspace{1cm}
        
        {\Large NAME }  % AUTHOR
        
        {\Large STUDENT NUMBER}
        \vspace{1cm}
        
        \includegraphics[width=5cm,height=5cm,keepaspectratio]{statslogo.png} 
         
    \vspace{0.2cm}
        
        Department of Statistical Sciences\\
        University of Cape Town\\
        South Africa\\
        \today
        
    \end{center}
\end{titlepage}

\end{document}

我对 Rmarkdown 比较陌生,不知道为什么标准的 Rmarkdown 文本没有在 knitted pdf 中显示。任何帮助将不胜感激。

【问题讨论】:

    标签: latex r-markdown page-title


    【解决方案1】:

    问题在于,使用 \begin{document}...\end{document} 您告诉乳胶它应该忽略之后的所有内容。相反,您可以发布标题页的内容\AtBeginDocument{...}

    title.tex:

    \usepackage{graphicx}
    \AtBeginDocument{
    
    \begin{titlepage}
        \begin{center}
        
        \includegraphics{example-image-duck} 
            \vspace*{2cm}
            
            \textbf {\Huge Applied Spatial Data Analysis} % MAIN TITLE
            \vspace{0.5cm}
            
            {\LARGE Assignment 1} % SUBTITLE
            \vspace{1cm}
            
            \noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}} 
            
            {\LARGE Geostatistics}
            \noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}} 
            \vspace{1cm}
            
            {\Large John Doe }  % AUTHOR
            
            {\Large something}
            \vspace{1cm}
            
            \includegraphics[width=5cm,height=5cm,keepaspectratio]{example-image-duck} 
             
        \vspace{0.2cm}
            
            Department of Statistical Sciences\\
            University of Cape Town\\
            South Africa\\
            \today
            
        \end{center}
    \end{titlepage}
    \clearpage
    }
    

    此外,我必须删除空行

    ---
    output:
      pdf_document:
        includes:
          in_header: title.tex
    ---
    

    【讨论】:

    • 谢谢!我意识到我的名字在这个问题中,并且希望保持私密 - 我将编辑问题,以便我的名字不会出现等。
    • @anemone19 不客气!我用答案+图像中的通用名称替换了名称。请注意,该名称将在帖子的历史记录中保持可见。如果你想完全删除它,你需要说服一个模组来编辑历史。
    猜你喜欢
    • 2018-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-21
    • 1970-01-01
    • 1970-01-01
    • 2015-05-31
    相关资源
    最近更新 更多