
在 KOMA-Script 報告中,我想使用自訂浮點數進行演算法,並顯示一個algorithmic
環境,並在其旁邊而不是下方顯示標題。除了我必須將 a 包裝起來algorithmic
以parbox
避免編譯器錯誤之外, -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}