%frsample01 - sample head
%one column non-facing layout
%plain style for figures
%miscellaneous ruled style for textboxes
\input pictures
%\listfiles
\documentclass{book}

\usepackage{calc}
\usepackage{tabularx,array}
\usepackage{floatpagestyle}

\IfFileExists{pstricks.sty}{\usepackage{pstricks}\psset{unit=1pt}}{}

%load floatrow
\usepackage[font=small,footskip=.65\skip\footins,capbesideposition=inside,
   footnoterule=limited,margins=centering,captionskip=5pt,facing=yes,
   capbesidesep=quad,floatrowsep=quad]{floatrow}
\marginparwidth0pt
\usepackage{listpen}
% new float
\DeclareNewFloatType{textbox}{fileext=lor,name=Text,placement=tp}

\DeclareFloatVCode{textprerule}%
  {{\hskip-6pt\vrule depth5ptwidth2pt\hrulefill
    \vrule depth5ptwidth2pt\hspace*{-6pt}}\par\kern-3pt}
\DeclareFloatVCode{textmidrule}%
  {\kern4pt\hrule\kern4pt}
\DeclareFloatVCode{textpostrule}%
  {\par\kern-6pt
   \hbox to\hsize{\hskip-6pt
   \vrule height5ptwidth2pt\hrulefill
   \vrule height5ptwidth2pt\hskip-6pt}\par\relax}

\DeclareFloatStyle{textbox}{style=BOXED,
  frameset={\fboxsep6pt\fboxrule0pt},
  framefit=yes,precode=textprerule,midcode=textmidrule,
  postcode=textpostrule,heightadjust=all}

\DeclareFloatSeparators{textbox}{\kern6pt\vrule\kern6pt}
\DeclareObjectSet{textbox}{\raggedright\parindent15pt\parskip2pt}

\floatsetup[textbox]{style=textbox,capposition=bottom,
   objectset=textbox,capbesidesep=textbox,
   heightadjust=object,valign=t}

\newif\ifWideLayout

%load caption
\usepackage[font=small,labelfont=bf,labelsep=period,
   justification=centerlast]{caption}[2004/11/28]

\newif\ifLoadSubcaption\LoadSubcaptiontrue
\usepackage{subcaption}
\DeclareCaptionSubType[alph]{figure}
\DeclareCaptionSubType[alph]{table}

\providecommand*\rightlast{\leftskip0ptplus1fil
  \rightskip0ptplus-1fil\parfillskip0ptplus1fil}
\providecommand*\leftlast{\leftskip0pt\rightskip0pt\parfillskip0ptplus1fil}
\DeclareCaptionJustification{togglelast}
  {\floatfacing*\rightlast\leftlast}
\captionsetup[floatbeside]{justification=togglelast}
\captionsetup[textbox]{justification=centerlast}

%load subfig
\newif\ifLoadSubfig
%\IfFileExists{subfig.sty}
%{\usepackage[justification=centerlast,captionskip=7pt]{subfig}
%
%\AtBeginDocument{\floatsetup{subfloatrowsep=columnsep}}
%
%\LoadSubfigtrue}{\LoadSubfigfalse}
\LoadSubfigfalse
%better put wrapfig before floatrow


\newif\ifLoadWrapfig
\IfFileExists{wrapfig.sty}
{\usepackage{wrapfig}\LoadWrapfigtrue}{\LoadWrapfigfalse}

\usepackage{floatpagestyle}
\let\wideemptyfloatpage\emptyfloatpage

\newif\ifLoadRotating
\IfFileExists{rotating.sty}
{\usepackage[figuresright]{rotating}

\DeclareMarginSet{expand}%
  {\setfloatmargins
    {\hfil}
    {\hskip-\headsep\hskip-.7\headheight plus1fil}}
\floatsetup[rotfloat]{capbesideposition=right,margins=expand}
\LoadRotatingtrue}{\LoadRotatingfalse}

\providecommand*{\pkg}[1]{\texttt{#1}}
\providecommand*{\com}[1]{\texttt{\char`\\#1}}
\providecommand*{\env}[1]{\texttt{#1}}
\begin{document}

\chapter{Examples in One Column Document}

\begin{sl}
This example shows floats in one-column document.

\emph{Common float settings.}\\
Font for float contents \verb|\small|; skips before foot material half reduced;
skip between caption above/below and object also half reduced;
footnote rule has maximal width$1$\,in (the maximal width defined by \verb|\frulemax| command); separation between
beside caption and object equals to 1\,em; separation between beside float
boxes also equals to 1\,em.
\begin{verbatim}
\usepackage[font=small,footskip=.65\skip\footins,
   capbesideposition=inside,footnoterule=limited,
   margins=centering,captionskip=5pt,facing=yes,
   capbesidesep=quad,floatrowsep=quad]{floatrow}
\end{verbatim}

\emph{Common caption settings.}\\
For caption text used \verb|\small| font, caption label font bold, separated
by period sign, justification centerlast (last line centered).
\begin{verbatim}
\usepackage[font=small,labelfont=bf,labelsep=period,
   justification=centerlast]{caption}
\end{verbatim}

\emph{Common subcaption settings.}\\
Justification centerlast (last line centered). The skip between caption and object enlarged to 7\,pt.
\begin{verbatim}
\usepackage[captionskip=7pt]{subfig}
\end{verbatim}

\emph{Special settings for float types.}

\emph{Textbox.}\\
The new float \env{textbox} uses special ruled style: there are defined three new options
\texttt{textprerule}, \texttt{textmidrule}, and \texttt{textpostrule}.
Please note that, in the case of usage of \env{floatrow} environment where float boxes must be aligned,
the rule below float must have total height no more than 2~pt to get correct alignment,
so first goes compensate vertical space.
\begin{verbatim}
\DeclareFloatVCode{textprerule}%
  {{\hskip-6pt\vrule depth5ptwidth2pt\hrulefill
    \vrule depth5ptwidth2pt\hspace*{-6pt}}\par\kern-3pt}
\DeclareFloatVCode{textmidrule}%
  {\kern4pt\hrule\kern4pt}
\DeclareFloatVCode{textpostrule}%
  {\par\kern-6pt
   \hbox to\hsize{\hskip-6pt
   \vrule height5ptwidth2pt\hrulefill
   \vrule height5ptwidth2pt\hskip-6pt}\par\relax}

\DeclareFloatStyle{textbox}{style=BOXED,
  frameset={\fboxsep6pt\fboxrule0pt},
  framefit=yes,precode=textprerule,midcode=textmidrule,
  postcode=textpostrule,heightadjust=all}

\DeclareFloatSeparators{textbox}{\kern6pt\vrule\kern6pt}
\DeclareObjectSet{textbox}{\raggedright\parindent15pt\parskip2pt}

\floatsetup[textbox]{style=textbox,capposition=bottom,
   objectset=textbox,capbesidesep=textbox,
   heightadjust=object,valign=t}
\end{verbatim}

\emph{Special settings for special float layout.}

\emph{Rotated.}\\
For rotated floats beside caption placed to right side of object;
right side expanded to the top of running head. To delete running head from pages
with rotated float was used \verb|\emptyfloatpage| macro\footnote{In current example the
\protect\com{wideemptyfloatpage} command is the synonym.} and
loaded \pkg{floatpagestyle} package.
\begin{verbatim}
\DeclareMarginSet{expand}%
   {\setfloatmargins
     {\hfil}
     {\hskip-\headsep\hskip-.7\headheight plus1fil}}
\floatsetup[rotfloat]{capbesideposition=right,margins=expand}
\end{verbatim}

\emph{Beside caption.}\\
There was set of changed \verb|\captionsetup| for alignment of beside captions.
There was created special justification: the last line of beside caption flushed to
object side.
\begin{verbatim}
\DeclareCaptionJustification{togglelast}
  {\floatfacing*\rightlast\leftlast}
\captionsetup[floatbeside]{justification=togglelast}
\end{verbatim}

\end{sl}

\input fr-sample

\end{document}
