Kapitel/Chapter 8

Einführung in LaTeX / Introduction into LaTeX

8.7

Defining a new float environment

\documentclass[a5paper]{scrartcl}
\usepackage{floatrow}
\makeatletter
\DeclareNewFloatType{stories}{name=Story,placement=!htb,fileext=box}
\newsavebox\floatb@x
\newlength\FBoxRule \FBoxRule=2pt
\newenvironment{story}[1][\textwidth]
  {\begin{stories}\begin{lrbox}{\floatb@x}%
   \minipage{\dimexpr#1-2\FBoxRule-2\fboxsep\relax}\textbf{Story:} }
  {\endminipage\end{lrbox}\let\fboxrule\FBoxRule%
   \fbox{\usebox\floatb@x}\end{stories}}
\makeatother
\begin{document}
Here's a framed box with a custom width:

\begin{story}
Lorem ipsum dolor sit amet Nullam suscipit nunc eu libero 
blandit porta. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus.
\caption{Lorem ipsum}\label{box:box1}
\end{story}

Here's another one with the default width:

\begin{story}[0.5\linewidth]
Lorem ipsum dolor sit amet Nullam suscipit nunc eu libero 
blandit porta. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus.
\caption{Lorem ipsum part deux}\label{box:box2}
\end{story}

\makeatletter
\listof{stories}{List of stories}
\end{document}

Caption in the outer marginpar

\documentclass[twoside]{report}
\usepackage{geometry,caption,floatrow}
\geometry{showframe=true,includemp,marginparwidth=5cm,marginparsep=1em}
\captionsetup{singlelinecheck=false}
\floatsetup[widefigure]{floatwidth=\textwidth,capposition=beside,
   capbesideposition={bottom,outside},margins=hangoutside,facing=yes,
   capbesidewidth=\marginparwidth}
\begin{document}
  \begin{figure*}
    \centering
    \rule{5cm}{3cm}
    \caption{Wide figure with the settings of float box width
             floatwidth=\texttt{\textbackslash textwidth}; caption
             beside object (on the margins), aligned by top of graphics.}
  \end{figure*}
\clearpage%%%%%%%%%%%%%%%%%%%%%%%%%%%

  \begin{figure*}
    \centering
    \rule{5cm}{3cm}
    \caption{Wide figure with the settings of float box width
             floatwidth=\texttt{\textbackslash textwidth}; caption
             beside object (on the margins), aligned by top of graphics.}
  \end{figure*}
\end{document}

Zurück zur Hauptseite/Back to main page
Copyright $Id: chapter08.html 2 2022-12-28 16:38:18Z voss $