summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-02-16 21:13:41 +0000
committerKarl Berry <karl@freefriends.org>2022-02-16 21:13:41 +0000
commit690674172d6290861ee9bc5043f6778ebf2418dc (patch)
tree157dafd5cba5bec817f2f8b9341e9f1196c31357
parent25748faf344e9457fa0898b9b4cd76f0befb6121 (diff)
wrapfig2 (16feb22)
git-svn-id: svn://tug.org/texlive/trunk@62039 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/wrapfig2/README.txt5
-rw-r--r--Master/texmf-dist/doc/latex/wrapfig2/commodilla.jpgbin137378 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/wrapfig2/stele-todi-small.jpgbin0 -> 64157 bytes
-rw-r--r--Master/texmf-dist/doc/latex/wrapfig2/wrapfig2.pdfbin758679 -> 697282 bytes
-rw-r--r--Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx917
-rw-r--r--Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty168
6 files changed, 683 insertions, 407 deletions
diff --git a/Master/texmf-dist/doc/latex/wrapfig2/README.txt b/Master/texmf-dist/doc/latex/wrapfig2/README.txt
index 720a426f33f..368a0784d04 100644
--- a/Master/texmf-dist/doc/latex/wrapfig2/README.txt
+++ b/Master/texmf-dist/doc/latex/wrapfig2/README.txt
@@ -1,5 +1,5 @@
%%%% README.txt file
-This README.txt for package wrapfig2[2022-01-26 v.5.0.7 ...]
+This README.txt for package wrapfig2[2022-02-16 v.6.0.0 ...]
This work is author maintained
@@ -27,6 +27,9 @@ older than 1st January 2019. In any case this package loading is
aborted in order to avoid conflicts, and in some other circumstances;
the error messages describe why the process was aborted.
+Version 6 of this package accepts options in the form key=value.
+Options are available to fall back to version 5 and version 4.
+
Claudio Beccari
claudio dot beccari at gmail dot com \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/wrapfig2/commodilla.jpg b/Master/texmf-dist/doc/latex/wrapfig2/commodilla.jpg
deleted file mode 100644
index 4c8dc01e2e9..00000000000
--- a/Master/texmf-dist/doc/latex/wrapfig2/commodilla.jpg
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/wrapfig2/stele-todi-small.jpg b/Master/texmf-dist/doc/latex/wrapfig2/stele-todi-small.jpg
new file mode 100644
index 00000000000..8f85df10a85
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/wrapfig2/stele-todi-small.jpg
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/wrapfig2/wrapfig2.pdf b/Master/texmf-dist/doc/latex/wrapfig2/wrapfig2.pdf
index dcbb079d64f..d8b27c3e18a 100644
--- a/Master/texmf-dist/doc/latex/wrapfig2/wrapfig2.pdf
+++ b/Master/texmf-dist/doc/latex/wrapfig2/wrapfig2.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx b/Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx
index 55147dcd015..dbcec7a0c62 100644
--- a/Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx
+++ b/Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx
@@ -45,7 +45,7 @@ wrapfig2.sty and wrapfig2.pdf, plus this file README.txt.
%<+package>\ProvidesPackage{wrapfig2}%
%^^A<+readme>File README.txt for package wrapfig2
%<*package|readme>
- [2022-01-26 v.5.0.7 Wrap text around figures, tables, framed text blocks]
+ [2022-02-16 v.6.0.0 Wrap text around figures, tables, framed text blocks]
%</package|readme>
%<*driver>
%
@@ -65,6 +65,7 @@ wrapfig2.sty and wrapfig2.pdf, plus this file README.txt.
\date{Version \fileversion~--~Last revised \filedate.}
%
\providecommand*\diff{\mathop{}\!\mathrm{d}}
+\providecommand*\ped[1]{\ensuremath{_{\mathrm{#1}}}}
\renewcommand\meta[1]{{\normalfont\textlangle\textit{#1}\textrangle}}
\renewcommand\marg[1]{\texttt{\{\meta{#1}\}}}
\providecommand\opz{}
@@ -156,7 +157,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%
% \begin{abstract}
% This new package \pack{wrapfig2} is a fork that extends Donald
-% Arseneau's package \pack{wrapfig} (version 2.6, dated 2003) by
+% Arseneau's package \pack{wrapfig} (version 3.6, dated 2003) by
% adding some \LaTeXiii definitions that accept a final optional star;
% its presence changes the meaning of the first optional
% argument so that it becomes a correction to the number of lines
@@ -166,8 +167,9 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% to wrap a small framed text block on a coloured background; the
% philosophy of this new environment is similar to that of the
% other two environments, but the syntax was different with
-% version~4.0 of this package, and is very similar with this
-% version 5.0. A fall back option is available for backwards
+% version~4 of this package, and is very similar with
+% version 5.0; a further important enhancement is implemented
+% in version~6. Fall back options are available for backwards
% compatibility.
% \end{abstract}
%
@@ -189,14 +191,12 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The purpose of this package is manyfold. On one side it tries
-% to modernise the original software by Donald Arseneau by
-% upgrading it to the \LaTeXiii modern language. On another it
+% to upgrade the original software by Donald Arseneau by
+% using some parts of the \LaTeXiii modern language. On another it
% creates a new environment, with the same philosophy
% of the original Arseneau's ones, such that a document author
-% can emphasise short blocks of text by framing them while
-% typesetting the text on a coloured background by means of
-% the \pack{curve2e} functionalities, and wrapping this
-% inserted text with the surrounding main text.
+% can emphasise short blocks of wrapped text by framing them while
+% typesetting the text on a coloured background.
%
% The original software had some idiosyncrasies; Donald Arseneau
% described them in the documentation of his package; we are sorry
@@ -223,15 +223,16 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% section; or at the beginning of a chapter that starts with plain
% text, in particular just at the beginning of the first paragraph.
%
-% The code of this package does very little if anything to correct
+% The code of this package does very little, if anything, to correct
% such idiosyncrasies. They are caused by the limitations of the
% \cs{ShipOut} \LaTeXe kernel macro, and very little we were able
% to do in addition to what Arseneau already did.
%
-% Another purpose of this package is to add an optional argument
+% Another purpose of this package is to add another optional argument
% so that the \meta{number of indented lines} argument does not mean
% the total number, but the correction number to add-to or subtract-from
% the value computed by the default mechanism devised by Arseneau.
+%
% We assume that most users first use the software to insert an object
% to be wrapped by the surrounding text without specifying any value
% with the specific optional argument; then they evaluate the result,
@@ -248,28 +249,33 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% to a user who was asking for such an arrangement; the solution
% resorted to a specific use of the \Env{wrapfigure} environment and
% used the \Env{tcolorbox} environment.
+%
% We thought that an \emph{ad hoc} solution would be a better one,
% since the parameters to be used for a figure have nothing or
% little to do with a text, therefore most of them would be useless
% with a wrapped text. Nevertheless the \meta{location} of the wrapped
% text and the optional correction of the indented lines number would
% still be necessary. We added also the possibility of optionally
-% specifying the measure of the wrapped text, even if this measure
-% should not be too different from a half the wrapping text measure.
+% specifying the measure of the wrapped text, even if it
+% should not be too different from a half of the wrapping text measure.
% In facts, with a value too different from \texttt{0.5\cs{linewidth}}
% either the wrapped text has problems with inter word spaces and
% hyphenation because of the small measure, or, on the opposite, the
% indented lines of the wrapping text would have similar problems.
%
-% Notice that the first implementation of this package, version~4.0,
+% Notice that the first implementation of this package, version~4,
% achieved the desired result but there were two drawbacks: $(a)$
-% the syntax was different from that of the other environments,
+% the syntax was rather different from that of the other environments,
% and $(b)$ any possible caption was typeset within the same
-% framing environment. In version~5.0 both drawbacks were
+% framing environment. In version~5 both drawbacks were
% eliminated, but since the environment syntax is different,
% in oder to assure backwards compatibility a package option
-% was defined in order to fall back to the previous version~4.0
-% behaviour.
+% was defined in order to fall back to the previous version~4
+% behaviour. In version 6.0 the \Env{wraptext} environment was
+% further enhanced so as to accept several \texttt{key=value} settings
+% concerned wit the text appearance, the colours, and other details
+% relative to the wrapping process. Again another fall back option
+% was defined in order to use the same functionalities of version~5.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Environment syntax}
@@ -284,9 +290,9 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% requires the first four optional and mandatory arguments to be
% maintained identical. When the optional star is specified, the
% \meta{indented lines number} is interpreted as the correction to the
-% computed number.
+% computed value.
%
-% Notice the different syntax in version 4.0 and version 5.0 of the
+% Notice the different syntax in versions~4, 5, and~6 of the
% \Env{wraptext} syntax.
%
% \begin{ttsintassi}\setfontsize{8.00}
@@ -298,40 +304,52 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\qquad\meta{table}
%\Eambiente{wraptable}
%~
-%\textnormal{\color{red}Package option \opt{WFold} required for backwards compatibility with version 4.0.*}.
+%\textnormal{\color{red}Package option \opt{WFold} required for backwards compatibility with version 4.*}.
%~
%\Bambiente{wraptext}\oarg{location}\barg{width}\aarg{indented line number correction}\parg{caption label}
%\qquad\meta{text to frame}
%\Eambiente{wraptext}
%~
-%\textnormal{\color{red}No package option required for version 5.0.*}.
+%\textnormal{\color{red}Package option \opt{WFfive} required for backwards compatibility with version 5.*}.
%~
-%\Bambiente{wraptext}\oarg{indented lines number correction} \marg{location} \oarg{overhang} \oarg{width}
+%\Bambiente{wraptext}\oarg{indented lines number correction} \marg{location} \oarg{overhang} \marg{width}
%\qquad \meta{optional colour settings}
-%\qquad\cs{includeframedtext}\marg{text to frame}\Oarg{\meta{frame thickness},\meta{frame separation}}
+%\qquad\cs{includeframedtext}\oarg{insertion measure}\marg{text to frame}\oarg{\meta{frame thickness},\meta{frame separation}}\oarg{radius}
+%\Eambiente{wraptext}
+%~
+%\textnormal{\color{red} No package option required for version~6.*}.
+%~
+%\Bambiente{wraptext}\oarg{indented lines number correction}\marg{location}\oarg{overhang}\marg{width}
+%\qquad \meta{optional style settings}
+%\qquad\cs{includeframedtext}\oarg{insertion measure}\marg{text to frame}\oarg{settings}\oarg{radius}
%\Eambiente{wraptext}
% \end{ttsintassi}
%^^A
-% Please notice that both syntaxes, thanks to differently
+% Please notice that all three syntaxes, thanks to differently
% delimited optional arguments with peculiar default values,
% become very similar when such optional arguments are reduced
% to a minimum; only the \meta{location} argument is delimited
% by brackets with the old version and with braces with the newer
-% one.
+% ones.
%
% It may be useful to compare the \cs{includeframedtext} macro,
% used to insert a framed test into a \Env{wraptext} environment,
-% with \cs{includegrphics}, used to insert an external image into
+% with \cs{includegraphics}, used to insert an external image into
% a \Env{figure} environment. Their functions are similar even if
% they refer to different objects to include. Their codes are
% obviously very different and the latter is much more complex
% than the former. The solution for a framed text used by
-% version~4.0 was inspired by the information found on
+% version~4 was inspired by the information found on
% \texttt{texstackexchange} that used the very elaborate \Env{tcolorbox}
-% environment; version~5.0 uses instead a much simpler command
+% environment; version~5 uses instead a much simpler command
% \cs{framedbox} based on the \pack{curve2e} package macro
-% \cs{Curve}. As it can be seen, the logic behind these different
-% macros are very similar.
+% \cs{Curve}. Version 6.0 admits many settings, not just the
+% \meta{frame thickness} and the space around the framed text, but
+% several others ones collectively indicated with \meta{settings};
+% such settings refer to colours, dimensions, styles, and so on,
+% relative to the text and to the frame; moreover they are set by
+% means of the \texttt{key=value} syntax. As it can be seen, the
+% logic, not the code, behind these different macros are very similar.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Examples}
@@ -345,9 +363,19 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \subsection{A wrapped figure}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
+%
+%\begin{wrapfigure}{r}{50mm}
+%\centering\unitlength=1mm
+%\begin{picture}(40,30)
+%\polygon(0,0)(40,0)(40,30)(0,30)
+%\Line(0,0)(40,30)\Line(0,30)(40,0)
+%\end{picture}
+%\caption{A rectangle with its diagonals}\label{fig:figure}
+%\end{wrapfigure}
+%{\itshape \kant[1]}
% The code used to type figure~\ref{fig:figure} is the following:
%
-%\begin{flushleft}\obeylines%
+%\begin{flushleft}\ttfamily\obeylines%
%\noindent\Bambiente{wrapfigure}\Marg{r}\Marg{50mm}
%\cs{centering}\cs{unitlength}=1mm
%\Bambiente{picture}\texttt{(40,30)}
@@ -362,33 +390,10 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% No asterisk was used because the package succeeded to correctly
% compute the necessary number of indented lines.
%
-%\begin{wrapfigure}{r}{50mm}
-%\centering\unitlength=1mm
-%\begin{picture}(40,30)
-%\polygon(0,0)(40,0)(40,30)(0,30)
-%\Line(0,0)(40,30)\Line(0,30)(40,0)
-%\end{picture}
-%\caption{A rectangle with its diagonals}\label{fig:figure}
-%\end{wrapfigure}
-%{\itshape \kant[1]}
-%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{A wrapped table}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Wrapping a small table is a little more difficult than wrapping
-% a figure, because the width of the inserted object is not known
-% exactly in advance and is difficult to estimate; therefore it is
-% possible that several trial compilations are necessary. In any
-% case a \cs{centering} command might help to center the table
-% within the indention of the wrapping text. Nevertheless the
-% software can compute the object width if a zero value is specified
-% or if the \meta{width} parameter is completely omitted together
-% with its braces; this second possibility is a feature of this
-% package, that uses a \LaTeXiii property by which even a braced
-% argument can be treated as an optional argument with a predefined
-% default value; see below more details about this feature.
-%
-%\begin{wraptable}{l}
+%\begin{wraptable}[-1]{l}*
%\centering
% \begin{tabular}{cc}
% \hline
@@ -396,14 +401,14 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% Third & Fourth\\
% \hline
%\end{tabular}
-%\caption{A small table}
+%\caption{A small table}\label{tab;small-table}
%\end{wraptable}
%{\itshape \kant[2]}
%
-% The above wrapped small table has been typeset by means of the
-% following code.
+% The wrapped small table~\ref{tab;small-table} has been typeset
+% by means of the following code.
%\begin{flushleft}\ttfamily\obeylines
-%\Bambiente{wraptable}\Marg{l}
+%\Bambiente{wraptable}\Oarg{-1}\Marg{l}*
%\quad\cs{centering}
%\quad\Bambiente{tabular}\Marg{cc}
%\qquad\cs{hline}
@@ -413,20 +418,21 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\quad\Eambiente{tabular}
%\quad\cs{caption}\Marg{A small table}
%\Eambiente{wraptable}
-%\Marg{\cs{\itshape} \cs{kant}\Oarg{2}}
+%\Marg{\cs{itshape} \cs{kant}\Oarg{2}}
%\end{flushleft}
%
-% You notice the absence of the braced width value; as said above,
-% this braced value is optional, and the software autonomously
-% computes the width of the wrapped object. This feature may be
-% useful in many instances, although a smart use of
-% this width parameter might yield better looking results.
-%
-% On the opposite if the user estimates that the table with its
-% caption might use 5~lines, and specified such a value as the
-% first (optional) argument to the environment, the result would
-% be the following poor one, with the last caption line overlapping the
-% wrapping text.
+% Wrapping a small table is a little more difficult than wrapping
+% a figure, because the width of the inserted object is not known
+% exactly in advance, and it is difficult to estimate; therefore
+% it might be necessary to execute several trial compilations. In any
+% case a \cs{centering} command might help to center the table
+% within the indention of the wrapping text. Nevertheless the
+% software can compute the object width if a zero value is specified,
+% or if the \meta{width} parameter is completely omitted together
+% with its braces; this second possibility is a feature of this
+% package, that uses a \LaTeXiii property by which even a braced
+% argument can be treated as an optional argument with a predefined
+% default value; see below more details about this feature.
%
%\begin{wraptable}[5]{l}
%\centering
@@ -436,12 +442,24 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% Third & Fourth\\
% \hline
%\end{tabular}
-%\caption{A small table}
+%\caption{A small table}\label{tab:wrong-wrapped-table}
%\end{wraptable}
%{\itshape \kant[2]}
%
+% Notice the absence of the braced width value; as said above,
+% this braced value is optional, and the software autonomously
+% computes the width of the wrapped object. This feature may be
+% useful in many instances, although a smart use of
+% this width parameter might yield better looking results.
+%
+% On the opposite if the user estimates that the table with its
+% caption might use 5~lines, and specified such a value as the
+% first (optional) argument to the environment, the result is
+% shown in table~\ref{tab:wrong-wrapped-table}, but it is a very
+% poor one, with the last caption line overlapping the wrapping text.
+%
%^^A\goodpagebreak
-% \newpage
+%^^A \newpage
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{A wrapped text}
@@ -457,15 +475,15 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \Bamb{wraptext}\Marg{l}
% \cs{includeframedtext}\Marg{\ttfamily Text, text, text, text, text, text, text, text, text, text, text.}
% \Eamb{wraptext}
-% \Marg{\itshape \cs{kant}[3]}
+% \Marg{\cs{itshape} \cs{kant}[3]}
%\end{flushleft}
%
-% The result is the same as that obtainable with version~4.0 of this
-% package where the \meta{location} argument specification is braced
+% The result is the same as that obtainable with version~4 of this
+% package, but the \meta{location} argument specification is braced
% instead of bracketed.
%
-% If a caption is specified, version~4.0 would print it within the
-% framed box, while version 5.0 prints it outside the framed box.
+% If a caption is specified, version~4 would print it within the
+% framed box, while versions~5 and~6 print it outside the framed box.
%
% \begin{wraptext}{r}
% \includeframedtext{Text, text, text, text, text, text, text, text, text, text, text.}
@@ -473,7 +491,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \end{wraptext}
% {\itshape \kant[3]}
%
-% The further feature introduced by version~5.0.* is the
+% The further feature introduced by version~5 is the
% possibility of choosing the colours for all three elements of the
% framed text; if within the environment \Env{wraptext} and before using
% \cs{includeframedtext} the following colours are set, it is
@@ -484,31 +502,152 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\cs{SetWFbgd}\marg{background colour}
%\cs{SetWFtxt}\marg{text colour}
% \end{ttsintassi}
-%See figure~\ref{fig:framed text}
+% Such commands, in version~6, are already taken care by the relevant
+% \texttt{key=value} options. With version~5 these are user commands.
+% See figure~\ref{fig:framed text} typeset with various version~6
+% options.
%
%\begin{figure}
-%\includeframedtext[0.45\linewidth]{Text}\hspace{9mm}%
-%\includeframedtext[0.45\linewidth]{Text}[3pt,1ex]\\[2ex]
-%{\SetWFtxt{red}\includeframedtext[0.45\linewidth]{Text}[2pt,0.6em]}\hspace{9mm}%
-%{\Large\includeframedtext[0.45\linewidth]{Text}[1pt,1ex]}\\[2ex]
-%{\SetWFbgd{yellow}\includeframedtext[0.45\linewidth]{Text}}\hspace{9mm}%
-%{\SetWFfrm{blue}\SetWFbgd{yellow}\includeframedtext[0.45\linewidth]{Text}[3pt,1ex]}%
+%\makebox[\textwidth]{\includeframedtext{Text}[insertionwidth=0.45\linewidth]
+%\hfill
+%\includeframedtext{Text}[insertionwidth=0.45\linewidth,fboxrule=3pt]}\\[2ex]
+%\makebox[\textwidth]{\includeframedtext{Text}[insertionwidth=0.45\linewidth,textcolor=red,fboxrule=2pt]
+%\hfill
+%\includeframedtext{Text}[insertionwidth=0.45\linewidth,fontstyle=\Large]}\\[2ex]
+%\makebox[\textwidth]{\includeframedtext{Text}[insertionwidth=0.45\linewidth,backgroundcolor=yellow]
+%\hfill
+%\includeframedtext{Text}[insertionwidth=0.45\linewidth,framecolor=blue,backgroundcolor=yellow,fboxrule=1mm]}\\[2ex]
+% \makebox[\textwidth]{\includeframedtext{Text}[insertionwidth=0.5\linewidth, fboxrule=0pt, backgroundcolor=cyan, textcolor=white, fontstyle=\Huge\bfseries]}
%\caption{Some framed text boxes with different dimension parameters,
% different font size, and different colours}\label{fig:framed text}
%\end{figure}
%
+% Figure~\ref{fig:framed text} used the following code, where it is
+% evident that the \cs{includeframedtext} command is available even
+% outside the \Env{wraptext} environment.
+%\begin{flushleft}\ttfamily\obeylines
+%\Bambiente{figure}
+%\cs{makebox}[\cs{textwidth}]\Marg{\cs{includeframedtext}\Marg{Text}\%
+%\qquad [insertionwidth=0.45\cs{linewidth}]
+%\quad\cs{hfill}
+%\quad\cs{includeframedtext}\Marg{Text}\%
+%\quad [insertionwidth=0.45\cs{linewidth},fboxrule=3pt]}\cs{\char92}[2ex]
+%\%
+%\cs{makebox}[\cs{textwidth}]\Marg{\cs{includeframedtext}\Marg{Text}\%
+%\quad [insertionwidth=0.45\cs{linewidth},textcolor=red,fboxrule=2pt]
+%\quad\cs{hfill}
+%\quad\cs{includeframedtext}\Marg{Text}\%
+%\qquad[insertionwidth=0.45\cs{linewidth},fontstyle=\cs{Large}]}\cs{\char92}[2ex]
+%\%
+%\cs{makebox}[\cs{textwidth}]{\cs{includeframedtext}\Marg{Text}\%
+%\quad[insertionwidth=0.45\cs{linewidth}, backgroundcolor=yellow]
+%\quad\cs{hfill}
+%\quad\cs{includeframedtext}\Marg{Text}\%
+%\qquad[insertionwidth=0.45\cs{linewidth},framecolor=blue,
+%\qquad backgroundcolor=yellow,fboxrule=1mm]}\cs{\char92}[2ex]
+%\%
+% \cs{makebox}[\cs{textwidth}]{\cs{includeframedtext}\Marg{Text}\%
+%\quad [insertionwidth=0.5\cs{linewidth}, fboxrule=0pt,\%
+%\qquad backgroundcolor=cyan,textcolor=white,fontstyle=\cs{Huge}\cs{bfseries}]}
+%\cs{caption}\Marg{Some framed text boxes ... different colours}
+%\cs{label}\Marg{fig:framed text}
+%\Eambiente{figure}
+%\end{flushleft}
+%
+%
+% As it is possible to notice from figure~\ref{fig:framed text},
+% version~6 adds another facility; the colours and dimensions of the
+% elements of the wrapped objects are inserted as
+% \textit{key=value} options to the \cs{includeframedtext} third
+% argument \meta{settings}; its default value is “empty”; the
+% users can introduce as many options as they desire, among the
+% valid ones; if an option is misspelled or its value is not
+% coherent with its nature, either the option is ignored, or an
+% error is raised. The valid options are the following; they are
+% listed in alphabetical order, because the options described with the
+% \texttt{key=value} syntax do not require either a specific order
+% or their presence; the users can therefore specify from zero to
+% nine options.
+%\begin{description}
+%^^A
+%\item{\ttfamily backgroundcolor} sets the background colour among
+% those defined by the default set provided by package \pack{xcolor}.
+% The default colour is a light grey.
+%^^A
+% \item{\ttfamily fboxrule} sets the thickness of the line
+% around the frame; a zero value is allowed, otherwise it should
+% not be smaller than \texttt{0.4pt}; on the opposite it
+% should not be set too large and \texttt{1mm} appears as
+% a thick enough line around the wrapped text.
+%^^A
+% \item{\ttfamily fboxsep} sets the distance of the frame from
+% the wrapped text; by default it is set to \texttt{1ex};
+% also in this case it is better to avoid exaggerations.
+% Notice that the default value depends on the wrapping text
+% font x-height.
+%^^A
+%\item{\ttfamily fontstyle} sets any available \emph{declaration}
+% that changes the characteristics of a font: size, series,
+% shape; it is possible to use also the \cs{usefont} command
+% with all its four arguments, even the font encoding. This
+% \pack{wrapfig2} has available also the \cs{setfontsize}
+% command that can select any size with any font that has
+% available at least a step wise continuous size set; for
+% example the Latin Modern fonts have a stepwise continuous
+% size set, while Computer Modern have available only a discrete
+% size set.
+%^^A
+%\item{\ttfamily framecolor} sets the color of the frame; the colours
+% available are those available with package \pack{xcolor} to which
+% no options have been specified; see its documentation and in case
+% load \pack{xcolor} with the desired options before this package
+% \pack{wrapfig2}. The default colour is a very dark grey.
+%^^A
+%\item{\ttfamily insertionwidth} sets the insertion width; as
+% it was previously specified, if this width is too small
+% or too large it will be automatically reassigned a value
+% within the allowed range.
+%^^A
+%\item{\ttfamily radius} sets the optional radius of the frame
+% rounded “corners”; if it is not specified, such radius is
+% equal to the default value of \cs{fboxsep}. Although it is
+% possible to use it, we suggest to abide from using it.
+%^^A
+% \item{\ttfamily scalefactor} sets the value that establishes
+% a reasonable range of the insertion width; users can specify
+% any value in the range $xy_0 = y\ped{min} \leq y \leq
+% y\ped{max} = y_0/x$ , where $y_0$ is the default value,
+% and $x$ is the scaling factor that by default equals $0.8$;
+% this means $y_0$ equals half the current measure and the
+% inserted wrapped text produces an indentation of the wrapping
+% lines approximately between 60\% and 40\% the current measure;
+% the wrapped text should never have a too short measure and the
+% wrapping indented lines never have a too short measure. If users
+% specify a different value to this key, they might get problems
+% with inter word spacing and of hyphenation.
+%^^A
+%\item{\ttfamily textcolor} sets the text colour among those available
+% among those available with the default set provided by package
+% \pack{xcolor}. The default colour is black.
+%^^A
+%\end{description}
+%
+% This version~6 has a more flexible way compared to version~5
+% to specify the details relative to the framed text, but they are
+% relevant only for the \cs{includeframedtext} command; the syntax
+% for the \Env{wraptext} environment opening command is identical.
% As it was previously shown, the syntax of environment \Env{wraptext}
-% for version~5.0 is practically identical to the one used for the
+% for version~6 and~5 is practically identical to the one used for the
% other two environments; actually, as it can be seen below in
-% the code description of this version~5.0, it has a fairly
+% the code description of version~6 and~5, it has a fairly
% longer definition; it is required by the necessity of avoiding
-% the \cs{caption} redefinition by the adjustments foreseen in
-% version~4.0, but in effects the new definition of the \Env{wraptex}
-% environment uses the same \cs{wrapfloat} and \cs{endwrapfloat}
-% commands.
+% the \cs{caption} changes foreseen in package{wrapfig} when
+% \pack{float} is used to define another floating object, but in
+% effects the new definition of the \Env{wraptext} environment uses
+% the same \cs{wrapfloat} and \cs{endwrapfloat} commands.
%
-% In all cases the \meta{width} parameter is a braced optional
-% argument; for the \Env{wraptext} environment its preset value is
+% In all three cases the \meta{width} parameter is a \emph{braced optional
+% argument}; for the \Env{wraptext} environment its preset value is
% half the column width, that in one column typesetting mode
% coincides with the text width. The wrapped text is typeset
% in justified mode within a \cs{parbox} argument; the
@@ -517,14 +656,14 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% word spacing might be too large; at the same time the measure
% of the mini paragraph cannot be too large, otherwise the indented
% wrapping lines, generally justified, might get a bad word
-% spacing. Therefore it is suggested to avoid specifying the
-% optional \meta{widh} outside the range of 40\% to 60\% the
-% column width. Actually specifying \texttt{0.2\cs{textwidth}}
+% spacing. As it was already explained, it is recoommended to avoid
+% specifying the optional \meta{widh} outside the range of 40\% to 60\%
+% the column width. Actually specifying \texttt{0.2\cs{textwidth}}
% or \texttt{0.4\cs{columnwidth}} when typesetting in two column
% mode produces approximately the same result, because
% \cs{columnwidth} is a little less than half the \cs{textwidth}.
-% In any case version~5.0 of \Env{wrapfig2} resets any specified
-% width outside the above range at the nearest range bound.
+% In any case versions~6 and~5 of \Env{wrapfig2} reset any specified
+% width outside the above range to the nearest range bound.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Remarks}
@@ -532,7 +671,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%
% The syntax of the original environments \amb{wrapfigure} and
% \amb{wraptable} has not been changed, except for a last optional
-% star. The fact that the last braced argument is optional does not
+% star. The fact that the last \emph{braced argument is optional} does not
% change the backward compatibility with the original environments.
%
% Therefore the optional \meta{line number} argument maintains its
@@ -548,29 +687,25 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%
% We tested all of them, but as a (possibly questionable) personal
% choice we prefer to place the wrapped object at the left of the text,
-% without floating it and irrespective of the page number parity.
+% without floating it and irrespective of the folio parity.
+%
+%\begin{wraptext}{l}{0.5\textwidth}%
+%\includegraphics[width=\hsize]{stele-todi-small}
+%\caption{The Todi stela written in Gallic and Latin. Gregorian Etruscan Museum in Rome.}\label{txt:todi-stela}
+%\end{wraptext}
+%{\itshape\kant[4]}
%
% As in the previous examples, we prefer to specify the wrapping
% environment just before a sufficiently long paragraph. Should the
% paragraph be too short to completely wrap the object, all
% the environments are capable of counting the number of used indented
-% lines and to apply the remaining number and the \cs{overhang} amount
+% lines and to apply the remaining number (and the \cs{overhang} amount)
% to the following paragraph(s); in these circumstances
% it might be necessary to recourse to the optional star in order
% to correct the indention, since the mechanism does not consider
% the inter paragraph spacing that \LaTeX introduces only at ship~out
% time.
%
-%\begin{wraptext}{l}
-%\includegraphics[width=\hsize]{commodilla}
-%\caption{A IX century text written in a language half way between
-% Latin and Italian. It is written on the frame of a fresco in the
-% Comodilla catacombs, Rome; an apparently free picture is available
-% from the internet site of the Bibliotheca Augustana in Germany.
-% The text is: «Non dicere ille secrita a bboce».}\label{fig:commodilla}
-%\end{wraptext}
-%{\textit{\kant[4]}
-%
% We avoid also to enter the wrapping environment before paragraphs
% that are close to a page break; this action would tickle the
% idiosyncrasies of the software, and requires moving the wrapping
@@ -584,9 +719,9 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% that a section title falls alone at the bottom of the page and
% the wrapping environment with its wrapping text gets typeset on the next
% page; this of course is not acceptable. We found the place to
-% correct and this version~5.0 more often than not does not
+% correct and versions~6 and~5 more often than not do not
% exhibit any more this “feature”. Unfortunately in some rare cases
-% this “feature” pops up agains; a \cs{newpage} command before the
+% this “feature” pops up again; a \cs{newpage} command before the
% section title solves the problem. This rare feature could be avoided
% if the sectioning commands are redefined; but this would imply
% modifications to a large number of redefinitions due to the large
@@ -597,7 +732,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% does exactly what its name implies: the wrapped object protrudes
% into the adjacent margin exactly by the specified amount. This
% parameter is not available for the \Env{wraptext} environment,
-% or better, it is still available in version~5.0, but we recommend
+% or better, it is still available in versions~6 and~5, but we recommend
% to abide from using it; we believe that a wrapped text logically
% pairs the wrapping text; of course this personal opinion might be wrong.
%
@@ -608,7 +743,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% insertion width can be specified but it should not be too different
% from its default value $y_0$, set to 50\% of the current measure.
% For the standard environments this parameter value appears to be
-% mandatory; actually it is a braced optional argument only for the
+% mandatory; actually it is a braced really optional argument only for the
% redefined environments \env{wrapfigure} and \env{wraptable}.
%
% Matter of facts, for the \Env{wraptext} environment we defined a
@@ -621,20 +756,21 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% the \cs{WFscalefactor} macro, but such resetting is strongly
% discouraged; the default value is~$0.8$.
%
+%\begin{wraptext}{l}
+%\includeframedtext{^^A
+% \foreignlanguage{greek}{Κα᾽γὼ σὲ πατάξας διαλύσω τὸ κρανὶον}}
+% \caption{A sample text in Greek}\label{txt:greek}
+%\end{wraptext}
+%{\itshape\kant[7]}
+%
% If optional parameters are not used and the mandatory ones are
% reduced to a minimum (remember the \meta{width}, in spite of being
% braced is optional) the three environments produce the same results;
% the difference, in spite of the nature of the wrapped object differs
-% only with the environment name. Text~\ref{fig:commodilla} displays
-% an image that contains some text; it is reasonable to insert it with
-% the \Env{wrapfigure} environment, but it is not absurd to insert
-% it with the \Env{wraptext} one.
-%
-%\begin{wraptext}{l}
-%\includeframedtext{%
-% \foreignlanguage{greek}{Κα᾽γὼ σὲ πατάξας διαλύσω τὸ κρανὶον}}\caption{A sample text in Greek}\label{txt:greek}
-%\end{wraptext}
-%{\textit{\kant[7]}
+% only with the environment name. Text~\ref{txt:todi-stela} displays
+% an \emph{image} that contains some text; it is reasonable to insert
+% it with the \Env{wrapfigure} environment, but it is not absurd to insert
+% it with the \Env{wraptext} one as we did with text~\ref{txt:todi-stela}.
%
% The wrapped text may be written also in a foreign language, even
% if it uses a differente alphabet. Evidently this language should
@@ -657,7 +793,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% objects may be defined by means of other packages, such as
% \pack{float}, or classes, such as \class{memoir}. Besides floating,
% the main difference is the name of the caption “label”: Figure, Table,
-% Algorithm, Example, and so on and the lists of such objects.
+% Algorithm, Example, and so on, and the lists of such objects.
%
% If floating is not necessary, this package (as well as the original
% one) allows to use the underlying environment \Env{wrapfloat}
@@ -678,33 +814,33 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\end{flushleft}
%
% By reading the documentation of the original \pack{wrapfig} package,
-% it may be assumed that if the floating \meta{location} codes have to
+% it may be assumed that, if the floating \meta{location} codes have to
% be used, another floating object with the desired \meta{object name}
-% has to be previously defined by means of the functionalities of other
+% has to be previously defined by means of the functionalities of other
% packages or classes. But, if the non floating \meta{location} codes
% are used, the presence of another \meta{floating object} environment
% appears to be unnecessary.
%
-% This is actually possible by “cheating” a little bit; it can be actually
-% wraped any \meta{object} by using the \Env{wrapfigure} environment,
+% This is actually possible by “cheating” a little bit: it can be actually
+% wrapped any \meta{object} by using the \Env{wrapfigure} environment,
% while assigning a different name to the caption label; something
% similar to typeset a small figure within a non floating environment.
% The obvious draw back is that the caption is numbered as a figure.
%
% In order to avoid such drawbacks and to have a real floating
-% \Env{text} environment it is necessary to procede by defining
+% \meta{other object} environment it is necessary to procede by defining
% a new real floating environment with that name. To do this task,
-% \pack{wrapfig2} version~5.0 uses the \pack{float} package.
+% \pack{wrapfig2} versions~5 and~6 use the \pack{float} package.
%
% As it is possible to verify by reading the section where the
% code is documented, the operation is not that simple because
% \pack{float} redefines several internal macros that are incompatible
% with both \pack{wrapfig} and \pack{wrapfig2}. This is why, even
-% with \pack{wrapfig2} in version~5.0, that loads the \pack{float}
-% package, the code for this environment redefines the \cs{caption}
+% with \pack{wrapfig2} in versions~5 and~6, that load the \pack{float}
+% package, the code for this environment redefines the \cs{caption}
% command so that Arseneau had to define some adjusting macros in order
% to deal with something different from what it was with the \LaTeXe
-% kernel. We did not modify what Arseneau defined in although it did not
+% kernel. We did not modify what Arseneau defined, although it did not
% work correctly with the new \Env{text} floating environment. Therefore
% we reinstated the \LaTeXe kernel relevant definitions.
%
@@ -712,32 +848,36 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% necessary also with floating objects defined by other means, for
% example by using the functionalities of \class{memoir}. We admit
% we did not test this package functionality with class
-% \class{memoir}; feedback on this compatibility issue is very
-% welcome
+% \class{memoir}; \textcolor{red}{feedback on this compatibility issue
+% is very welcome}.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section*{Acknowledgements}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% We gratefully thank Donald Arseneau who gave the \TeX community
-% the original \Env{wrapfig} package.
+% the original \Env{wrapfig} package. For what concerns wrapped text,
+% we did not use Arseneau's \pack{framed} package, because we wanted a
+% frame with rounded corners. Nevertheless, while developing our package,
+% we experimented also with his package that yields good results but
+% with the ordinary right angle frame corners.
%
% Thanks to Heinrich Fleck who submitted to our attention the
% \texttt{texstackexchange} message where the problem of wrapping text was
% presented possibly for the first time. The solution presented in
% \texttt{texstackexchange} appears to be oversimple, almost trivial;
-% especially it does not solve the problem of a caption if one is desired
-% under the wrapped text.
-% Moreover the solution of \texttt{texstackexchange} uses an almost
-% trivial usage of the \Env{tcolorbox} environment, that behind the
-% scenes uses a very heavy set of multifunctional macros the offer
-% functionalities are not required for this problem.
+% especially it does not solve the problem of a caption if one is desired
+% to describe that wrapped text.
+% Moreover the solution of \texttt{texstackexchange} used in a very
+% simple way the \Env{tcolorbox} environment, that behind the
+% scenes uses a very heavy set of multifunctional macros that offer
+% functionalities that are not required for this problem.
%
% Warm thanks also to Juan Luis Varona Malumbres for his precious
% feedback and his suggestions.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% \CheckSum{1345}
+% \CheckSum{1411}
% \StopEventually{}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@@ -759,15 +899,14 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% First of all we check if certain packages have already been
% loaded; some of these packages, such as \pack{wrapfig}, that
% might have been previously directly loaded, or might have been
-% loaded by other packages, are incompatible with this new version
-% (and also with the previous versions, but the problem was less
-% serious). That package might have been loaded by other packages,
-% such as \pack{caption} or \pack{subcaption}, that redefine some
-% internals that we did not want to replace so as to avoid other
+% loaded by other packages, are incompatible with this package
+% \pack{wrapfig2}. \pack{wrapfig} might have been loaded by other
+% packages, such as \pack{caption} or \pack{subcaption}, that redefine
+% some internals that we did not want to replace so as to avoid other
% possible incompatibilities. We first check if a specific macro
% with the \texttt{WF} prefix has already been defined; if so,
-% this package loading is aborted with a very evident error
-% message. In contrast the job is not aborted, because the presence
+% this package \emph{loading} is aborted with a very evident error
+% message. In contrast the \emph{job} is not aborted, because the presence
% of the original \pack{wrapfig} package might still be sufficient;
% evidently there will be many errors if some new user commands
% or environments are used.
@@ -786,27 +925,30 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
Package `wrapfig' has already been loaded perhaps \MessageBreak
by other packages, for example caption or subcaption.\MessageBreak
Such packages are incompatible with wrapfig2 \MessageBreak
- Loading `wrapfig2' aborted \MessageBreak
+ Loading of`wrapfig2' is aborted \MessageBreak
****************************************************\MessageBreak
}{You might type X <return> and might get along without\MessageBreak
this package if you don't use the new environment \MessageBreak
- `wraptext'; otherwise you get errors about such \MessageBreak
- environment not being defined; you must kill your job!}
+ `wraptext' and the new commands; otherwise you get \MessageBreak
+ errors about such environment not being defined; \MessageBreak
+ you must kill your job!}
\expandafter\endinput\fi
% \end{macrocode}
% We keep the original definition of the \cs{WF@warning} and the
% original definition of the \opt{verbose} option; but we add the
-% new \opt{WFold} option in order to fall back to the functionalities
-% of the previous version~4.0, at least for what concerns the
-% \Env{swraptext} environment.
+% new \opt{WFold} and \opt{WFfivw} options in order to fall back
+% to the functionalities of the previous version~4 or~5, at least
+% for what concerns the \Env{wraptext} environment.
%
%
% \begin{macrocode}
\def\WF@warning{\PackageWarning{wrapfig2}}
\DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig2}}}
\newif\ifWFnew \let\ifWFnew\iftrue
+\newif\ifWFfive \let\ifWFfive\iffalse
\DeclareOption{WFold}{\let\ifWFnew\iffalse}
+\DeclareOption{WFfive}{\let\ifWFnew\iffalse \let\ifWFfive\iftrue}
\ProcessOptions
% \end{macrocode}
@@ -828,12 +970,13 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% now available directly within the \LaTeXe kernel.
%\end{quote}
% Their availability eases the treatment of the backwards
-% compatibility of this software with the original \pack{wrapfig}
-% functionality. It deals with the mandatory \meta{width} argument
-% of the \Env{wrapfigure}, \Env{wraptable}, the new \Env{wraptext},
-% and \Env{wrapfloat} environments, where it was possible to specify
-% a zero value. Now it is possible to omit it completely because it
-% is a \emph{braced optional argument} with a \texttt{0pt} default value.
+% compatibility of this software with the original \pack{wrapfig} and
+% \pack{wraptable} functionality. It deals with the mandatory
+% \meta{width} argument of the \Env{wrapfigure}, \Env{wraptable},
+% the new \Env{wraptext}, and \Env{wrapfloat} environments, where
+% it was possible to specify a zero value. Now it is possible to
+% omit it completely because it is a \emph{braced optional argument}
+% with a \texttt{0pt} default value.
%
%
% \begin{macrocode}
@@ -845,12 +988,13 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}%
}
\@ifpackageloaded{curve2e}{}{\RequirePackage{curve2e}}
+\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}}
% \end{macrocode}
% Notice that we loaded the \pack{xcolor} package without any option
% in order to avoid option clash errors, and users who want to use
% \pack{xcolor} with options should load it \emph{before} this package
-% \pack{wrapfig2}, version~5.0.*. {\color{red}Users are warned
+% \pack{wrapfig2}, version~5 and~6. {\color{red}Users are warned
% to pay attention to this \pack{color} package loading: they should load
% it neither before nor after loading \pack{wrapfig2}; if they do, they
% receive various warning or error messages because \pack{xcolor}
@@ -858,8 +1002,8 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% explained in the \pack{xcolor} documentation.}
%
% In order to define the new floating object \texttt{text} we have
-% to load the package \pack{float}, but only if version~5.0.*
-% is used; in other words only if the \cs{ifWFnew} switch
+% to load the package \pack{float}, but only if versions~5 or~6
+% ae used; in other words only if the \cs{ifWFnew} switch
% is \texttt{true}.
%
% If the \cs{chapter} command is or is not defined we have to load
@@ -871,24 +1015,25 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \Env{text} environment correctly reset the right counter with the
% right label before the object number.
% \begin{macrocode}
-\ifWFnew
- \floatstyle{plain}
+\ifboolexpr{ bool{WFfive} or bool{WFnew} }%
+ {\floatstyle{plain}%
\ifcsname chapter\endcsname
- \newfloat{text}{tbp}{lotx}[chapter]
- \else
- \newfloat{text}{tbp}{lotx}
+ \newfloat{text}{tbp}{lotx}[chapter]%
+ \else
+ \newfloat{text}{tbp}{lotx}%
\fi
- \floatname{text}{Text}
+ \floatname{text}{Text}% come personalizzare con le diverse lingue?
\let\WF@text@caption\float@caption
-\fi
+ }{}
% \end{macrocode}
%
% If the users wanted to add the \texttt{text} counter to some
-% sectioning command counter reset list they might use the
+% sectioning command counter reset list, they might use the
% \cs{counterwithin} command now available with the recent updates
% of the \LaTeX kernel; see the \LaTeX newsletter~28 for details
-% (terminal command \texttt{texdoc ltnews28}). Its syntax is the following:
+% (terminal command \texttt{texdoc ltnews28}). Its syntax is the
+% following:
%\begin{ttsintassi}
%\cs{counterwithin}\marg{counter}\marg{main counter reset list}
%\end{ttsintassi}
@@ -903,7 +1048,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \begin{macrocode}
\newdimen\wrapoverhang \wrapoverhang\z@
\newdimen\WF@size
-\newcounter{WF@wrappedlines}
+\newcount\c@WF@wrappedlines
\newbox\WF@box
\newbox\NWF@box
\newtoks\WF@everypar
@@ -913,6 +1058,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\let\WF@@everypar\everypar
\newdimen\insertwidth
+\newdimen\radius
\newdimen\WFinsertwidthL
\newdimen\WFinsertwidthH
@@ -922,8 +1068,14 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\def\SetWFbgd#1{\colorlet{WFbackground}{#1}}
\def\SetWFfrm#1{\colorlet{WFframe}{#1}}
\def\SetWFtxt#1{\colorlet{WFtext}{#1}}
+
+
\def\WFsplitdimens#1,#2!{\fboxrule=#1\relax\fboxsep=#2\relax}
+\providecommand\setfontsize{}
+\RenewDocumentCommand\setfontsize{O{1.2} m}{%
+ \fontsize{#2}{\fpeval{#1*#2}}\selectfont}
+
\def\WFscalefactor{0.8}%
\newcommand*\WFscalewidth{%
\WFinsertwidthL=\fpeval{\WFscalefactor*0.5\columnwidth}\p@
@@ -938,20 +1090,51 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
}%
% \end{macrocode}
+% We define several options that use the \texttt{key=value} syntax.
+% Above we have already loaded the \pack{xkeyval} package that
+% offers also some ‘X’ labeled macros that mimic the corresponding
+% \LaTeXe kernel macros, but that are necessary for using the
+% \pack{xkeyval} internal macros. We chose the \texttt{wraptext}
+% option family name, because such options are to be used mostly within
+% the \cs{includeframedtext} macro.
+% The \cs{ExecuteOptionX} used here stands for a general
+% initialisation of the listed options, but it will be used also
+% within the \cs{includeframedtext} command in order to set the
+% specified options for the specific use of this command.
+% \begin{macrocode}
+\DeclareOptionX<wraptext>{scalefactor}[0.8]{\def\WFscalefactor{#1}}
+\DeclareOptionX<wraptext>{fboxrule}[1pt]{\fboxrule=#1}
+\DeclareOptionX<wraptext>{fboxsep}[1ex]{\fboxsep=#1}
+\DeclareOptionX<wraptext>{framecolor}[WFframe]{\SetWFfrm{#1}}
+\DeclareOptionX<wraptext>{backgroundcolor}[WFbackground]{\SetWFbgd{#1}}
+\DeclareOptionX<wraptext>{textcolor}[WFtext]{\SetWFtxt{#1}}
+\DeclareOptionX<wraptext>{fontstyle}[\normalfont]{#1}
+\DeclareOptionX<wraptext>{radius}[\fboxsep]{\radius=#1}
+\DeclareOptionX<wraptext>{insertionwidth}[0.5\columnwidth]{\insertwidth=#1}
+
+\DeclareOptionX*{\PackageWarning{wrapfig2}{`\CurrentOption' ignored}}
+
+\ExecuteOptionsX<wraptext>{scalefactor, fboxrule, fboxsep, framecolor,
+backgroundcolor, textcolor, fontstyle, radius, insertionwidth}
+
+\ProcessOptionsX*
+
+% \end{macrocode}
%
%
% {\color{red}Should the format file be not so up to date, a multitude
% of errors would be produced, and the user should take care to load the
% \pack{xparse} and \pack{xfp} packages before loading \pack{wrapfig2}.
-% Notice that most of the \pack{xparse} package functionalities
-% at the date required for the format file are already included. The
-% \pack{xparse} package has been available since about 2018; should the
-% users have available a definitely older \TeX system installation, they
-% should upgrade it, or must avoid using this \pack{wrapfig2} package
-% and use the original \pack{wrapfig} one; if they need to wrap text,
-% they should resort to some ingenious, not so trivial, tricks to do it.}
-%
-% Originally version~4.0 used the \pack{tcolrbox} package to frame
+% Notice that most of the \pack{xparse} package functionalities are
+% already included in the format file at the date required for this
+% file. The \pack{xparse} package has been available since about 2018;
+% should the users have available a definitely older \TeX system
+% installation, either they upgrade it, or they must avoid using this
+% \pack{wrapfig2} package and should use the original \pack{wrapfig} one;
+% if they need to wrap text, they should resort to some ingenious,
+% not so trivial tricks to do it.}
+%
+% Originally version~4 used the \pack{tcolrbox} package to frame
% the wrapped text; we thought that loading that package was too
% heavy on memory, even if the modern computers have large working
% memories. But in order to maintain and track possible errors
@@ -959,10 +1142,10 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% help; therefore in oder to draw a framed box with rounded corners
% we thought it would be much simpler to load the \pack{curve2e}
% package, just a second level extension of the original \Env{picture}
-% environment defined in the \LaTeXe kernel; just some 30 lines of code
+% environment defined in the \LaTeXe kernel; only some 30 lines of code
% are sufficient to replace the extremely powerful \pack{tcolorbox}
-% functionalities needed by this \pack{wrapfig2} package.
-%
+% functionalities otherwise required to frame wrapped text with this
+% \pack{wrapfig2} package.
%
% The definitions of the \Env{wrapfigure} and \Env{wraptable}
% environments are very simple by means of the underlaying
@@ -987,21 +1170,39 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% to insert it with its frame into the \Env{wraptext} environment body.
% Here is the code of some extra macros and of the \Env{wraptext}
% environment.
+%
+% We start with two different \cs{includeframedtext}, one for
+% version~6, that accepts \texttt{key=velue} options, and
+% another one for version~5, that requires only a comma
+% separated list of dimensional values.
% \begin{macrocode}
+\ifbool{WFnew}{%
+\NewDocumentCommand\includeframedtext{O{\insertwidth} m O{} o}{\bgroup%
+ \ExecuteOptionsX<wraptext>{#3}% executes possible key=value options
+ \insertwidth=#1\WFscalewidth
+ \framedbox{#2}{\fboxrule}{\fboxsep}[\radius]\egroup}
+}{}
+
+\ifbool{WFfive}{%
\NewDocumentCommand\includeframedtext{O{\insertwidth} m O{1pt,1ex} o}%
-{\bgroup \WFsplitdimens #3!%
-\insertwidth=#1\relax
-\IfNoValueTF{#4}%
- {\framedbox{#2}{\fboxrule}{\fboxsep}}%
- {\framedbox{#2}{\fboxrule}{\fboxsep}[#4]}%
-\egroup}
+{\bgroup
+ \WFsplitdimens #3!\relax
+ \IfNoValueTF{#4}%
+ {\framedbox{#2}{\fboxrule}{\fboxsep}}%
+ {\framedbox{#2}{\fboxrule}{\fboxsep}[#4]}
+\egroup}%
+}{}
% \end{macrocode}
%
-%
-% Its simple syntax is the following
+% Their simple syntaxes are the following
%\begin{ttsintassi}
-%\cs{includeframedtext}\oarg{text width}\marg{text}\oarg{settings}\oarg{radius}
+%~
+%\% for version 6.0
+%\cs{includeframedtext}\oarg{text width}\marg{text}\oarg{options}\oarg{radius}
+%
+%\% for version 5.0
+%\cs{includeframedtext}\oarg{text width}\marg{text}\oarg{dimensions}\oarg{radius}
%\end{ttsintassi}
%
% The optional \meta{text width} is the (possibly scaled) width computed
@@ -1010,36 +1211,42 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% in any case the default value is half the current measure
% \cs{linewidth}. The \meta{text} is the unformatted text to be wrapped;
% it will be boxed and framed by the service macro \cs{framedbox}; the
-% \meta{settings} are passed on to \cs{framedbox} command; they are a
+% \meta{dimensions} are passed on to \cs{framedbox} command; they are a
% comma separated list of dimensions, namely the thickness of the frame
-% and the necessary distance of the frame from the formatted text; the
-% last optional \meta{radius} is the curvature radius of the rounded frame
-% corners; no default value is specified, because it is going to be
-% received by \cs{framedbox} that by default sets it equal to the frame
-% separation width; this value is certainly the best one, but the user
-% can specify a different value, of course not too different from the
-% default one. See some examples in figure~\ref{fig:framed text}.
+% and the necessary frame distance from the formatted text. The
+% \meta{options} contains a comma separated list of zero to nine options
+% with the syntax \texttt{key=vale} that are going to be used by both
+% the \cs{includeframedtext} and \cs{framedbox}. The last optional
+% \meta{radius} is the curvature radius of the rounded frame corners;
+% the default value is going to be set to \cs{fboxsep}: in
+% version~5 \cs{framedbox} by default sets it equal to the frame
+% separation width, while with version~6 its value is received with
+% the option \texttt{radius=\meta{dimension}}; the default value is
+% certainly the best one, but the users can specify a different value,
+% of course not too different from the default one. See some examples
+% in figure~\ref{fig:framed text}.
%
% The definition of the \cs{framedbox} command appears to be
% complicated; it is just an apparent complication due to the
% fact that it uses the powerful \cs{Curve} command that draws an
-% arbitrary curved line or fills the area delimited by the
+% arbitrary curved line or fills the area delimited by such
% curved line; it suffices to specify the nodes and the tangents
% to each node; the nodes are the points the line should pass
% through, their tangents may be specified with arbitrary vector
% components along the horizontal and vertical axes. For a
-% rectangle such vector componente are just 0 or $\pm 1$. The
-% node coordinates, on the opposite, must be determined with
-% accuracy; we used the \cs{fpeval} function of package \pack{xfp},
-% that performs precise operation on operands in fractional
-% decimal numbers; if the operands are dimensions, the operands
-% are their fractional values in printer points, the results of
-% such operations are pure fractional decimal numbers without units;
-% if the numerical result is to be interpreted again as the measure of a
-% dimensional entity, \texttt{pt} must be appended to the
-% assignments to a dimension register; within the \Env{picture}
+% rectangle such vector components are just 0 or $\pm 1$. The
+% node coordinates of the rounded corners, on the opposite, must be
+% determined with accuracy; we used the \cs{fpeval} function of
+% package \pack{xfp}, that performs precise computations on operands
+% in fractional decimal numbers; if the operands are dimensions, the
+% operands are their fractional decimal values in printer points, the
+% results of such operations are pure fractional decimal numbers
+% without units; if the numerical result is to be interpreted again
+% as the measure of a dimensional entity, \texttt{pt} must be appended
+% to the assignments to a dimension register; within the \Env{picture}
% environment, any coordinate is expressed in multiples of
-% \cs{unitlength}.
+% \cs{unitlength}, therefore no unit of measure is necessary, once
+% \cs{unitlength} has been specified.
%
% For a rectangle with curved corners of a given radius \cs{R}
% we have four quarter circles joined by straight lines; therefore
@@ -1047,42 +1254,50 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%
% The shaded background and the coloured frame have the same contour;
% but the former is filled, while the latter is stroked; we have to
-% draw the same curve two times; first the shaded background, then
-% the frame.
+% draw the same curve two times; first the shaded background, then we
+% superimpose the frame
%
-% This shaded framed rectangle is at the center of the coordinate
-% system of a \Env{piture} environment, and has the correct dimensions
-% to receive the boxed text; it is trivial to center the text within a
-% zero dimensioned box, typical of the \Env{picture} environment.
+% This shaded framed curved corners rectangle is at the center of the
+% coordinate system of a \Env{piture} environment, and has the correct
+% dimensions to receive the boxed text; it is trivial to center the text
+% by means of a zero dimensioned box, typical of the \Env{picture}
+% environment.
%
% The code of this long but simple code is the following.
% \begin{macrocode}
\NewDocumentCommand\framedbox{ m m m O{#3}}{\bgroup
\fboxrule=#2\fboxsep=#3\relax
-\setbox0\hbox{\fboxrule=0pt\fboxsep=#3\relax
-\framebox{\parbox{%
- \fpeval{\insertwidth-2\fboxrule-2\fboxsep}pt}{\textcolor{WFtext}{#1}}}}%
-%
-\unitlength=\fpeval{\wd0/100}pt
-\edef\x{100}\edef\y{\fpeval{(\ht0 +\dp0)/\unitlength}}%
-\edef\xc{50}\edef\yc{\fpeval{\y/2}}\edef\R{\fpeval{#4/\unitlength}}%
-%
+\setbox0\hbox{\fboxrule=\z@\fboxsep=#3\relax
+\framebox{\parbox{% draw a framed box without the frame
+ \fpeval{\insertwidth-2\fboxrule-2\fboxsep}\p@}{\textcolor{WFtext}{#1}}}}
+
+\unitlength=\fpeval{\wd0/100}\p@ % set the picture \unitlength
+ % determine the picture coordinates and displacement of the axes origin
+\edef\x{100}%
+\edef\y{\fpeval{(\ht0 +\dp0)/\unitlength}}%
+\edef\xc{50}%
+\edef\yc{\fpeval{\y/2}}\edef\R{\fpeval{#4/\unitlength}}%
+\edef\R{\fpeval{#4/\unitlength}}% radius in unit lengths
+ % compute the horizontal and vertical shifts of the corner extrema
\edef\WFXds{\fpeval{-\xc+\R}}\edef\WFXsd{-\WFXds}%
\edef\WFYuo{\fpeval{\yc-\R}}\edef\WFYou{-\WFYuo}%
-%
+ % compute the coordinates of the curved corners frame contour
\edef\PSEl{\WFXsd,-\yc}\edef\PSEu{\xc,\WFYou}\edef\PNEd{\xc,\WFYuo}%
\edef\PNEl{\WFXsd,\yc}\edef\PNWr{\WFXds,\yc}\edef\PNWd{-\xc,\WFYuo}%
\edef\PSWu{-\xc,\WFYou}\edef\PSWr{\WFXds,-\yc}%
-%
-\def\WFrectangle{%
+
+\def\WFrectangle{% define the contour as the argument of \Curve
(\WFXsd,-\yc)<1,0>(\xc,\WFYou)<0,1>(\xc,\WFYuo)<0,1>%
(\WFXsd,\yc)<-1,0>(\WFXds,\yc)<-1,0>(-\xc,\WFYuo)<0,-1>%
(-\xc,\WFYou)<0,-1>(\WFXds,-\yc)<1,0>(\WFXsd,-\yc)<1,0>}%
-\def\CurveStar{\Curve*}%
-%
+\def\CurveStar{\Curve*}% define a macro for adding the asterisk
+
\begin{picture}(\x,\y)(-\xc,-\yc)
-{\color{WFbackground}\expandafter\CurveStar\WFrectangle}%
-{\color{WFframe}\linethickness{#2}\expandafter\Curve\WFrectangle}%
+{\color{WFbackground}\expandafter\CurveStar\WFrectangle}% draw background
+\ifdim\fboxrule>\z@% draw the frame if its thickness is not zero
+ {\color{WFframe}\linethickness{#2}\expandafter\Curve\WFrectangle}%
+\fi
+ % put the text block in a null box at the coordinates origin
\put(0,0){\makebox(0,0)[cc]{\box0}}%
\end{picture}
\egroup}
@@ -1094,14 +1309,14 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\end{ttsintassi}
%
% The default value of the \meta{corner radius} is assigned to
-% equal argument number~3, that is the \meta{frame separation}; both
-% have a default value of \texttt{1ex} therefore they vary with the
+% equal argument number~3, that is the \meta{frame separation} and both
+% have a default value of \texttt{1ex}; therefore they vary with the
% current font size. See figure~\ref{fig:framed text}. The frame
% thickness is given a default value of \texttt{1pt} if the command is
% used within the body of the \cs{includeframedtext}; but if this
% command received a different value the frame may be thicker,
% or even vanish; we discourage values higher than \texttt{3pt}
-% (about \texttt{1mm}) and lower than \texttt{1pt}.
+% (about \texttt{1mm}) and lower than \texttt{1pt} unless is zero.
%
% The definition of the \Env{wraptext} environment is more detailed,
% because most of the computations must be done on the actual text
@@ -1110,10 +1325,12 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% problems with its justification or the justification of the wrapping
% lines. The framed box width is preset to 50\% of the normal text
% measure, but it can be optionally specified to a different value (not
-% too different from 50\%); as with the other wrapping environments, the
-% inserted material width is a \emph{braced optional parameter}.
+% too different from 50\%); as with the other wrapping environments,
+% with versions~6 and~5 the inserted material width is a \emph{braced
+% optional argument}; with version 6.0 the default value of
+% the \opz{radius} option is equal to \cs{fboxsep}.
%
-% For what concerns \Env{wraptext}, the first statement argument
+% For what concerns \Env{wraptext}, the opening statement argument
% description list does not contain any descriptor for an optional
% star. There is no need because the computation of the insertion
% block height is pretty precise and at most the user might desire
@@ -1121,15 +1338,17 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% and that of the inserted block and/or the measure of the indented
% wrapping lines; sometimes it might be necessary to get rid of the
% space below the inserted block when it gets typeset at the bottom
-% of a page.
+% of a page. The asterisk is not needed because for this environment
+% the optional first argument is always interpreted as the indented
+% lines number correction.
%
% It is true that some of the input parameters specified to the opening
% command of any environment with \LaTeXiii are available also to the
% closing commands; see the last paragraph of section~2 in the
% \pack{xparse} documentation.
-% But the following definition, besides using special delimiters for
-% optional parameters, uses the separate opening and closing
-% macros of the \Env{wrapfloat} environment; such procedure
+%
+% But the following definition uses the separate opening and closing
+% macros of the \Env{wrapfloat} environment; such procedure
% breaks this second availability of the input parameters,
% therefore it is necessary to save them into local macros or count
% registers (assignments to \TeX count registers are \emph{local},
@@ -1137,38 +1356,41 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \cs{setcounter} macro and its siblings, are \emph{global}) so
% that we can use their values within the closing commands.
%
-% The \cs{NWF@box} box register has been allocated at the beginning;
+% The \cs{NWF@box} box register has been allocated at the code beginning;
% remember that \LaTeXiii registers of any kind are not limited in number
% as they were some years ago with \LaTeXe.
%
% The last opening commands are conceived to box the object to be
% wrapped, typeset within a coloured box with the default of
-% specified width; compared to version 4.0.*, this new version~5.0.*
-% does not use anymore the functionalities provided by package
-% \pack{tcolorbox}; instead it uses the \pack{curve2e} package
+% specified width; compared to version~4, these new versions~5
+% and~6 do not use anymore the functionalities provided by package
+% \pack{tcolorbox}; instead they use the \pack{curve2e} package
% functionalities to draw similar framed and shaded boxes; this
% implies much less memory used by the almost unlimited,
% but unused, functionalities of the \pack{tikz} package on which
-% \pack{tcolorbox} relies.
-%
-% Notice the \Env{wraptext} has two definitions depending on the
-% logical switch \texttt{WFnew}; if this switch is \texttt{true}
-% the definition applies to version~5.0.* of this package; otherwise
-% the second definition is a fall back to the functionality and the
-% syntax of the previous version~4.0.* implementation of this package;
-% in this latter case, in spite of the fact the the previous version
+% \pack{tcolorbox} relies. Notice that the plain \Env{picture}
+% environment extended with the \pack{pict2e} package can draw
+% “ovals”, that is rectangles with rounded corners, but as far as
+% we know they have the frame but cannot be filled.
+%
+% Notice the \Env{wraptext} has two or three definitions depending on the
+% logical switches \texttt{WFnew} and \texttt{WFfive}; if one of these
+% switches is \texttt{true} the definitions apply to either version~5
+% or~6 of this package; otherwise the last definition is a fall back to
+% the functionality and the syntax of the previous version~4 of this
+% package; in this case, in spite of the fact the the previous version
% used package \pack{tcolorbox}, the new code relies on the
% \pack{curve2e} functionalities in oder to get the same results
% without using the memory heavy \pack{tcolorbox} package.
%
-% With this new solution the frame that surrounds the wrapped text
+% With version 6.0, the frame that surrounds the wrapped text
% has the desired rounded corners; it is possible to easily
% specify the background and the frame colours, that by default
-% are maintained to light grey and black respectively; this new
+% are maintained to light grey and almost black respectively; this
% flexibility allows to set also the frame thickness and the
% separation width of the frame from its contents; by default
% they are~1pt for the frame thickness, and~1ex for the separation
-% width, that changes with the size of the surrounding fonts.
+% width, that changes with the font size.
% The number of indented lines is computed by means of the
% \cs{fpeval} \LaTeXiii function; among the operands of this
% function there is the number \texttt{2} used to take into
@@ -1179,7 +1401,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% a better choice.
%
% Eventually the opening \Env{wrapfloat} statement is created by
-% expanding the whole line complete of arguments, by means of the
+% expanding the whole line complete of its arguments, by means of the
% usual trick of defining a dummy macro within a group that contains
% among its expansion the group closing command, so that while
% it is being executed, it deletes itself from memory.
@@ -1188,13 +1410,13 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% absolutely identical to that of the other two wrapping environments
% in terms of \meta{line number correction}, mandatory \meta{location},
% optional \meta{overhang} and braced optional \meta{width}. See below
-% for the very different syntax of the fall back version~4.0.* opening
+% for the very different syntax of the fall back version~4 opening
% \Env{wraptext} statement; they become almost identical when no
% optional parameters are specified, the only little difference being
-% that the \meta{location} argument is mandatory for version~5.0.*,
-% while it is optional for version~4.0.*.
+% that the \meta{location} argument is mandatory for versions~5 and~6,
+% while it is optional for version~4.
% \begin{macrocode}
-\ifWFnew
+\ifboolexpr{bool{WFnew} or bool{WFfive}}{% definition for versions 5 and 6
\NewDocumentEnvironment{wraptext}{O{0} m O{0pt} G{0.5\columnwidth}}{%
\insertwidth=#4\WFscalewidth
\def\textplacement{#2}%
@@ -1202,7 +1424,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\def\textoverhang{#3}%
\bgroup\edef\x{\egroup\noexpand\wrapfloat{text}%
[\textcorrection]{\textplacement}[\textoverhang]{\insertwidth}*}\x%
- \def\caption{\unskip
+ \def\caption{\unskip
\refstepcounter\@captype
\let\@tempf\@caption
\unless\ifcsname @float@c@\@captype\endcsname
@@ -1214,16 +1436,16 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
}{\endwrapfloat\ignorespaces}%
% \end{macrocode}
%
-% For the fallback definition of this \Env{wraptext} environment
-% we have to start with the old list of specifically delimited
-% optional arguments. We remember that this opening statement
-% receives in order a bracket delimited \meta{location} parameter,
-% a vertical bar delimited optional \meta{width}, an angle bracket
-% delimited \meta{line number correction}, a round parenthesis
-% delimited \meta{caption label}; the different delimiters allow
-% to specify any optional argument without regard with the other
-% ones, provided they are in the same logical order when more than one
-% optional argument is specified.
+% For the fallback to version!4 definition of this \Env{wraptext}
+% environment we have to start with the old list of specifically
+% delimited optional arguments. We remember that this opening statement
+% receives in order a bracket delimited optional \meta{location}
+% parameter, a vertical bar delimited optional \meta{width}, an angle
+% bracket delimited optional \meta{line number correction}, a round
+% parenthesis delimited optional \meta{caption label}; the different
+% delimiters allow to specify any optional argument without regard with
+% the other ones, provided they are in the same logical order when more
+% than one optional argument is specified.
%
% Notice that the third optional argument contains the
% \meta{line number correction}, therefore the star used with the
@@ -1235,35 +1457,32 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% easily obtained with a \Env{minipage} environment, of which the
% internal commands are used; this insures that the text is
% typeset with the correct measure; with the closing commands
-% this boxed text shall be fed to the \cs{framedbox} command, in
-% oder to be framed and assigned a default background color.
+% this boxed text is fed to the \cs{framedbox} command, in
+% order to be framed and assigned a default background color.
% There is no possibility of specifying the colours unless the
% whole \Env{wraptext} environment, preceded by explicit color
-% settings, is confined within a group delimited, for example
-%, by the \cs{begingroup} and \cs{endgroup} commands.
-% \begin{macrocode}
-\else %
+% settings, is confined within a group delimited, for example,
+% by the \cs{begingroup} and \cs{endgroup} commands.
+% \begin{macrocode}
+}{% definition for version 4 fall back
%
\NewDocumentEnvironment{wraptext}%
{O{l} D||{0.5\columnwidth} D<>{0} D(){text} }%
- {%
+ {% Open environment
\insertwidth=#2
\def\textplacement{#1}%
\def\textcorrection{#3}%
\def\WF@caption@label{#4}%
\setbox0\hbox\bgroup
\minipage{\dimexpr\insertwidth-2pt-6ex}%
-}{\endminipage\egroup
+}{% Close environment
+ \endminipage\egroup
\begin{lrbox}{\NWF@box}%
\framedbox{\box0}{1pt}{1ex}%
\end{lrbox}
- \edef\NWF@wli
- {%
- \fpeval{%
- round((\ht\NWF@box+\dp\NWF@box)/\baselineskip,0)+2+
- \textcorrection
- }%
- }%
+ \edef\NWF@wli]{\fpeval{%
+ round((\ht\NWF@box+\dp\NWF@box)/\baselineskip,0)+2+\textcorrection}%
+ }%
\unles\ifhmode
\leavevmode\noindent
\fi
@@ -1273,7 +1492,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\endwrapfloat
\ignorespaces
}
-\fi
+}
% \end{macrocode}
%
@@ -1289,7 +1508,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% to be wrapped, but certain tasks are demanded to other service
% macros.
%
-% It is possible to set the width of the box if the \meta{width}
+% It is possible to set the width of the box if the \meta{width}
% parameter is specified; otherwise it closes the \cs{hbox} that was used;
% then it closes the main vertical box \cs{WF@box}. After executing
% \cs{WF@floatstyhook}, necessary when package \pack{float.sty}
@@ -1299,11 +1518,11 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% in the same box register with a negative initial vertical skip
% that raises the box contents.
%
-% Now comes the definition of the fundamental environment \Env{wrapfloat};
-% compared to the original Arseneau's definition it is much longer,
-% but it contains the code that Arseneau, who used the \LaTeXe
-% language, had to split in several macros in order to handle the
-% multitude of interspersed mandatory and optional arguments.
+% Now comes the new actual definition of the fundamental environment
+% \Env{wrapfloat}; compared to the original Arseneau's definition it is
+% much longer, but it contains the code that Arseneau, who used the
+% \LaTeXe language, and had to split it in several macros in order to
+% handle the multitude of interspersed mandatory and optional arguments.
%
% The main function of this environment is to handle the box that
% contains the figure, or the table, or the framed text, or what
@@ -1315,25 +1534,27 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% corrected. As it can be seen the optional star is not among
% the argument descriptors of the opening commands; it will be
% the following macro \cs{WR@wr} responsible of taking care of
-% the list of arguments and see if a star has been specified and
-% not yet read by the preceding commands.
+% the list of arguments and see if a star has been specified but
+% is still in the input flow.
%
% In order to handle any kind of wrapped object, this environment
% first argument is the \meta{caption label}. It may remain blank;
% but for wrapping figures or tables their respective definitions
% specify the name of the floating object they belong to; it is
% necessary that there exists a floating environment with the same
-% name of the wrapped object, even when its wrapping environment
+% name of the wrapped object, even when its wrapping environment
% is not specified with a floating \meta{location} argument.
%
% \begin{macrocode}
-
\NewDocumentEnvironment{wrapfloat}{m o m o G{\z@}}%
- {\def\@captype{#1}\WF@wr[#2]{#3}[#4]{#5}}%
- {\ifdim\hsize>\z@
+{% open environment code
+ \def\@captype{#1}\WF@wr[#2]{#3}[#4]{#5}%
+}{% close environment code
+ \ifdim\hsize>\z@
\par\hrule\@width\hsize\@height\z@ % force width with invisible rule
\else
- \unskip \egroup \box\z@ % or close hbox
+% \unskip % is the \unskip necessary?
+ \egroup \box\z@ % or close hbox
\fi
\egroup % close the vtop box; its width now is known
\WF@floatstyhook % support for float.sty
@@ -1354,7 +1575,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\fi
\fi
\global\@ignoretrue
- }
+}
% \end{macrocode}
%
@@ -1380,19 +1601,24 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% height to \cs{WF@size}. Afterwards some unusual macros are executed;
% they were devised by Arseneau to deal with possibly floating wrapped
% objects. The optional star is not accepted by this macro; if the user
-% specified it, it is still in the input flux; notice that the
-% \Env{wraptext} environment in version~4.0 does not accept the
-% optional star; if the user specifies it for this environment, an
-% asterisk appears at the beginning of the wrapped text; with
-% version~5.0 the asterisk appears at the left of the framed text.
-% In both cases, in facts, the first optional parameter is always
-% interpreted as the \meta{line number correction}.
+% specified it, it is still in the input flow; notice that the
+% \Env{wraptext} environment does not accept the optional star; if the
+% user indadvertedly specifies it for this environment, an
+% asterisk appears at the beginning of the wrapped text with version~4;
+% with versions~5 and~6 the asterisk appears at the left of the framed
+% text. In all three cases, in facts, the first optional parameter is
+% always interpreted as the \meta{line number correction}.
%
% The braced \meta{width} fourth parameter (actually a
% \textit{braced optional parameter}) may be specified
% to be \texttt{0pt}; in any case \texttt{0pt} is the default parameter
% value; if so, the object is treated at its natural width, by
-% boxing it into an hbox and using this box width as the working width.
+% boxing it into an hbox and using this box width as the working
+% width of course this works only with \Env{wrapfigure} and
+% \Env{wraptable}, because what is being wrapped has its own natural
+% width; with text the natural width is the default setting made
+% with the \emph{braced optional argument} described with the
+% \texttt{G} descriptor.
% \begin{macrocode}
\NewDocumentCommand\WF@wr{o m o m s}{%
\xdef\WF@wfname{wrap\@captype\space}%
@@ -1434,9 +1660,8 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\IfBooleanTF{#5}% if the asterisk is present set the numerical switch
{\global\WF@correctlines@switch=\@ne}%
{\global\WF@correctlines@switch=\z@}%
- \global\@ignoretrue
-}
+}
% \end{macrocode}
%
% At this point the main box \cs{WF@box} is opened in order to
@@ -1514,26 +1739,23 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\vskip-\parskip \global\WF@floatfalse
\let\pagetotal\maxdimen % kludge flag for "not top of page"
\else % outer page
- \unless\ifWFnew \@tempdima\pagedepth \fi% save page depth
{\advance\parskip\@tempdima\vskip-\parskip}% back up to base line
\penalty\interlinepenalty % update page parameters
- \@tempdimb\pagegoal \advance\@tempdimb-\pagetotal % room left on page
+ \@tempdimb\dimexpr\pagegoal - \pagetotal \relax% room left on page
\ifdim \@tempdimb<\z@ % page already full
\global\WF@floatfalse
- \unless\ifdim-\@tempdimb>\pageshrink
- \pagebreak
- \fi
+ \unless\ifdim-\@tempdimb>\pageshrink \pagebreak \fi
\else
\ifdim\WF@size>\@tempdimb% box too high does not fit in \@tempdimb
\ifWF@float
- \dimen@.5\baselineskip
+ \dimen@ 0.5\baselineskip
\else
\dimen@ 2\baselineskip
\fi
\ifdim\pagestretch>\dimen@ \dimen@\pagestretch \fi
\ifdim\pagefilstretch>\z@ \dimen@\@tempdimb \fi
\ifdim\pagefillstretch>\z@ \dimen@\@tempdimb \fi
- \advance\dimen@.5\baselineskip
+ \advance\dimen@ 0.5\baselineskip
\ifdim\dimen@>\@tempdimb % stretch page contents
\global\WF@floatfalse \pagebreak
\fi
@@ -1541,7 +1763,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\global\WF@floatfalse
\fi
\fi
- \vskip\@tempdima\relax % return erased page depth
+ \vskip\@tempdima% return erased page depth
\fi
\noindent
\ifWF@float
@@ -1562,7 +1784,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\ifnum `l=\WF@place % object on left
\hss
\def\@tempa{\kern\columnsep}% take right gap into action
- \else % insert on light
+ \else % object on right
\@tempdima\z@ % no left indentation
\kern\@tempdimb \kern\columnsep
\def\@tempa{\hss}% object overlaps space to the right
@@ -1586,9 +1808,10 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\aftergroup\WF@startwrapping
\fi
}
+
% \end{macrocode}
%
-% Here comes the very important macro that counts the wrapping indented
+% Here comes the very important macro that counts the indented wrapping
% lines, so that wrapping is correct; of course the limitations
% of the \LaTeX processing (needed to ship out a complete
% page) forbid to take into account the spaces inserted between
@@ -1614,18 +1837,19 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\ifnum\WF@correctlines@switch>\z@ % line number correction
\setcounter{WF@wrappedlines}
{\fpeval{round((\WF@size)/\baselineskip,0)+\WF@wli}}%
- \xdef\WF@wli{\value{WF@wrappedlines}}%
+ \xdef\WF@wli{\the\c@WF@wrappedlines}%
\else
\setcounter{WF@wrappedlines}{\WF@wli}% absolute number of lines
- \global\advance\c@WF@wrappedlines\@ne
+ \stepcounter{WF@wrappedlines}%
\fi
\fi
\ifnum\c@WF@wrappedlines>\@ne % fine tuning
\let\parshape\WF@fudgeparshape \let\WF@pspars\@empty \let\WF@@par\par
\def\@setpar##1{\def\WF@@par{##1}}\def\par{\@par}\let\@par\WF@mypar
- \xdef\WF@restoretol{\tolerance\the\tolerance}\tolerance9999
+ \xdef\WF@restoretol{\tolerance\the\tolerance}\tolerance9999\relax
\advance\linewidth-\WF@adjlw \advance\@totalleftmargin\WF@adjtlm
- \fi}
+ \fi
+}
% \end{macrocode}
%
@@ -1692,7 +1916,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\ifnum\c@WF@wrappedlines<\tw@
\WF@finale
\else
- \afterassignment\WF@fudgeparshapee \fam
+ \afterassignment\WF@fudgeparshapee \fam
\fi
}
@@ -1826,18 +2050,18 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% with package \pack{float.sty}, since, after defining a new float
% \meta{foo}, it suffices to define the new environment
% \Env{wrap\meta{foo}}. This fork version of his package should do
-% the same: is suffices to mimic the definitions of environments
+% the same: it suffices to mimic the definitions of environments
% \Env{wrapfigure} or \Env{wraptable}.
%
% Here there is some Arseneau's code that renders his \pack{wrapfig}
% code compatible with \cs{newfloat} of class \class{memoir}, and
-% with \cs{newfloatlist} of package \pack{ccaption}. We leave his code
-% hereafter; but we did not test it with this package.
-% \begin{macrocode}
+% with \cs{newfloatlist} of package \pack{ccaption}. We keep his code,
+% but we did not test it with this package.
+% \begin{macrocode}
\let\WF@floatstyhook\relax
-%
+
\@ifundefined{newfloat}{}{% \newfloat comes from somewhere besides
-% float.sty
+ % float.sty
\@ifundefined{restylefloat}{%
\@ifclassloaded{memoir}{%
\toks@=\expandafter\expandafter\expandafter
@@ -1850,10 +2074,11 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
}% end memoir support
{}% other origins of \newfloat here?
}{% float.sty handler. Ops: Two versions for different versions
-% Changing \floatstyle or \restylefloat changes \newfloat too.
+ % Changing \floatstyle or \restylefloat changes also \newfloat.
\@ifundefined{float@restyle}%
{% older float.sty
- \toks@=\expandafter{\restylefloat{#1}% env. might be undefined
+
+ \toks@=\expandafter{\restylefloat{##1}% env. might be undefined
\@namedef{wrap#1}{%
\def\@captype{#1}\@nameuse{fst@#1}%
\def\WF@floatstyhook{\let\@currbox\WF@box \columnwidth\wd\WF@box
diff --git a/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty b/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty
index 0fe642f2490..508e88fc576 100644
--- a/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty
+++ b/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty
@@ -12,25 +12,28 @@
%%
\NeedsTeXFormat{LaTeX2e}[2019/01/01]
\ProvidesPackage{wrapfig2}%
- [2022-01-26 v.5.0.7 Wrap text around figures, tables, framed text blocks]
+ [2022-02-16 v.6.0.0 Wrap text around figures, tables, framed text blocks]
\ifcsname c@WF@wrappedlines\endcsname
\PackageError{wrapfig2}{ \MessageBreak
****************************************************\MessageBreak
Package `wrapfig' has already been loaded perhaps \MessageBreak
by other packages, for example caption or subcaption.\MessageBreak
Such packages are incompatible with wrapfig2 \MessageBreak
- Loading `wrapfig2' aborted \MessageBreak
+ Loading of`wrapfig2' is aborted \MessageBreak
****************************************************\MessageBreak
}{You might type X <return> and might get along without\MessageBreak
this package if you don't use the new environment \MessageBreak
- `wraptext'; otherwise you get errors about such \MessageBreak
- environment not being defined; you must kill your job!}
+ `wraptext' and the new commands; otherwise you get \MessageBreak
+ errors about such environment not being defined; \MessageBreak
+ you must kill your job!}
\expandafter\endinput\fi
\def\WF@warning{\PackageWarning{wrapfig2}}
\DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig2}}}
\newif\ifWFnew \let\ifWFnew\iftrue
+\newif\ifWFfive \let\ifWFfive\iffalse
\DeclareOption{WFold}{\let\ifWFnew\iffalse}
+\DeclareOption{WFfive}{\let\ifWFnew\iffalse \let\ifWFfive\iftrue}
\ProcessOptions
\RequirePackage{xparse}
@@ -41,21 +44,22 @@
\@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}%
}
\@ifpackageloaded{curve2e}{}{\RequirePackage{curve2e}}
+\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}}
-\ifWFnew
- \floatstyle{plain}
+\ifboolexpr{ bool{WFfive} or bool{WFnew} }%
+ {\floatstyle{plain}%
\ifcsname chapter\endcsname
- \newfloat{text}{tbp}{lotx}[chapter]
+ \newfloat{text}{tbp}{lotx}[chapter]%
\else
- \newfloat{text}{tbp}{lotx}
+ \newfloat{text}{tbp}{lotx}%
\fi
- \floatname{text}{Text}
+ \floatname{text}{Text}% come personalizzare con le diverse lingue?
\let\WF@text@caption\float@caption
-\fi
+ }{}
\newdimen\wrapoverhang \wrapoverhang\z@
\newdimen\WF@size
-\newcounter{WF@wrappedlines}
+\newcount\c@WF@wrappedlines
\newbox\WF@box
\newbox\NWF@box
\newtoks\WF@everypar
@@ -65,6 +69,7 @@
\let\WF@@everypar\everypar
\newdimen\insertwidth
+\newdimen\radius
\newdimen\WFinsertwidthL
\newdimen\WFinsertwidthH
@@ -74,8 +79,13 @@
\def\SetWFbgd#1{\colorlet{WFbackground}{#1}}
\def\SetWFfrm#1{\colorlet{WFframe}{#1}}
\def\SetWFtxt#1{\colorlet{WFtext}{#1}}
+
\def\WFsplitdimens#1,#2!{\fboxrule=#1\relax\fboxsep=#2\relax}
+\providecommand\setfontsize{}
+\RenewDocumentCommand\setfontsize{O{1.2} m}{%
+ \fontsize{#2}{\fpeval{#1*#2}}\selectfont}
+
\def\WFscalefactor{0.8}%
\newcommand*\WFscalewidth{%
\WFinsertwidthL=\fpeval{\WFscalefactor*0.5\columnwidth}\p@
@@ -89,6 +99,23 @@
\fi
}%
+\DeclareOptionX<wraptext>{scalefactor}[0.8]{\def\WFscalefactor{#1}}
+\DeclareOptionX<wraptext>{fboxrule}[1pt]{\fboxrule=#1}
+\DeclareOptionX<wraptext>{fboxsep}[1ex]{\fboxsep=#1}
+\DeclareOptionX<wraptext>{framecolor}[WFframe]{\SetWFfrm{#1}}
+\DeclareOptionX<wraptext>{backgroundcolor}[WFbackground]{\SetWFbgd{#1}}
+\DeclareOptionX<wraptext>{textcolor}[WFtext]{\SetWFtxt{#1}}
+\DeclareOptionX<wraptext>{fontstyle}[\normalfont]{#1}
+\DeclareOptionX<wraptext>{radius}[\fboxsep]{\radius=#1}
+\DeclareOptionX<wraptext>{insertionwidth}[0.5\columnwidth]{\insertwidth=#1}
+
+\DeclareOptionX*{\PackageWarning{wrapfig2}{`\CurrentOption' ignored}}
+
+\ExecuteOptionsX<wraptext>{scalefactor, fboxrule, fboxsep, framecolor,
+backgroundcolor, textcolor, fontstyle, radius, insertionwidth}
+
+\ProcessOptionsX*
+
\NewDocumentEnvironment{wrapfigure}{o m o G{0pt}}%
{\wrapfloat{figure}[#1]{#2}[#3]{#4}}%
{\endwrapfloat}
@@ -97,40 +124,61 @@
{\wrapfloat{table}[#1]{#2}[#3]{#4}}%
{\endwrapfloat}
+\ifbool{WFnew}{%
+\NewDocumentCommand\includeframedtext{O{\insertwidth} m O{} o}{\bgroup%
+ \ExecuteOptionsX<wraptext>{#3}% executes possible key=value options
+ \insertwidth=#1\WFscalewidth
+ \framedbox{#2}{\fboxrule}{\fboxsep}[\radius]\egroup}
+}{}
+
+\ifbool{WFfive}{%
\NewDocumentCommand\includeframedtext{O{\insertwidth} m O{1pt,1ex} o}%
-{\bgroup \WFsplitdimens #3!%
-\insertwidth=#1\relax
-\IfNoValueTF{#4}%
- {\framedbox{#2}{\fboxrule}{\fboxsep}}%
- {\framedbox{#2}{\fboxrule}{\fboxsep}[#4]}%
-\egroup}
+{\bgroup
+ \WFsplitdimens #3!\relax
+ \IfNoValueTF{#4}%
+ {\framedbox{#2}{\fboxrule}{\fboxsep}}%
+ {\framedbox{#2}{\fboxrule}{\fboxsep}[#4]}
+\egroup}%
+}{}
\NewDocumentCommand\framedbox{ m m m O{#3}}{\bgroup
\fboxrule=#2\fboxsep=#3\relax
-\setbox0\hbox{\fboxrule=0pt\fboxsep=#3\relax
-\framebox{\parbox{%
- \fpeval{\insertwidth-2\fboxrule-2\fboxsep}pt}{\textcolor{WFtext}{#1}}}}%
-\unitlength=\fpeval{\wd0/100}pt
-\edef\x{100}\edef\y{\fpeval{(\ht0 +\dp0)/\unitlength}}%
-\edef\xc{50}\edef\yc{\fpeval{\y/2}}\edef\R{\fpeval{#4/\unitlength}}%
+\setbox0\hbox{\fboxrule=\z@\fboxsep=#3\relax
+\framebox{\parbox{% draw a framed box without the frame
+ \fpeval{\insertwidth-2\fboxrule-2\fboxsep}\p@}{\textcolor{WFtext}{#1}}}}
+
+\unitlength=\fpeval{\wd0/100}\p@ % set the picture \unitlength
+ % determine the picture coordinates and displacement of the axes origin
+\edef\x{100}%
+\edef\y{\fpeval{(\ht0 +\dp0)/\unitlength}}%
+\edef\xc{50}%
+\edef\yc{\fpeval{\y/2}}\edef\R{\fpeval{#4/\unitlength}}%
+\edef\R{\fpeval{#4/\unitlength}}% radius in unit lengths
+ % compute the horizontal and vertical shifts of the corner extrema
\edef\WFXds{\fpeval{-\xc+\R}}\edef\WFXsd{-\WFXds}%
\edef\WFYuo{\fpeval{\yc-\R}}\edef\WFYou{-\WFYuo}%
+ % compute the coordinates of the curved corners frame contour
\edef\PSEl{\WFXsd,-\yc}\edef\PSEu{\xc,\WFYou}\edef\PNEd{\xc,\WFYuo}%
\edef\PNEl{\WFXsd,\yc}\edef\PNWr{\WFXds,\yc}\edef\PNWd{-\xc,\WFYuo}%
\edef\PSWu{-\xc,\WFYou}\edef\PSWr{\WFXds,-\yc}%
-\def\WFrectangle{%
+
+\def\WFrectangle{% define the contour as the argument of \Curve
(\WFXsd,-\yc)<1,0>(\xc,\WFYou)<0,1>(\xc,\WFYuo)<0,1>%
(\WFXsd,\yc)<-1,0>(\WFXds,\yc)<-1,0>(-\xc,\WFYuo)<0,-1>%
(-\xc,\WFYou)<0,-1>(\WFXds,-\yc)<1,0>(\WFXsd,-\yc)<1,0>}%
-\def\CurveStar{\Curve*}%
+\def\CurveStar{\Curve*}% define a macro for adding the asterisk
+
\begin{picture}(\x,\y)(-\xc,-\yc)
-{\color{WFbackground}\expandafter\CurveStar\WFrectangle}%
-{\color{WFframe}\linethickness{#2}\expandafter\Curve\WFrectangle}%
+{\color{WFbackground}\expandafter\CurveStar\WFrectangle}% draw background
+\ifdim\fboxrule>\z@% draw the frame if its thickness is not zero
+ {\color{WFframe}\linethickness{#2}\expandafter\Curve\WFrectangle}%
+\fi
+ % put the text block in a null box at the coordinates origin
\put(0,0){\makebox(0,0)[cc]{\box0}}%
\end{picture}
\egroup}
-\ifWFnew
+\ifboolexpr{bool{WFnew} or bool{WFfive}}{% definition for versions 5 and 6
\NewDocumentEnvironment{wraptext}{O{0} m O{0pt} G{0.5\columnwidth}}{%
\insertwidth=#4\WFscalewidth
\def\textplacement{#2}%
@@ -148,27 +196,24 @@
\@dblarg{\@caption\@captype}%
}%
}{\endwrapfloat\ignorespaces}%
-\else %
+}{% definition for version 4 fall back
\NewDocumentEnvironment{wraptext}%
{O{l} D||{0.5\columnwidth} D<>{0} D(){text} }%
- {%
+ {% Open environment
\insertwidth=#2
\def\textplacement{#1}%
\def\textcorrection{#3}%
\def\WF@caption@label{#4}%
\setbox0\hbox\bgroup
\minipage{\dimexpr\insertwidth-2pt-6ex}%
-}{\endminipage\egroup
+}{% Close environment
+ \endminipage\egroup
\begin{lrbox}{\NWF@box}%
\framedbox{\box0}{1pt}{1ex}%
\end{lrbox}
- \edef\NWF@wli
- {%
- \fpeval{%
- round((\ht\NWF@box+\dp\NWF@box)/\baselineskip,0)+2+
- \textcorrection
- }%
- }%
+ \edef\NWF@wli]{\fpeval{%
+ round((\ht\NWF@box+\dp\NWF@box)/\baselineskip,0)+2+\textcorrection}%
+ }%
\unles\ifhmode
\leavevmode\noindent
\fi
@@ -178,15 +223,16 @@
\endwrapfloat
\ignorespaces
}
-\fi
-
+}
\NewDocumentEnvironment{wrapfloat}{m o m o G{\z@}}%
- {\def\@captype{#1}\WF@wr[#2]{#3}[#4]{#5}}%
- {\ifdim\hsize>\z@
+{% open environment code
+ \def\@captype{#1}\WF@wr[#2]{#3}[#4]{#5}%
+}{% close environment code
+ \ifdim\hsize>\z@
\par\hrule\@width\hsize\@height\z@ % force width with invisible rule
\else
- \unskip \egroup \box\z@ % or close hbox
+ \egroup \box\z@ % or close hbox
\fi
\egroup % close the vtop box; its width now is known
\WF@floatstyhook % support for float.sty
@@ -207,7 +253,7 @@
\fi
\fi
\global\@ignoretrue
- }
+}
\NewDocumentCommand\WF@wr{o m o m s}{%
\xdef\WF@wfname{wrap\@captype\space}%
@@ -247,9 +293,8 @@
\IfBooleanTF{#5}% if the asterisk is present set the numerical switch
{\global\WF@correctlines@switch=\@ne}%
{\global\WF@correctlines@switch=\z@}%
- \global\@ignoretrue
-}
+}
\def\wf@caption{\relax% redefine \wf@caption in case \hsize is zero
\ifdim\hsize>\z@
\let\caption\wf@@caption
@@ -294,26 +339,23 @@
\vskip-\parskip \global\WF@floatfalse
\let\pagetotal\maxdimen % kludge flag for "not top of page"
\else % outer page
- \unless\ifWFnew \@tempdima\pagedepth \fi% save page depth
{\advance\parskip\@tempdima\vskip-\parskip}% back up to base line
\penalty\interlinepenalty % update page parameters
- \@tempdimb\pagegoal \advance\@tempdimb-\pagetotal % room left on page
+ \@tempdimb\dimexpr\pagegoal - \pagetotal \relax% room left on page
\ifdim \@tempdimb<\z@ % page already full
\global\WF@floatfalse
- \unless\ifdim-\@tempdimb>\pageshrink
- \pagebreak
- \fi
+ \unless\ifdim-\@tempdimb>\pageshrink \pagebreak \fi
\else
\ifdim\WF@size>\@tempdimb% box too high does not fit in \@tempdimb
\ifWF@float
- \dimen@.5\baselineskip
+ \dimen@ 0.5\baselineskip
\else
\dimen@ 2\baselineskip
\fi
\ifdim\pagestretch>\dimen@ \dimen@\pagestretch \fi
\ifdim\pagefilstretch>\z@ \dimen@\@tempdimb \fi
\ifdim\pagefillstretch>\z@ \dimen@\@tempdimb \fi
- \advance\dimen@.5\baselineskip
+ \advance\dimen@ 0.5\baselineskip
\ifdim\dimen@>\@tempdimb % stretch page contents
\global\WF@floatfalse \pagebreak
\fi
@@ -321,7 +363,7 @@
\global\WF@floatfalse
\fi
\fi
- \vskip\@tempdima\relax % return erased page depth
+ \vskip\@tempdima% return erased page depth
\fi
\noindent
\ifWF@float
@@ -342,7 +384,7 @@
\ifnum `l=\WF@place % object on left
\hss
\def\@tempa{\kern\columnsep}% take right gap into action
- \else % insert on light
+ \else % object on right
\@tempdima\z@ % no left indentation
\kern\@tempdimb \kern\columnsep
\def\@tempa{\hss}% object overlaps space to the right
@@ -366,6 +408,7 @@
\aftergroup\WF@startwrapping
\fi
}
+
\def\WF@startwrapping{%
\ifnum\WF@wli=\z@ % no number was specified
\setcounter{WF@wrappedlines}%
@@ -375,18 +418,19 @@
\ifnum\WF@correctlines@switch>\z@ % line number correction
\setcounter{WF@wrappedlines}
{\fpeval{round((\WF@size)/\baselineskip,0)+\WF@wli}}%
- \xdef\WF@wli{\value{WF@wrappedlines}}%
+ \xdef\WF@wli{\the\c@WF@wrappedlines}%
\else
\setcounter{WF@wrappedlines}{\WF@wli}% absolute number of lines
- \global\advance\c@WF@wrappedlines\@ne
+ \stepcounter{WF@wrappedlines}%
\fi
\fi
\ifnum\c@WF@wrappedlines>\@ne % fine tuning
\let\parshape\WF@fudgeparshape \let\WF@pspars\@empty \let\WF@@par\par
\def\@setpar##1{\def\WF@@par{##1}}\def\par{\@par}\let\@par\WF@mypar
- \xdef\WF@restoretol{\tolerance\the\tolerance}\tolerance9999
+ \xdef\WF@restoretol{\tolerance\the\tolerance}\tolerance9999\relax
\advance\linewidth-\WF@adjlw \advance\@totalleftmargin\WF@adjtlm
- \fi}
+ \fi
+}
\def\WF@wraphand{% for indenting one or more paragraphs
\ifnum\c@WF@wrappedlines<\tw@
@@ -521,7 +565,9 @@
\let\WF@info\@gobble
\let\WF@floatstyhook\relax
+
\@ifundefined{newfloat}{}{% \newfloat comes from somewhere besides
+ % float.sty
\@ifundefined{restylefloat}{%
\@ifclassloaded{memoir}{%
\toks@=\expandafter\expandafter\expandafter
@@ -534,9 +580,11 @@
}% end memoir support
{}% other origins of \newfloat here?
}{% float.sty handler. Ops: Two versions for different versions
+ % Changing \floatstyle or \restylefloat changes also \newfloat.
\@ifundefined{float@restyle}%
{% older float.sty
- \toks@=\expandafter{\restylefloat{#1}% env. might be undefined
+
+ \toks@=\expandafter{\restylefloat{##1}% env. might be undefined
\@namedef{wrap#1}{%
\def\@captype{#1}\@nameuse{fst@#1}%
\def\WF@floatstyhook{\let\@currbox\WF@box \columnwidth\wd\WF@box