简体   繁体   English

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

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

New to LateX, I have two problems with it or knitr. LateX的新手,它或knitr有两个问题。 Running the code that follows the image of what is produced in PDF, there continue to appear three repetitions of the the path above the .png figure. 运行跟随PDF产生的图像的代码,.png图上方的路径继续出现三个重复。

Second, the side-by-side table with a .png image in each is not appearing at all. 其次,每个都没有.png图像的并排表根本不会出现。

I would appreciate being corrected and educated. 我将不胜感激得到纠正和教育。

在此处输入图片说明

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

With spaces in your filenames, you need to add 文件名中有空格,您需要添加

\usepackage{grffile}

to your preamble. 到你的序言。 Additionally, once you've specified an appropriate set in \\graphicspath{..} , you can remove all such path references in the \\includegraphics commands. 此外,在\\graphicspath{..}指定了适当的设置后,您可以在\\includegraphics命令中删除所有此类路径引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM