1

I need to add frames to all my images in my file. Captions must stay outside - below the frames - and the frame-caption spacing should be adjusted to a definite value.

I used \floatstyle{boxed} and \restylefloat{figure} commands with float and floatrow packages. These solved my framing problem, but I could not adjust the frame-caption spacing.

Here is my MWE:

\documentclass[14pt]{article}  
\usepackage[turkish]{babel} 
\usepackage[utf8]{inputenc}  
\usepackage{graphicx}
\usepackage{float}
\floatstyle{boxed}
\restylefloat{figure}   
\begin{document}  
\begin{figure}[h!] 
\centering  
\scalebox{0.6}{\includegraphics{bandstr}}  
\caption{Band structure of a crystal}
\end{figure}
\end{document}  

This code creates a framed image with the caption just under the border, without any spacing: enter image description here How can I adjust the spacing between the caption and the frame border?

  • 3
    Welcome! Without an MWE it is highly unlikely that any work people put into helping you will be useful to you. So if you really can't create an MWE, then you are probably going to have to solve this on your own. People might make some guesses as answers, if they are looking for something to do. But the chances of those answers working in your very complicated document are really quite low. Also, I have no idea what adjusting frame-caption spacing lacked means, even with the addition of an exclamation mark. – cfr Aug 27 '16 at 0:01
  • 14pt is not a valid option. Using h as the sole specifier for a float is a Seriously Bad Idea. – cfr Aug 27 '16 at 1:48
  • @cfr I edited my question, and deleted my first comment. – Yasin Şale Aug 27 '16 at 1:58
  • Thanks. I tidied up your question a little. Please roll-back if you think I misunderstood your meaning. – cfr Aug 27 '16 at 2:22
1

The caption package provides extensive options for caption customisation.

\usepackage{caption}

It can be used to adjust the boxed float style, including the skip between the box and the caption.

\captionsetup[boxed]{skip=20pt}

Note that 20pt is clearly too large. It is used here just to illustrate the effect.

I didn't have a picture of the structure of crystals, so I substituted a couple of cats instead. I hope you'll agree that this is a great improvement.

[The relevant cat codes are available in other answers or on request. However, I must admit that the feline elements of this solution do require TikZ.]

feline partners

\documentclass{article}
\usepackage{graphicx}
\usepackage{float,caption}
\floatstyle{boxed}
\restylefloat{figure}
\captionsetup[boxed]{skip=20pt}
\begin{document}
\begin{figure}% don't use the h specifier on its own!
  \centering
  \includegraphics[width=\linewidth]{cathod}
  \caption{Striped structure of feline partners}
\end{figure}
\end{document}
  • Thanks @crf for your clear and immediate answer. It works well. 15pt is a better choise for my work. Under similar problems there are billions of answers but they are not economic and untidy, at least for me. – Yasin Şale Aug 27 '16 at 2:34
  • Is it possible to adjust frame width with only small changes, since it comes me that frame wells over the text width. This is, unfortunately, an unacceptable situation for our university. – Yasin Şale Aug 27 '16 at 2:57
  • @YasinŞale This is an aspect of the style you've chosen from the float package. From page 11 of the manual The boxed float style puts the float into a box (which is slightly larger than the usual \textwidth). . – cfr Aug 27 '16 at 3:02
  • You're right, i've read that part of manual, but again had a shot. Thanks. – Yasin Şale Aug 27 '16 at 3:11
  • Personally, I wouldn't use the float package if I could help it. I'd stick to a more flexible approach and add the frames within the floating environment, when needed. Or define a custom command. Or follow the package suggestions from the caption manual's discussion of float. You could, obviously, redefine the boxed style, but I don't see what would be gained by that. If you don't really want this style, easier not to use it. – cfr Aug 27 '16 at 3:11

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.