5

I am trying to generate a space (6pt) between the boxed figure and its caption. Since I am using tikz code \includegraphics did not work. Also I tried \setlength{\abovecaptionskip}{6pt}, \captionsetup[figure]{skip=6pt}. However they did not work. How to handle this problem?

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage[margin=10pt,font=small,justification=centering]{caption}
\usepackage{tikz}
\usepackage{floatrow}
\usepackage{float,lipsum}
\floatstyle{boxed}
\restylefloat{figure}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{amsmath}

\begin{document}
\begin{figure}[ht]
\begin{center}
\begin{tikzpicture}[thick,scale=1]
\filldraw[black]
(0,0) circle (2pt) (1,1) circle (2pt) (1,-1) circle (2pt)
(3,1) circle (2pt) (3,-1) circle (2pt) (4,0) circle (2pt);
\draw (0,0) -- (1,1) -- (1,-1) -- (0,0);
\draw (1,1) -- (3,1) -- (4,0) -- (3,-1) -- (3,1);
\draw (3,-1) -- (1,-1)--(1,1);
\draw (3,1)-- (3,-1); \draw (4,0) -- (0,0);
\node[above] at (1,1) {$v_1$};
\node[left] at (0,0) {$v_0$};
\node[below] at (1,-1) {$v_5$};
\node[below] at (3,-1) {$v_4$};
\node[right] at (4,0) {$v_3$};
\node[above] at (3,1) {$v_2$};
\end{tikzpicture}
\caption{$G$.}
\label{factorex}
\end{center} 
\end{figure}


\end{document}
  • Thank you, Yes there are packages unused for the solution of the problem. I wrote them just in case. – Zehra Nur Özbay Jul 29 '15 at 16:41
  • Don't use the center environment. Rather use the declaration \centering. – Werner Jul 29 '15 at 17:01
  • But using \centering or \begin{center} are the same? My problem is actually space between the borders of the box and the caption. I think it is caused because of the \floatstyle{boxed} style. But I could not find out how to fix. – Zehra Nur Özbay Jul 29 '15 at 17:39
  • @Werner Please consider re-opening the question, it asks about increasing the space above caption and the question you are referring to as duplicate discusses centering the figure (totally another issue). – AboAmmar Jul 29 '15 at 18:02
  • @egreg Please consider re-opening the question, it asks about increasing the space above caption and the question you are referring to as duplicate discusses centering the figure (totally another issue). – AboAmmar Jul 29 '15 at 18:12
  • @AboAmmar: You're correct. It's actually a duplicate of How can I modify vertical space between figure and caption? I've voted to re-open and will vote-to-close again once it is open. – Werner Jul 29 '15 at 18:41
  • @Werner I think no, even this is not a duplicate, the answer there will not work here either because the OP is using the floatrow which will affect any \abovecaptionskip – AboAmmar Jul 29 '15 at 18:50
  • I viewed all the former questions related to my question (also How can I modify vertical space between figure and caption?). However, none of them answered my question. As I mentioned I tried using \setlength{\abovecaptionskip}{6pt}, \captionsetup[figure]{skip=6pt}. They did not work. Thanks.. @AboAmmar – Zehra Nur Özbay Jul 29 '15 at 18:53
  • @ZehraNurÖzbay I will post my answer as soon as the question is re-opened – AboAmmar Jul 29 '15 at 18:55

1 Answers1

3

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage{floatrow}

\floatsetup[figure]{%
style=Boxed,captionskip=12pt,capposition=bottom,margins=centering,%
}
\usepackage[font=small]{caption}

\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}[thick,scale=1]
\filldraw[black]
(0,0) circle (2pt) (1,1) circle (2pt) (1,-1) circle (2pt)
(3,1) circle (2pt) (3,-1) circle (2pt) (4,0) circle (2pt);
\draw (0,0) -- (1,1) -- (1,-1) -- (0,0);
\draw (1,1) -- (3,1) -- (4,0) -- (3,-1) -- (3,1);
\draw (3,-1) -- (1,-1)--(1,1);
\draw (3,1)-- (3,-1); \draw (4,0) -- (0,0);
\node[above] at (1,1) {$v_1$};
\node[left] at (0,0) {$v_0$};
\node[below] at (1,-1) {$v_5$};
\node[below] at (3,-1) {$v_4$};
\node[right] at (4,0) {$v_3$};
\node[above] at (3,1) {$v_2$};
\end{tikzpicture}
\caption{$G$.}
\label{factorex}
\end{figure}

\end{document}

The floatrow package and the caption package play roles with one another. The floatrow package can even have command over the caption package, that is why setting any \abovecaptionskip by caption will have no effect. However, we can pass the captionskip=<length> option to the \floatsetup for the floatrow. Only caption will be required to set the font size of captions. I cleaned the code by removing extra/duplicate packages and used a single \floatsetup including the required settings.

AboAmmar
  • 46,352
  • 4
  • 58
  • 127