Body Latex 标题页后的文本未显示,Rmarkdown

Body text after latex title page not showing, Rmarkdown

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

---

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

我没有更改 Rmarkdown 文件中的任何其他内容,它的标准文本开头为:This is an Rmarkdown document 等。我包括我的 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 中。任何帮助将不胜感激。

问题是使用 \begin{document}...\end{document} 你告诉 latex 它应该忽略之后的所有内容。相反,您可以发布标题页的内容 \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
---