我有以下R
代码来生成tikzdevice
图表:
tikz(file = "plot_CIs.tex", width = 5, height = 5)
par(cex = 0.8)
ggplot(confidence_interval, aes(x = Statistic, y = Values, group = 1)) +
geom_errorbar(width = 0.1, aes(ymin = Lower_Bound, ymax = Upper_Bound)) +
geom_point(shape = 21, size = 3, fill = "white") +
labs(title = title, subtitle = subtitle) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(plot.subtitle = element_text(hjust = 0.5))
然后latex
我使用以下内容:
\documentclass{article}
%The package tikz is available in pgf
\usepackage{tikz}
\usepackage[justification=centering]{caption}
\begin{document}
\begin{figure}
%Do not try to scale figure in .tex or you loose font size consistency
\centering
%The code to input the plot is extremely simple
\input{../plot_CIs.tex}
%Captions and Labels can be used since this is a figure environment
\caption{Sample output from tikzDevice}
\label{plot:test}
\end{figure}
\end{document}
编译文档时我收到以下警告latex
:
Overfull \hbox (16.35pt too wide)
根据日志,这与以下内容相关:
(../plot_CIs.tex)
Overfull \hbox (16.35pt too wide) in paragraph at lines 12--14
我该如何解决这个警告?如果我将它\includegraphics
用于我的图像,我只需执行以下操作:
includegraphics[width=\linewidth]{plot_CIs.tx}
有没有办法用\input
绘图做同样的事情tikzdevice
?
谢谢!
答案1
你可以\resizebox
这样使用:
\resizebox{\linewidth}{!}{\input{../plot_CIs.tex}}
由于您没有提供最低限度的和完整例子。
或者,您可以调整调用width
中的参数tikz(...)
。