1

I have some difficulties in R Sweave so I hope someone could help me.

I want to include two TikZ pictures using minipage and figure to the R Sweave but I get an error:

Overfull \hbox (2.43085pt too wide). 

The code I'm using is (I have deleted some rows because the code is too long):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{figure}[!ht]  
\begin{minipage}[c]{0.5\linewidth}  
\centering  
\begin{tikzpicture}[>=triangle 45, scale=0.85]  
  \draw[line width=0.2mm] (-0.25,-0.25)--(-0.25,4.5)--(6.25,4.5)--(6.25,-0.25)--(-0.25,-0.25);  
\end{tikzpicture}  
\end{minipage}  
\begin{minipage}[c]{0.5\linewidth}  
\centering  
\begin{tikzpicture}[>=triangle 45, scale=0.85]  
  \draw[line width=0.2mm] (-0.25,-0.25)--(-0.25,4.5)--(6.25,4.5)--(6.25,-0.25)--(-0.25,-0.25);  
\end{tikzpicture}  
\end{minipage}  
\caption{Picture}  
\label{fig:pic1}  
\end{figure}
\end{document}

On page How do you effectively debug overfull \hbox warnings? that if include I found that \showboxdepth=\maxdimen will tell what the real problem is. But this also shows the same error as before.

So my question is: Why do I get an error? What wrong with my code?

5
  • it is impossible really to tell as you have only posted a fragment and that has been corrupted in posting I suspect (do you have a blank line between every line in the source?) but what you show is not an error it is just telling you that something is too wide for the place where it has been placed. (the full message would have given information telling you what was too wide but you have not shown it). note that your two minipage are .5\linewidth wide but won't fit on a line as there is a word space (or a paragraph break if you really have a blank line) between them. Jan 16, 2016 at 10:07
  • As far I can guess without a MWE, do not matter if you have an overfull \hbox of a tikzpicture in a .Rnw or a ` .tex` file. If the .Rnw extension is the unique relation of R and Sweave with this problem, please change the title and the tags of the question.
    – Fran
    Jan 16, 2016 at 10:33
  • @DavidCarlisle I don't have blank lines between the rows. The code now looks just as mine in R. I deleted the rows in my code, but the "error" is the same. What I don't understand is that in TeXworks everything works fine but in R it doesn't.
    – Kyoto
    Jan 16, 2016 at 10:59
  • You have posted an incomplete fragment. I guessed \documentclass{article}\usepackage{tikz} but that gave an error about arrows so I guessed \usetikzlibrary{arrows} but now I get ! Package tikz Error: Cannot parse this coordinate. See the tikz package documentation for explanation. Type H <return> for immediate help. ... l.9 ...)--(-0.25,4.5)--(6.25,4.5)--(6.25,-0.25)-(- so I give up sorry, please post a complete example that reproduces the overfull box that you are asking about. Jan 16, 2016 at 11:10
  • oh that is - not -- I'll update your question this time. Jan 16, 2016 at 11:11

1 Answer 1

1

As noted in the initial comment the error is

\end{minipage}
\begin{minipage}[c]{0.5\linewidth}  

which should be

\end{minipage}%
\begin{minipage}[c]{0.5\linewidth}  

As you can not fit two .5\linewidth minipages and an inter-word space on to a single line.

1
  • David, I have one more question for you, since you know so much about this. In another file I get the similar mistake Overfull \hbox (17.01892pt too wide) in paragraph at lines 8--8. But in line 8 I have \usepackage{enumerate}. Even if I delete this row, the "error" remains.
    – Kyoto
    Jan 16, 2016 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .