1

I'm trying to write an article with both figures and algorithms. The commands related to images should be these:

\usepackage{float}
\usepackage{graphicx}
\usepackage[margin=1.5cm]{caption}
\restylefloat{figure}

Instead, the code related to algorithms should be this:

\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

Here's the problem: before introducing these last commands for pseudocode, the style for images was the figure alone with a caption that had a lower width than the rest of the text, while after introducing these lines images basically adopted the same graphical style of the algorithms:

Figure with algorithm's graphical style

Do you know what I could do to get back standard figures' graphical style?

3
  • Welcome to TeX.SX! Please, add a MWE instead of just code snippets. People here then can reproduce your problem and try to help you.
    – AboAmmar
    Feb 2, 2015 at 12:58
  • While we want to help you, somehow, I failed to understand the problem even after several readings. Use of "Instead" at the start of second paragraph complicated the comprehension further. Please provide an MWE. And welcome to TeX.SE.
    – Masroor
    Feb 2, 2015 at 13:04
  • Thanks a lot to both of you, but the answer solved the problem. Next time, I will provide an MWE! :) Feb 3, 2015 at 3:23

1 Answer 1

3

You have to simply remove the line

\restylefloat{figure}

In fact, you should have something like

\documentclass{article}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{float}
\usepackage{graphicx}
\usepackage[margin=1.5cm]{caption}
\restylefloat{figure}

\begin{document}

\begin{figure}
  \caption{A figure}
\end{figure}

\begin{algorithm}
  \caption{An algorithm}
\end{algorithm}

\end{document} 

which produces the following output

enter image description here

Removing that line, you get instead

enter image description here

The problem arises from the fact that the algorithm package redefines the float style to be ruled and, when you issue

\restylefloat{figure}

the ruled style is also applied to the figure float.


If, for some reason, you have to keep that line in your document, the solution is to load algorithm after that line.

You must log in to answer this question.

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