Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In a KOMA-Script report, I want to use a custom float for algorithms and display an algorithmic-environment with a caption right next to it instead of below. Apart from the fact that I have to wrap the algorithmic in a parbox to avoid compiler errors, captionbeside has a problem with float-floats:

\documentclass{scrreprt}
\usepackage{float}
\floatstyle{plain}
\newfloat{myfigure}{t}{myfigure}
\begin{document}
% Works as expected: Left & Right on same line.
\begin{figure}
    \begin{captionbeside}{Right}Left\end{captionbeside}
\end{figure}
% Doesn't work: Left on one line, Right below
\begin{myfigure}
    \begin{captionbeside}{Right}Left\end{captionbeside}
\end{myfigure}
\end{document}

output

What's the difference between built-in floats and float floats? How can I get the figure-like result for everything?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

With KOMA-Script there's no need for an additional package in order to define new floating environments as it has its own mechanism:

\documentclass{scrreprt}

\DeclareNewTOC[
  type=myfigure,
  types=myfigures,
  float,
  floatpos=t,
  name=My Figure,
  listname={List of my Figures},
  counterwithin=chapter
]{lomf}

\begin{document}

\chapter{foo}

\begin{figure}[h]% positioning parameter just for the example
    \begin{captionbeside}{Right}Left\end{captionbeside}
\end{figure}

\begin{myfigure}[h]% positioning parameter just for the example
    \begin{captionbeside}{Right}Left\end{captionbeside}
\end{myfigure}

\end{document}

The command \DeclareNewTOC and its options are explained in scrguien.pdf section 13.5.

share|improve this answer
    
ah, that's even better, thanks –  pascal Apr 2 '13 at 21:28
add comment

The float package seems to introduce slight incompatibilities with lots of other packages and classes. Your example works as intended with the newfloat package.

\documentclass{scrreprt}

\usepackage{newfloat}
\DeclareFloatingEnvironment[placement=t]{myfigure}

\begin{document}

\chapter{foo}

\begin{figure}[h]% positioning parameter just for the example
    \begin{captionbeside}{Right}Left\end{captionbeside}
\end{figure}

\begin{myfigure}[h]% positioning parameter just for the example
    \begin{captionbeside}{Right}Left\end{captionbeside}
\end{myfigure}

\end{document}

enter image description here

share|improve this answer
    
Additional note: KOMA-Script package scrhack. –  Speravir Apr 2 '13 at 14:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.