3

I do not understand why, but somehow I get a big black line in my pdf, why?

head:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage[margin=3cm]{geometry}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage[]{mcode}
\usepackage[swedish]{babel}
\usetikzlibrary{calc}
\usepackage{float}
\usepackage{subfig}

\parindent=0pt
\setlength{\parskip}{1em}

\title{Matematisk modellering}
\author{}
\date{February 2016}
\begin{document}

code:

\begin{figure*}[t!]\centering
\begin{tikzpicture}
[
scale=3,
>=stealth,
point/.style = {draw, circle,  fill = black, inner sep = 1pt},
dot/.style   = {draw, circle,  fill = black, inner sep = .2pt},
]
%
% the circle
\draw (0,0) circle (2.12cm);
%
% triangle nodes: just points on the circle
\node (n0) at (0,0) [point, label = below:$S$] {};
\node (n1) at (-1.5,1.5) [point, label = below:$R_{1}$] {};
\node (n2) at (-3,0) [point, label = {below left:$R_{2}$}] {};
\node (n3) at (-2.12,0) [point, label = {below left:$q$}] {};
%
% triangle edges: connect the vertices, and leave a node at the midpoint
\draw[-] (n0) -- node (a) [label = {below left:$\gamma$}] {} (n1);
\draw[-] (n0) -- node (a) [label = {below right:$\gamma$}] {} (n2);
\draw[-] (n2) -- node (a) [label = {below :$vt_{1,2}$}] {} (n3);
\end{tikzpicture}

\end{figure*}

My Circle

  • 1
    Try looking at the log: I bet you'll find "Overfull \hbox" someplace. I'm pretty sure that is what is called overfull rule, indicating you have a line that is out of the page margin. To get that away, either scale the picture, or give your class the final option. – MickG Feb 29 '16 at 14:16
  • You were correct. – Olba12 Feb 29 '16 at 14:27
  • Perfect. Would you accept the answer I posted so I can flag the other thing as a duplicate of this one? – MickG Feb 29 '16 at 14:33
  • Is there anything more I need to do, than just saying that I accept it? – Olba12 Feb 29 '16 at 16:15
  • Click the checkmark on its left. That's what we mean here by "accept an answer". – MickG Feb 29 '16 at 16:15
6

First of all, I should point out two things:

  • Package mcode is not available on my computer, which means it either isn't in TeXLive or is in the form of an .ins to be typeset to get a .sty from it, as rmathbr is on CTAN; either way, it is useless, so a good MWE should ideally not include it;
  • Secondly, I compiled the following code:

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage{verbatim}
    \usepackage{tikz}
    \usepackage{amsmath}
    \usepackage[margin=3cm]{geometry}
    \usepackage{mathtools}
    \usepackage{graphicx}
    %\usepackage[]{mcode}
    \usepackage[swedish]{babel}
    \usetikzlibrary{calc}
    \usepackage{float}
    \usepackage{subfig}
    
    \parindent=0pt
    \setlength{\parskip}{1em}
    
    \title{Matematisk modellering}
    \author{}
    \date{February 2016}
    \begin{document}
    
    \begin{figure*}[t!]\centering
    \begin{tikzpicture}
    [
    scale=3,
    >=stealth,
    point/.style = {draw, circle,  fill = black, inner sep = 1pt},
    dot/.style   = {draw, circle,  fill = black, inner sep = .2pt},
    ]
    %
    % the circle
    \draw (0,0) circle (2.12cm);
    %
    % triangle nodes: just points on the circle
    \node (n0) at (0,0) [point, label = below:$S$] {};
    \node (n1) at (-1.5,1.5) [point, label = below:$R_{1}$] {};
    \node (n2) at (-3,0) [point, label = {below left:$R_{2}$}] {};
    \node (n3) at (-2.12,0) [point, label = {below left:$q$}] {};
    %
    % triangle edges: connect the vertices, and leave a node at the midpoint
    \draw[-] (n0) -- node (a) [label = {below left:$\gamma$}] {} (n1);
    \draw[-] (n0) -- node (a) [label = {below right:$\gamma$}] {} (n2);
    \draw[-] (n2) -- node (a) [label = {below :$vt_{1,2}$}] {} (n3);
    \end{tikzpicture}
    
    \end{figure*}
    
    \end{document}
    

    to get no overfull rule:

    enter image description here

    So either you have some out-of-date package, or the code you gave does not reproduce your problem.

Assuming you have up-to-date packages, that black line is showing you what the following message tells you:

Overfull \hbox (13.73792pt too wide) in paragraph at lines 45--46

that is, you have a line that's getting out of the page margin, in this case, a huge picture. So you can either:

  • Add the final option to article, i.e. \documentclass[final]{article};
  • Change margin=3cm to e.g. margin=2cm, which removes the overfull;
  • Change scale=3 to e.g. scale=2;
  • Try some \parbox or minipage trickery, though I'm not sure that can widen the margin and remove the overfull; after all, I hardly ever use minipage, and only use \parbox via a macro built for a very specific purpose.

For the record, a very similar question was asked here, and assuming you googled first, you probably didn't find it because of the "edge". Well now we have a nice duplicate target for that question: this one. Flagging soon.

It is strange that you got that. Were you using draft option? Because it should not be default…

Additional remarks

Since you are using LaTeX, you may well want to use the center environment rather than the plain-TeX \centering macro. I do not know if there are any big "upsides" to this choice, but it is generally considered good practice to use LaTeX where you can, and resort to TeX when writing macros where LaTeX is not convenient, unless I'm much mistaken. So I suggest you remove \centering and wrap the figure inside \begin{center}…\end{center}.

This MWE needs neither inputenc, nor verbatim, nor mathtools, nor graphicx, nor mcode, nor babel, so to make it really minimal, you should have removed those packages. They only clutter the code and may make others think one of those is the problem, when the problem is just an overfull box. And I think geometry is also not needed.

In general, before posting, you should check your code reproduces your problem. In this case, it didn't. If the code must be an example of the problem, and it doesn't show the problem, then it's not a good example, right :)?

Update

Turns out I was partly wrong in the part about center. Quoting @barbarabeeton's comment:

the center environment adds extra space above and below; \centering does not. sometimes the environment results in too much space, and in that situation, \centering is not only appropriate, but recommended.

| improve this answer | |
  • Im writing in ShareLatex. I cuted this figure out from a BIG document. You are right I should have tried to run just the code presented. But somehow, just following your first comment above, solved the whole thing. – Olba12 Feb 29 '16 at 16:16
  • 1
    Perhaps ShareLatex fiddles with class options, making draft default and final the one to be specified. Bizarre behaviour if you ask me, but if you weren't passing draft the black line should not have appeared... – MickG Feb 29 '16 at 16:19
  • 2
    the center environment adds extra space above and below; \centering does not. sometimes the environment results in too much space, and in that situation, \centering is not only appropriate, but recommended. – barbara beeton Feb 29 '16 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.