0

当我使用 kable 在我的 Rnw 文件中创建一个表时,该表按预期输出。但是,当我包含标题时,表格完全停止输出。下面是我的乳胶和示例 knitr 块。

\documentclass[titlepage]{article}

\usepackage{graphicx}

\usepackage[dvipsnames]{xcolor}

\usepackage{afterpage}

\usepackage{booktabs}

\usepackage{longtable}

\pagecolor{ForestGreen}\afterpage{\nopagecolor}

\color{white}

\title{%
  \noindent\makebox[\linewidth]{\rule{9cm}{0.9pt}}
  \huge \textbf{\textit{Key Distributor Report}}\\
  \LARGE \vspace{2mm} \textbf{\textit{A detailed quarterly review}} \\
  \noindent\makebox[\linewidth]{\rule{9cm}{0.9pt}}
  \vspace{6mm} \LARGE Macdonald Corp.} 

\pagenumbering{arabic}

\begin{document}

\maketitle

\color{black}

\newpage  

\tableofcontents

\newpage

\section{Overview of Key Distributors}

\section{Company A}

\subsection{National Overview}

\subsubsection{Account base structure}

<<
tester, echo=FALSE, message=FALSE, warning=FALSE,    results='asis',fig.height=3, fig.width=3, fig.align='center', eval=TRUE >>=

library(knitr)

kable(head(mtcars[,1:3]), booktabs=TRUE, caption='This is a caption')

@


\end{document}
4

1 回答 1

0

这似乎是文本着色的问题。如果您尝试选择您意识到的 pdf 中的所有内容,表格实际上就在那里,但文本是白色的。所以只需改变标题页的着色方式(使用\coloron\maketitle代替\title):

\documentclass[titlepage]{article}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{afterpage}
\usepackage{booktabs}
\usepackage{longtable}
\pagecolor{ForestGreen}\afterpage{\nopagecolor}

\title{%
  \noindent\makebox[\linewidth]{\rule{9cm}{0.9pt}}
  \huge \textbf{\textit{Key Distributor Report}}\\
  \LARGE \vspace{2mm} \textbf{\textit{A detailed quarterly review}} \\
  \noindent\makebox[\linewidth]{\rule{9cm}{0.9pt}}
  \vspace{6mm} \LARGE Macdonald Corp.} 

\pagenumbering{arabic}

\begin{document}

{\color{white}%
  \maketitle
}
\color{black}

\newpage  
\tableofcontents
\newpage

\section{Overview of Key Distributors}
\section{Company A}
\subsection{National Overview}
\subsubsection{Account base structure}


<<tester, echo=FALSE, message=FALSE, warning=FALSE,results='asis',fig.height=3, fig.width=3, fig.align='center', eval=TRUE >>=
library(knitr)
library(kableExtra)
library(dplyr)
kable(head(mtcars[,1:3]), booktabs=T, caption='This is a caption') %>%
kable_styling(latex_options = "hold_position")
@

\end{document}
于 2018-03-14T10:35:47.247 回答