4

I am getting a significant amount of empty space under the following figure. How do I get rid of it? (I am a new user and I don't know how to post a tex code.)

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{figure}[h!]
\centering

    \begin{tikzpicture}
    \tkzDefPoint(0,0){A}
    \tkzDefPoint(5,0){B}
    \tkzLabelPoints[below](A)
    \tkzLabelPoints[below](B)
    \tkzDrawSegment(A,B)
    \tkzDefPoint(2,3){C}
    \tkzLabelPoints[above](C)
    \tkzDrawSegment(A,C)
    \tkzDrawSegment(B,C)
    \tkzDrawBisector(C,B,A)(P)
    \tkzDrawBisector(C,A,B)(Q)
    \tkzDrawBisector(A,C,B)(R)
    \tkzDefCircle[in](A,B,C)\tkzGetPoint{I}\tkzGetLength{rIN}
    \tkzDrawCircle[R](I,\rIN pt)

    \draw[red] (I) -- ($(A)!(I)!(C)$)++(-30:0.1) -- ++(56:0.1) -- +(-34:-0.1);
    \draw[red] (I) -- ($(A)!(I)!(B)$) ++(90:0.1) -- ++(0:-0.1) -- +(-90:0.1);
    \draw[red] (I) -- ($(B)!(I)!(C)$) ++(45:-0.1) -- ++(-45:0.1) -- +(45:0.1);
    \draw (I)+(.2,-.3) node {$I$};
    \end{tikzpicture}
    \caption{Inscribed circle.}    
    \end{figure}  

\end{document}
6
  • 2
    you can mark code sections with {} in the editor (which indents by 4 spaces) not really possible to answer the question as it is impossible to say why you have space: it depends on other things on the page. But in general you should use \centering not \begin{center} in figures as the environment form adds vertical space, and don't use [!h] use [htp] or no option. [!h] usually generates a warning that it is being changed to [!ht]. Jul 26, 2015 at 18:44
  • Thank you for your quick response. I am pretty sure the problem is with the tikzpicture part. I have made many figures and I experienced this kind of problem with only two figures. Both times it was when I used \tkzDrawBisector. Jul 26, 2015 at 18:54
  • It would help if you extended the example to a complete document . I thought you meant space after the figure caption before the (unshown) following text, do you mean space above the caption? in either case an example that reporduces the problem would help. Jul 26, 2015 at 19:13
  • do you have to mask line-endings in tikz? (i really dont know, but when I see tikz examples they often are masked) on a more general hack note: you could always end your figure with a negative vspace
    – Bort
    Jul 26, 2015 at 20:17
  • The space is between the figure and the caption. The TEX code above by itself has that problem. Jul 26, 2015 at 20:37

3 Answers 3

4

The problem is, as cfr mentions in her answer, that in calculating some elements (in your case, the bisectors and even the inscribed circle) the bounding box gets enlarged. ANother way to prevent the problem, instead of interrupting the bounding box, is to use the native \tkzClip command.

enter image description here

Notice also that instead of manual \draws for the heights you can use

    \tkzDrawAltitude
    \tkzMarkRightAngle

as I did in my code. The complete code:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{figure}[h!]
\centering
    \begin{tikzpicture}
    \tkzInit[xmin=-0.3,xmax=5.3,ymin=-0.5,ymax=3.5]
    \tkzClip    
    \tkzDefPoint(0,0){A}
    \tkzDefPoint(5,0){B}
    \tkzLabelPoints[below](A)
    \tkzLabelPoints[below](B)
    \tkzDrawSegment(A,B)
    \tkzDefPoint(2,3){C}
    \tkzLabelPoints[above](C)
    \tkzDrawSegment(A,C)
    \tkzDrawSegment(B,C)
    \tkzDrawBisector(C,B,A)(P)
    \tkzDrawBisector(C,A,B)(Q)
    \tkzDrawBisector(A,C,B)(R)
    \tkzDefCircle[in](A,B,C)\tkzGetPoint{I}\tkzGetLength{rIN}
    \tkzDrawCircle[R](I,\rIN pt)
    \tkzSetUpLine[color=red]
    \tkzDrawAltitude(A,B)(I)
    \tkzMarkRightAngle[color=red,size=.15](I,tkzPointResult,A)
    \tkzDrawAltitude(B,C)(I)
    \tkzMarkRightAngle[color=red,size=.15](I,tkzPointResult,B)
    \tkzDrawAltitude(C,A)(I)
    \tkzMarkRightAngle[color=red,size=.15](I,tkzPointResult,C)
    \end{tikzpicture}An
    \caption{Inscribed circle.}    
    \end{figure}  

\end{document}
5
  • This one is nicer than my method. Jul 26, 2015 at 23:54
  • Is it possible to change the size of the square generated by \tkzMarkRightAngle? Jul 27, 2015 at 16:05
  • @PiotrMikusinski Sure. There's a size=<factor> (default=0.22) option to control the size. I changed the size in my updated answer. Jul 27, 2015 at 16:45
  • Fantastic! This is exactly what I needed. Thank you! Jul 27, 2015 at 19:50
  • Possible is to use the macro tkzDefPoints to define A,B and C then also possible is to group tkzDrawSegments(A,C B,C A,B). The code is fine. Feb 29, 2016 at 20:21
2

I think that drawing the bisectors increases the bounding box. You can avoid this by interrupting the box while drawing them.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\begin{figure}
  \centering
  \begin{tikzpicture}
    \tkzDefPoint(0,0){A}
    \tkzDefPoint(5,0){B}
    \tkzLabelPoints[below](A)
    \tkzLabelPoints[below](B)
    \tkzDrawSegment(A,B)
    \tkzDefPoint(2,3){C}
    \tkzLabelPoints[above](C)
    \tkzDrawSegment(A,C)
    \tkzDrawSegment(B,C)
    \begin{pgfinterruptboundingbox}
    \tkzDrawBisector(C,B,A)(P)
    \tkzDrawBisector(C,A,B)(Q)
    \tkzDrawBisector(A,C,B)(R)
    \end{pgfinterruptboundingbox}
    \tkzDefCircle[in](A,B,C)\tkzGetPoint{I}\tkzGetLength{rIN}
    \tkzDrawCircle[R](I,\rIN pt)
    \draw[red] (I) -- ($(A)!(I)!(C)$)++(-30:0.1) -- ++(56:0.1) -- +(-34:-0.1);
    \draw[red] (I) -- ($(A)!(I)!(B)$) ++(90:0.1) -- ++(0:-0.1) -- +(-90:0.1);
    \draw[red] (I) -- ($(B)!(I)!(C)$) ++(45:-0.1) -- ++(-45:0.1) -- +(45:0.1);
    \draw (I)+(.2,-.3) node {$I$};
  \end{tikzpicture}
  \caption{Inscribed circle.}
\end{figure}
\end{document}

modified bounding box

Here's a comparison of the figure with the unmodified code (Before) and the modified code (After):

before and after

3
  • The picture changed. It's no longer an inscribed circle. Jul 26, 2015 at 20:38
  • @PiotrMikusinski I don't know what an inscribed circle is but it looks the same to me with and without my modification. The only difference in the output I get is the distance between the picture and the caption.
    – cfr
    Jul 26, 2015 at 20:45
  • @PiotrMikusinski See edit for before/after. Also, although the code I posted was right, for some reason the image I uploaded before was not. I've rerun the code and created a new screenshot to replace the one I posted previously. Very odd. Sorry for the confusion.
    – cfr
    Jul 26, 2015 at 20:51
1

Another potential solution, the sledgehammer method, so to say, would be to insert an \vspace*{-3.2cm} between the \end{tikzpicture} and \caption{Inscribed circle.}. With this, you can remove the space, but it does only address the symptom of the problem but not the cause.

You must log in to answer this question.

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