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

时间:2015-08-27 19:10:10

标签: r latex png knitr

LateX的新手,我有两个问题或者knitr。运行跟随PDF生成的图像的代码,继续出现.png图上方路径的三次重复。

其次,并排表中的.png图像根本没有出现。

我希望得到纠正和教育。

enter image description here

\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}

1 个答案:

答案 0 :(得分:0)

文件名中包含空格,您需要添加

\usepackage{grffile}

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