KOMA-Script 標題旁邊和自訂浮動

KOMA-Script 標題旁邊和自訂浮動

在 KOMA-Script 報告中,我想使用自訂浮點數進行演算法,並顯示一個algorithmic環境,​​並在其旁邊而不是下方顯示標題。除了我必須將 a 包裝起來algorithmicparbox避免編譯器錯誤之外, -floatscaptionbeside還有一個問題float

\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}

輸出

內建浮球和float內建浮球有什麼不同?我怎樣才能得到figure所有事情的類似結果?

答案1

KOMA腳本不需要額外的套件來定義新的浮動環境,因為它有自己的機制:

\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}

該命令\DeclareNewTOC及其選項的解釋見scrguien.pdf第 13.5 節。

答案2

float包似乎與許多其他套件和類別存在輕微的不相容性。您的範例按預期工作newfloat包裹。

\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}

在此輸入影像描述

相關內容