使用 knitr 和 LateX,如何避免 .png 上面的路径;以及如何在 table 中并排放置两个地块

With knitr and LateX, how to avoid path above .png; and how to place two plots side-by-side in table

LateX 新手,我在使用它或 knitr 时遇到了两个问题。 运行PDF生成的图片后面的代码,.png图上面的路径不断重复出现3次。

其次,并排的 table 和每个 .png 图像根本没有出现。

我希望得到纠正和教育。

\documentclass[11pt]{article}  

\usepackage{fullpage}
\usepackage[margin=1in]{geometry}

\usepackage{color}

% \usepackage{framed}

\usepackage{graphicx}  % to import .png files
\usepackage{tabularx}  % note that there is no tabular package
\usepackage{fancyhdr}

\lhead{Survey Graphics}
\rhead{Pg. \thepage}
\cfoot{$\copyright$ lawyeR}

<<echo=FALSE, results="hide", warning=FALSE, message=FALSE>>=
lm_blue <- "#003767"
@

% \renewcommand
% \headrule{ 
% \color{lm_blue}
% \begin{minipage}{1\textwidth}
% \hrule width \hsize height 5pt 
% \end{minipage}}%
% 
% \newcommand{\HRule}[1]{\hfill \rule{0.2\linewidth}{#1}} % Horiz rule at bottom of page, adjust width here
% 
% \renewcommand{\headrulewidth}{0.4pt}
% \renewcommand{\footrulewidth}{0.1pt}  
% \addtolength{\headheight}{0.5pt}  

%% end preamble; begin document


\begin{document}

\graphicspath{ {C:/Users/blank/Documents/Marketing and Blog/ReproData Book Survey/Plots and images/} }

\begin{figure}[h]    
\begin{center}
\includegraphics[width = 90mm, height = 2in]{C:/Users/blank/Documents/Marketing and Blog/ReproData Book Survey/Plots and images/Above the Law 2013 comment in plot.PNG}
\end{center}
\end{figure}


% lay out figures side-by-side using table

\begin{table}[h]
\begin{tabular}{cc}
PNG One & PNG Two \
\includegraphics[width = 20mm]{C:/Users/blank/Documents/Marketing and Blog/ReproData Book Survey/Plots and images/MLA Comp 2014 bars separated.PNG} &
\includegraphics[width = 20mm]{C:/Users/blank/Documents/Marketing and Blog/ReproData Book Survey/Plots and images/Winstonpg19noredundantdata2.PNG}
\end{tabular}
\end{table}

\end{document}

文件名中有空格,需要添加

\usepackage{grffile}

到你的序言。此外,一旦您在 \graphicspath{..} 中指定了适当的集合,您就可以在 \includegraphics 命令中删除所有此类路径引用。