Graphics, Figures & TablesSpace between algorithm body and caption

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sercan
Posts: 5
Joined: Wed Dec 23, 2009 11:52 pm

Space between algorithm body and caption

Post by sercan »

Hello,

I am using algorithm package with style "boxed". The caption is too close to the box of the algorithm. How can I add some space between algorithm body and caption?

Thanks in advance...

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Space between algorithm body and caption

Post by sommerfee »

If you load the caption package, you could just use

Code: Select all

\captionsetup[boxed]{skip=6pt}
after loading the caption package. (The default is 2pt)

If you won't use the caption package, you need to copy the relevant code (which is \fs@boxed) out of the float package into the preamble of your document and adapt it.
sercan
Posts: 5
Joined: Wed Dec 23, 2009 11:52 pm

Space between algorithm body and caption

Post by sercan »

sorry, I am not so familiar with the environment.

I have a block like this :

Code: Select all

\begin{algorithm}
\caption{Caption ...}
....
\end{algorithm}
where should I put \captionsetup[boxed]{skip=6pt} expression?
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Space between algorithm body and caption

Post by sommerfee »

sercan wrote:where should I put \captionsetup[boxed]{skip=6pt} expression?
Right after \usepackage[...]{caption} in your document preamble. For example:

Code: Select all

\documentclass{article}

\usepackage{float}
\floatstyle{boxed}
\restylefloat{table}

\usepackage[labelfont=bf]{caption}
\captionsetup[boxed]{skip=6pt}

\begin{document}

\begin{table}[!ht] \def\B#1{$\displaystyle{n\choose#1}$}
\begin{center} \begin{tabular}{c|cccccccc}
$n$&\B0&\B1&\B2&\B3&\B4&\B5&\B6&\B7\\ \hline
 0 & 1\\
 1 & 1&1\\
 2 & 1&2&1\\
 3 & 1&3&3&1\\
 4 & 1&4&6&4&1\\
 5 & 1&5&10&10&5&1\\
 6 & 1&6&15&20&15&6&1\\
 7 & 1&7&21&35&35&21&7&1
\end{tabular} \end{center}
\caption{Pascal's triangle. This is a re-styled \LaTeX\ \texttt{table} with \texttt{skip=6pt}.}
\end{table}

\end{document}
sercan
Posts: 5
Joined: Wed Dec 23, 2009 11:52 pm

Re: Space between algorithm body and caption

Post by sercan »

Thank you sommerfee.

It works just fine for algorithms. However, my other captions (for figures and tables) are also affected. Can I force this setting to be applied just for algorithms?
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Space between algorithm body and caption

Post by sommerfee »

sercan wrote:However, my other captions (for figures and tables) are also affected.
Yes, this setting affects all "boxed" floats.
Can I force this setting to be applied just for algorithms?
Use \captionsetup[algorithm]{skip=...} instead.
sercan
Posts: 5
Joined: Wed Dec 23, 2009 11:52 pm

Re: Space between algorithm body and caption

Post by sercan »

no, i used \captionsetup[algorithm]{skip=...} but it still affects figures and tables.

interestingly, figures seems different than before :(
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Space between algorithm body and caption

Post by sommerfee »

sercan wrote:no, i used \captionsetup[algorithm]{skip=...} but it still affects figures and tables.
It seems that either your document class or one of your packages is incompatible to the caption package.

Are you able to give me a small but complete example which shows the problem?
sercan
Posts: 5
Joined: Wed Dec 23, 2009 11:52 pm

Re: Space between algorithm body and caption

Post by sercan »

I think it is something else related to my environment.
Adding the line \usepackage{caption} is enough the change some pieces.

But \captionsetup[algorithm]{skip=...} works just fine. I have used this for different font sizes, only algorithm captions are affected with new font size.

Thank you sommerfee, you have been extremely helpful :D
Post Reply