summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-01-26 21:09:26 +0000
committerKarl Berry <karl@freefriends.org>2022-01-26 21:09:26 +0000
commit0b19d44096eb613853c6b04e08fbe716091c8798 (patch)
tree03da5f10fe3baba043fcf49f339705dc310340c7
parentb3e927c8043ceabb5dae6645819e150244f9f11d (diff)
wrapfig2 (26jan22)
git-svn-id: svn://tug.org/texlive/trunk@61749 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/wrapfig2/README.txt16
-rw-r--r--Master/texmf-dist/doc/latex/wrapfig2/commodilla.jpgbin0 -> 137378 bytes
-rw-r--r--Master/texmf-dist/doc/latex/wrapfig2/wrapfig2.pdfbin532255 -> 758679 bytes
-rw-r--r--Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx1233
-rw-r--r--Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty192
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds1
6 files changed, 1030 insertions, 412 deletions
diff --git a/Master/texmf-dist/doc/latex/wrapfig2/README.txt b/Master/texmf-dist/doc/latex/wrapfig2/README.txt
index c6f50111110..720a426f33f 100644
--- a/Master/texmf-dist/doc/latex/wrapfig2/README.txt
+++ b/Master/texmf-dist/doc/latex/wrapfig2/README.txt
@@ -1,23 +1,31 @@
%%%% README.txt file
-This README.txt for package wrapfig2[2022-01-03 v.4.0.1 ...]
+This README.txt for package wrapfig2[2022-01-26 v.5.0.7 ...]
This work is author maintained
This work consists of wrapfig2.dtx, the main file, this README.txt
and the derived files wrapfig2.pdf and wrapfig2.sty.
+The package besides the source documented source file contains the
+image file commodilla.jpg, a slightly cropped image downloaded from
+the internet site of the Bibliotheca Augustiana in Germany. Apparently
+this image is free provided the source is duly acknowledged.
+
Licence appended to the wrapfig2.sty file.
The software contained herein is a fork of Donald Arseneau wrapfig
package. It uses most of his code, but adds a new environment,
-wraptext, to the existing wrapfigure and wraptable. In addition
-most code uses the LaTeX3 functionalities.
+wraptext, to the existing wrapfigure and wraptable ones.
Supposedly this software is backwards compatible with Arseneau's
original environments. Future experience may confirm this statement.
The user commands are defined by means of the LaTeX3 functionalities.
-Therefore this package does not work with LaTeX2e kernels older than about 2018, although a warning is issued if the LaTeX format file is dated with a date older than 1st January 2019.
+Therefore this package does not work with LaTeX2e kernels older than
+about 2018, although a warning is issued if the LaTeX format file is
+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.
Claudio Beccari
diff --git a/Master/texmf-dist/doc/latex/wrapfig2/commodilla.jpg b/Master/texmf-dist/doc/latex/wrapfig2/commodilla.jpg
new file mode 100644
index 00000000000..4c8dc01e2e9
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/wrapfig2/commodilla.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 1b17f61e8ef..dcbb079d64f 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 36b142c9673..55147dcd015 100644
--- a/Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx
+++ b/Master/texmf-dist/source/latex/wrapfig2/wrapfig2.dtx
@@ -8,7 +8,7 @@
\preamble
Copyright (C) 1991-2003 by Donald Arseneau (asnd@triumf.ca)
-Copyright (C) 2021 by Claudio Beccari (claudio.beccari@gmail.com)
+Copyright (C) 2021-2022 by Claudio Beccari (claudio.beccari@gmail.com)
License information appended
\endpreamble
@@ -22,7 +22,7 @@ this license is at: http://www.latex-project.org/lppl.txt
This work is "maintained"
This work consists of file wrapfig2.dtx, and the derived files
-wrapfig2.sty and wrapfig2.pdf, plus the auxiliary file README.txt.
+wrapfig2.sty and wrapfig2.pdf, plus this file README.txt.
\endpostamble
\askforoverwritefalse
@@ -45,22 +45,25 @@ wrapfig2.sty and wrapfig2.pdf, plus the auxiliary file README.txt.
%<+package>\ProvidesPackage{wrapfig2}%
%^^A<+readme>File README.txt for package wrapfig2
%<*package|readme>
- [2022-01-03 v.4.0.1 Wrapfig extended]
+ [2022-01-26 v.5.0.7 Wrap text around figures, tables, framed text blocks]
%</package|readme>
%<*driver>
%
\documentclass{ltxdoc}\errorcontextlines=100
\hfuzz 10pt
+\usepackage[greek.ancient, english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{mflogo}
-\usepackage{multicol,amsmath,fancyvrb,graphicx,verbatim,pict2e,trace}
-\usepackage{xfp,xcolor,wrapfig2,tcolorbox,kantlipsum,xspace}
+\usepackage{multicol,amsmath,fancyvrb,verbatim,microtype}
+\usepackage{wrapfig2,kantlipsum,xspace}
+%
\GetFileInfo{wrapfig2.dtx}
\title{The \textsf{wrapfig2} package}
\author{Claudio Beccari\thanks{E-mail: \texttt{claudio dot beccari at gmail dot com}}}
\date{Version \fileversion~--~Last revised \filedate.}
+%
\providecommand*\diff{\mathop{}\!\mathrm{d}}
\renewcommand\meta[1]{{\normalfont\textlangle\textit{#1}\textrangle}}
\renewcommand\marg[1]{\texttt{\{\meta{#1}\}}}
@@ -94,11 +97,20 @@ wrapfig2.sty and wrapfig2.pdf, plus the auxiliary file README.txt.
\renewcommand\env[1]{\meta{\textsf{\slshape#1}}}\let\amb\env
\providecommand\Env{}
\renewcommand\Env[1]{\textsf{\slshape#1}}\let\Amb\Env
+\providecommand\opt{}
+\renewcommand\opt[1]{\textsl{\meta{#1}}}
\providecommand*\Bambiente[1]{\texttt{\char92begin\{#1\}}}
\providecommand*\Eambiente[1]{\texttt{\char92end\{#1\}}}
\let\Bamb\Bambiente \let\Benv\Bamb
\let\Eamb\Eambiente \let\Eenv\Eamb
+\ProvideDocumentCommand\goodpagebreak{O{4}}{%
+\dimen10=#1\baselineskip
+\dimen8=\dimexpr\pagegoal-\pagetotal\relax
+\ifdim\dimen8 < \dimen10 \newpage\fi}
+
+
+
\makeatletter
\AfterEndPreamble{%
@@ -122,45 +134,6 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\RenewDocumentCommand\setfontsize{O{1.2} m}{%
\fontsize{#2}{\fpeval{#1*#2}}\selectfont}
-
-\newwrite\example@out
-\ProvideDocumentEnvironment{Esempio}{ O{\footnotesize} D(){0.50}}
-% All definitions and assignments are local
-% #1 := LaTeX font size command or \setfontsize{<size>}
-% %2 := \textwidth percentage for the code box; the complement, less the
-% column gap, for the resulting compiled code
-% Syntax: \begin{Esempio}[<size command>](<code-box percentage-width>)
-%
-{\par\addvspace{3.0ex plus 0.8ex minus 0.5ex}\vskip -\parskip
-\dimendef\Wboxu=2570 \dimendef\Wboxd=2572
-\Wboxu=#2\textwidth\relax
-\Wboxd=\dimexpr\linewidth-\columnsep-\Wboxu\relax
-\begingroup
-\@bsphack
-\immediate\openout\example@out\jobname-temp.tex
-\let\do\@makeother\dospecials\catcode`\^^M\active
-\def\verbatim@processline{%
- \immediate\write\example@out{\the\verbatim@line}}%
-\verbatim@start\relax}%
-{\immediate\closeout\example@out\@esphack\endgroup
-\begin{lrbox}{0}%
-\begin{minipage}{\textwidth}%
-\begin{minipage}{\Wboxu}%
-#1\relax
-\verbatiminput{\jobname-temp.tex}
-\end{minipage}%
-\hfill
-\begin{minipage}{\Wboxd}\raggedleft
-\input{\jobname-temp}%
-\end{minipage}
-\end{minipage}%
-\end{lrbox}%
-
-\medskip
-\noindent\makebox[\textwidth]{\box0}%
-\par
-}
-
\providecommand\hz{\hskip0pt}
\newenvironment{ttsintassi}{\begin{lrbox}{0}
@@ -182,100 +155,121 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \fi
%
% \begin{abstract}
-% This new package \pack{wrapfig2} is a fork that upgrades Donald
+% This new package \pack{wrapfig2} is a fork that extends Donald
% Arseneau's package \pack{wrapfig} (version 2.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
% that must be indented in order to receive the wrapped object.
-% A new environment is added to the traditional \Env{wrapfigure}
+% A new environment is added to the original \Env{wrapfigure}
% and \Env{wraptable}, namely \Env{wraptext}; it may be used
-% to wrap a small framed text block on a grey background; the
+% 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 is different.
+% 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
+% compatibility.
% \end{abstract}
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% \paragraph{Caution} This package requires a fairly recent
+%
+% {\color{red}\paragraph{Caution} This package requires a fairly recent
% \LaTeX kernel, otherwise it won't work; any \LaTeX kernel dated
% at least 2020 is~OK.
+%
+% Read carefully this document, because the are several pieces of
+% information concerning other packages that may be incompatible
+% with this \pack{wrapfig2} version. Special warnings are typeset
+% in red as this one.}
+%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Introduction}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% The purpose of this package is twofold. On one side it tries
+% 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 the other it
+% upgrading it to 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{tcolorbox} functionalities, and wrapping this
+% the \pack{curve2e} functionalities, and wrapping this
% inserted text with the surrounding main text.
%
% The original software had some idiosyncrasies; Donald Arseneau
-% described them in the documentation of his package; I am sorry
-% to say that such idiosyncrasies have not been reduced; but in
-% any case in order to avoid such peculiar anomalies, it is
+% described them in the documentation of his package; we are sorry
+% to admit that such idiosyncrasies might have been slightly reduced;
+% but in any case in order to avoid such peculiar anomalies, it is
% sufficient to wrap the inserted object with a reasonable
-% number of lines, i.e. by a reasonably long paragraph.
+% number of lines, i.e. by reasonably long paragraphs.
%
% The above implies that no wrapped object code should be specified
-% in the source file close the end of a paragraph; again no object
-% code should be inserted within any list; not even close to the end
-% or to the beginning of section. Arseneau's code is capable of
-% specifying the wrapping number of lines such that two or more
-% paragraphs can be indented so as to wrap a longish insertion,
-% but it is wise to avoid such risky situations. Moreover, if the
-% inserted figure or table has a numbered caption, the number might
-% not result in the correct sequence of the normal corresponding
-% floating objects.
+% in the source file close the end of a paragraph, unless it is
+% followed by other paragraphs; again no object code should be inserted
+% within any list; not even close to the end or to the beginning of a
+% section. Arseneau's code is capable of specifying the wrapping
+% number of lines such that two or more paragraphs can be indented
+% so as to wrap a longish insertion, but it is wise to avoid such
+% risky situations. Moreover, if the inserted object has a numbered
+% caption, the number might not result in the correct sequence with
+% the normal corresponding floating objects.
%
% Therefore the usefulness of the wrapping procedure depends very
-% much from the document author ability to move around his/her code
+% much on the document authors' ability to move around their code
% until a suitable position is found. Certainly a good place is
-% within a longish first section paragraph at the beginning of a
-% new chapter.
-%
-% The code of this package does not do anything to correct such
-% idiosyncrasies. They are caused by the limitations of the
-% \cs{ShipOut} native \TeX/\LaTeXe macro, and very little can be done in
-% addition to what Arseneau already did.
-%
-% Another purpose of this package is to add an option 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 to the
-% value computed by the default mechanism devised by Arseneau. We assume
-% that all user 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, and if the
-% space below the wrapped object is too large, or if such space is
-% too small they count the necessary number of lines and specify
-% it to be processed during another document compilation. When the
-% object to be wrapped is tall, it is very easy to miscount the
-% necessary number of lines, while is is very easy to evaluate the
-% necessary small correction to the default computed value.
-%
-% A furher purpose of this package is to define a new environment,
-% \Env{wraptext}, to wrap a framed text block typeset on a grey
-% background as if it were a figure. On \texttt{texstackexchange}
-% a solution was suggested to a user who was asking for such an
-% arrangement; the solution resorted to a specific use of the
-% \Env{wrapfigure} 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 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
-% have similar problems.
+% within a longish paragraph especially at the beginning of a
+% 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
+% 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
+% 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,
+% and if the space below the wrapped object is too large, or if such
+% space is too small they count the necessary number of lines and
+% specify it to be processed during another document compilation.
+% When the object to be wrapped is tall, it is very easy to miscount
+% the necessary number of lines, while is is very easy to evaluate the
+% necessary small correction to the computed value.
+%
+% A further purpose of this package is to define a new environment,
+% \Env{wraptext}, to wrap a framed text block typeset on a coloured
+% background. On \texttt{texstackexchange} a solution was suggested
+% 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.
+% 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,
+% achieved the desired result but there were two drawbacks: $(a)$
+% the syntax was 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
+% 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.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Environment syntax}
@@ -284,19 +278,18 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% The new syntax for \Env{wrapfigure} and \Env{wraptable} is backwards
% compatible with the original one: just a final optional star is
% added to the original list of arguments.
-% As the list of arguments shows, the \Env{wraptext} environment has
-% similar features, but all its arguments are optional, so that they
-% may be specified independently from one another, provided that, when
-% they are more than one, they are specified in the order
-% shown in the syntax table.
%
% The optional star is available only for the standard \Env{wrapfigure}
% and \Env{wraptable} environments because the backwards compatibility
-% requires the first four optional and mandatory arguments. When the
-% optional star is specified, the \meta{indented lines number} is
-% interpreted as the correction to the computed number.
+% 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.
+%
+% Notice the different syntax in version 4.0 and version 5.0 of the
+% \Env{wraptext} syntax.
%
-% \begin{ttsintassi}\setfontsize{8.10}
+% \begin{ttsintassi}\setfontsize{8.00}
%\Bambiente{wrapfigure}\oarg{indented lines number}\marg{location}\oarg{overhang}\oarg{width}\meta{$\star$}
%\qquad\meta{figure}
%\Eambiente{wrapfigure}
@@ -305,38 +298,54 @@ 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.*}.
+%~
%\Bambiente{wraptext}\oarg{location}\barg{width}\aarg{indented line number correction}\parg{caption label}
-%\qquad\meta{wrapped framed text}
+%\qquad\meta{text to frame}
+%\Eambiente{wraptext}
+%~
+%\textnormal{\color{red}No package option required for version 5.0.*}.
+%~
+%\Bambiente{wraptext}\oarg{indented lines number correction} \marg{location} \oarg{overhang} \oarg{width}
+%\qquad \meta{optional colour settings}
+%\qquad\cs{includeframedtext}\marg{text to frame}\Oarg{\meta{frame thickness},\meta{frame separation}}
%\Eambiente{wraptext}
% \end{ttsintassi}
+%^^A
+% Please notice that both 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.
+%
+% 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
+% 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
+% \texttt{texstackexchange} that used the very elaborate \Env{tcolorbox}
+% environment; version~5.0 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.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Examples}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% We display some examples by using fake objects such that suitably
-% long paragraphs are available; some fake-language long-paragraphs are
-% obtained by means of the \pack{kantlipsum} package functionalities.
-% They contain paragraphs that look as Kant's sentences, but we
-% doubt that Immanuel Kant ever wrote such texts\dots
+% We display some examples by using fake objects and suitably
+% long paragraphs; some fake-language long-paragraphs are
+% obtained by means of the \pack{kantlipsum} package functionalities;
+% they are emphasised with an italic font.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \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}
-%\end{wrapfigure}
-%
-% \kant[1]
-%
-%
-% The code used to type the above figure is the following:
+% The code used to type figure~\ref{fig:figure} is the following:
%
%\begin{flushleft}\obeylines%
%\noindent\Bambiente{wrapfigure}\Marg{r}\Marg{50mm}
@@ -345,15 +354,24 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\cs{polygon}\texttt{(0,0)(40,0)(40,30)(0,30)}
%\cs{Line}\texttt{(0,0)(40,30)}\cs{Line}\texttt{(0,30)(40,0)}
%\Eambiente{picture}
-%\cs{caption}\Marg{A rectangle with its diagonals}
+%\cs{caption}\Marg{A rectangle with its diagonals}\cs{label}\Marg{fig:figure}
%\Eambiente{wrapfigure}
-%~
-%\cs{kant}\Oarg{1}
+%\Marg{\cs{itshape} \cs{kant}\Oarg{1}}
%\end{flushleft}
%
% 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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -380,8 +398,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\end{tabular}
%\caption{A small table}
%\end{wraptable}
-%
-%\kant[2]
+%{\itshape \kant[2]}
%
% The above wrapped small table has been typeset by means of the
% following code.
@@ -396,13 +413,13 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\quad\Eambiente{tabular}
%\quad\cs{caption}\Marg{A small table}
%\Eambiente{wraptable}
-%\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 we think that a smart use of
+% 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
@@ -421,37 +438,84 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\end{tabular}
%\caption{A small table}
%\end{wraptable}
-%\kant[2]
+%{\itshape \kant[2]}
+%
+%^^A\goodpagebreak
+% \newpage
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{A wrapped text}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% \begin{wraptext}
-% Text, text, text, text, text, text, text, text, text, text, text.
+% \begin{wraptext}{l}
+% \includeframedtext{Text, text, text, text, text, text, text, text, text, text, text.}
% \end{wraptext}
-% \kant[3]
-%\enlargethispage{-2\baselineskip}
+% {\itshape \kant[3]}
%
% The above example was typeset with this simple code:
%\begin{flushleft}\obeylines
-% \Bamb{wraptext}
-% \ttfamily Text, text, text, text, text, text, text, text, text, text, text.
+% \Bamb{wraptext}\Marg{l}
+% \cs{includeframedtext}\Marg{\ttfamily Text, text, text, text, text, text, text, text, text, text, text.}
% \Eamb{wraptext}
-% \cs{kant}[3]
+% \Marg{\itshape \cs{kant}[3]}
%\end{flushleft}
%
-% As it was previously shown, the syntax for the \Env{wraptext}
-% environment is a little different from that of the other two
-% environments. The logic behind it is substantially the same;
-% the \meta{width} parameter is optional; its preset value is
+% The result is the same as that obtainable with version~4.0 of this
+% package where 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.
+%
+% \begin{wraptext}{r}
+% \includeframedtext{Text, text, text, text, text, text, text, text, text, text, text.}
+%\caption{A wrapped text}%
+% \end{wraptext}
+% {\itshape \kant[3]}
+%
+% The further feature introduced by version~5.0.* 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
+% possible to set different colours from the default light grey for
+% the background, the black text, and the almost black frame:
+% \begin{ttsintassi}
+%\cs{SetWFfrm}\marg{frame colour}
+%\cs{SetWFbgd}\marg{background colour}
+%\cs{SetWFtxt}\marg{text colour}
+% \end{ttsintassi}
+%See figure~\ref{fig:framed text}
+%
+%\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]}%
+%\caption{Some framed text boxes with different dimension parameters,
+% different font size, and different colours}\label{fig:framed text}
+%\end{figure}
+%
+% As it was previously shown, the syntax of environment \Env{wraptext}
+% for version~5.0 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
+% 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.
+%
+% In all cases the \meta{width} parameter is a 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 \Env{minipage} environment; the
-% measure of this mini page should not be too small (unless
+% in justified mode within a \cs{parbox} argument; the
+% measure of this text box should not be too small (unless
% the text is less than one line long) otherwise the inter
% word spacing might be too large; at the same time the measure
-% of the mini page cannot be too large, otherwise the indented
+% 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
@@ -459,14 +523,8 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% 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}.
-%
-% A warning is necessary: if a caption is entered
-% within the environment, such caption gets typeset within the
-% background coloured frame. We think that a framed text does not
-% require any caption; if such caption were necessary, then the
-% user should resort to other means, for example, to a standalone
-% small PDF file containing the framed shaded text to be imported
-% as a figure with the \amb{wrapfigure} environment.
+% In any case version~5.0 of \Env{wrapfig2} resets any specified
+% width outside the above range at the nearest range bound.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Remarks}
@@ -482,60 +540,124 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% number assumes the meaning of a correction to the computed number
% of the indented lines.
%
-% The mandatory \meta{placement} maintains its meaning and the legal
+% The mandatory \meta{location} maintains its meaning and the legal
% values are \texttt{l} (left), \texttt{r} (right), \texttt{L}
% (floating left), \texttt{R} (floating right), \texttt{i}
% (inner margin), \texttt{o} (outer margin), \texttt{I}
% (floating inner margin), \texttt{O} (floating outer margin).
%
-% We tested all of them, but as a 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.
+% 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.
%
% As in the previous examples, we prefer to specify the wrapping
-% environment before a sufficiently long paragraph. Should the
+% 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 indented
-% lines and to apply the \cs{overhang} command with the remaining
-% line number to the following paragraph(s); in these circumstances
+% the environments are capable of counting the number of used indented
+% 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 \TeX introduces only at ship~out
+% 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
% environment some paragraphs before or after the preferred one; but
% this can be done only while reviewing the document, because any
% change in the previous source text might change the situation
-% if this adjustment is done while still editing the document.
+% if this adjustment is done while still editing the document.
+%
+% Juan Luis Varona Malumbres, whom we thank very much, noticed that
+% if the space left at the bottom of a page is scarse, it may be
+% 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
+% exhibit any more this “feature”. Unfortunately in some rare cases
+% this “feature” pops up agains; 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
+% varieties of classes and packages that redefine such sectioning
+% commands.
%
% With the standard environments the optional parameter \meta{overhang}
% 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;
-% we believe that a wrapped text logically pairs the wrapping text;
-% of course this opinion might be wrong and in future upgrades we
-% might add this functionality.
+% parameter is not available for the \Env{wraptext} environment,
+% or better, it is still available in version~5.0, 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.
+%
%
% The \meta{width} parameter has been already sufficiently described;
% we just remember that for \Env{wraptext} this parameter is optional
-% and its default value amounts to half the current measure; it can
-% be specified but it should not be too different from 50\% the
-% current measure. For the standard environments this parameter value
-% is mandatory, but, we recall, only for the redefined environments
-% \env{wrapfigure} and \env{wraptable}, this braced argument is optional.
+% and its default value amounts to half the current measure; this
+% 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
+% redefined environments \env{wrapfigure} and \env{wraptable}.
+%
+% Matter of facts, for the \Env{wraptext} environment we defined a
+% command in order to specify a factor $x$ so as to avoid getting the
+% object width outside the range $xy_0 \leq y \leq y_0/x$, where $y_0$
+% is the preset default width; if the authors specified
+% a value outside this range, the above environment automatically
+% resets the insertion width $y$ to the nearest bound. Of course authors
+% have the possibility to change the preset $x$ value, if they redefine
+% the \cs{WFscalefactor} macro, but such resetting is strongly
+% discouraged; the default value is~$0.8$.
+%
+% 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]}
+%
+% The wrapped text may be written also in a foreign language, even
+% if it uses a differente alphabet. Evidently this language should
+% be specified in the preamble of the author's document, either
+% when using \pack{babel} or \pack{polyglossia}. The example
+% text~\ref{txt:greek} was typeset with the following code:
+%\begin{flushleft}\ttfamily\obeylines
+%\Bamb{wraptext}\Marg{l}
+%\cs{includeframedtext}\Marg{\%
+%\qquad\cs{foreignlanguage}\Marg{greek}\Marg{\foreignlanguage{greek}{Κα᾽γὼ σὲ πατάξας διαλύσω τὸ κρανὶον}}}
+%\cs{caption}\Marg{A sample text in Greek}\cs{label}\Marg{txt:greek}
+%\Eamb{wraptext}
+%\end{flushleft}
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Other floating objects}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pictures and textual arrays may be floated by means of the standard
% \amb{figure} and \amb{table} environments. But other floating
-% objects may be defined by means of other packages, for example the
+% 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.
+% 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}
@@ -547,43 +669,156 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%\quad\qquad\meta{image}
%\Eenv{wrapfloat}
%\end{flushleft}
-% Another \meta{object} may be wrapped by using:
+% Another \meta{object} might be wrapped by using:
%\begin{flushleft}\ttfamily\obeylines
-%\Benv{wrapfloat}\marg{object name}\oarg{line number}\marg{placement}\%
+%\Benv{wrapfloat}\marg{object name}\oarg{line number}\marg{location}\%
%\quad \oarg{overhang}\marg{width}\meta{$\star$}
%\qquad\qquad\meta{object}
%\Eenv{wrapfloat}
%\end{flushleft}
%
-% If the floating \meta{placement} 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
-% packages or classes.
+% By reading the documentation of the original \pack{wrapfig} package,
+% 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
+% 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,
+% 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
+% a new real floating environment with that name. To do this task,
+% \pack{wrapfig2} version~5.0 uses 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}
+% 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
+% work correctly with the new \Env{text} floating environment. Therefore
+% we reinstated the \LaTeXe kernel relevant definitions.
+%
+% It is possible that such resetting of the original definition is
+% 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
+%
+%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section*{Acknowledgements}
+%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% We gratefully thank Donald Arseneau who gave the \TeX community
+% the original \Env{wrapfig} package.
+%
+% 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.
+%
+% Warm thanks also to Juan Luis Varona Malumbres for his precious
+% feedback and his suggestions.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% \CheckSum{1061}
+% \CheckSum{1345}
% \StopEventually{}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
+%\iffalse
+%<*package>
+%\fi
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{The code}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Here we describe and comment the code of this package; essentially
% only the initial parts need some comments; because the final ones
-% are almost identical to the original Arseneau's code.
-%
-% We start with the usual specification of the format name and date,
-% and the identification of this specific package. We possibly load
-% the \pack{etoolbox} package, because we immediately need a
-% test on the existence of an @-protected macro; should this macro
-% already been defined by the class or other packages (including a
-% previous loading of this package or the previous Arseneau's one)
-% the loading is immediately aborted. If is was not previously loaded,
-% we load the \pack{xfp} package, that allows us to perform precise
-% calculations. Loading the \pack{xparse} package is necessary in
-% order to use one of its rare features that did not migrate
-% to the \LaTeX kernel. From the \LaTeX News Letter dated October 2020:
+% are almost identical to Arseneau's original code.
+%
+% The usual specification of the format name and date, and the
+% identification of this specific package have been already specified
+% by the \texttt{.dtx} file.
+%
+% 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
+% 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
+% 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.
+%
+%{\color{red}\paragraph{Caution} besides the evident error message,
+% that might be neglected by the user, the job may continue but it
+% may produce several errors difficult to interpret. Please,
+% in these cases read the \texttt{.log} file and look for error
+% messages; there you are going to discover what has gone wrong
+% with your way of using this package.}
+%
+% \begin{macrocode}
+\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
+ ****************************************************\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!}
+\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.
+%
+%
+% \begin{macrocode}
+\def\WF@warning{\PackageWarning{wrapfig2}}
+\DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig2}}}
+\newif\ifWFnew \let\ifWFnew\iftrue
+\DeclareOption{WFold}{\let\ifWFnew\iffalse}
+\ProcessOptions
+
+% \end{macrocode}
+%
+% We load the \pack{etoolbox} package, in order to have available
+% its powerful macros.
+%
+% If is was not previously loaded, we load the \pack{xfp} package,
+% that allows us to perform precise calculations. Loading the
+% \pack{xparse} package is necessary in order to use one of its
+% rare features that did not migrate to the \LaTeX kernel. From the
+% \LaTeX News Letter dated October 2020:
%\begin{quote}
% Most, but not all, of the argument types defined by \pack{xparse}
% are now supported at the kernel level. In particular, the types
@@ -592,33 +827,77 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% explicitly loading \pack{xparse}. All other argument types are
% now available directly within the \LaTeXe kernel.
%\end{quote}
-% For now their availability eases the treatment of the backwards
+% 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 \pack{wrapfigure}, \pack{wraptable}, and \pack{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}.
+% 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.
+%
%
-%\iffalse
-%<*package>
-%\fi
-
% \begin{macrocode}
-\NeedsTeXFormat{LaTeX2e}[2020-01-01]
-\ProvidesPackage{wrapfig2}%
- [2021-11-30 v.4.0 Wrap text around figures, tables, framed text blocks]
-\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
-\ifcsdef{c@WF@wrappedlines}{\endinput}{}
-\ifcsdef{fpeval}{}{\RequirePackage{xfp}}
\RequirePackage{xparse}
+\@ifpackageloaded{xfp}{}{\RequirePackage{xfp}}
+\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
+\@ifpackageloaded{float}{}{\RequirePackage{float}}
+\@ifpackageloaded{color}{}{%
+ \@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}%
+ }
+\@ifpackageloaded{curve2e}{}{\RequirePackage{curve2e}}
% \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
+% 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}
+% redefines some \pack{color} internal commands; everything is
+% 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
+% is \texttt{true}.
+%
+% If the \cs{chapter} command is or is not defined we have to load
+% the \pack{float} package with different options; for example, if
+% we are using the \class{article} class, the \cs{chapter} command
+% is undefined, and the last option might become \opt{section} (although
+% in the standard \class{article} class, no floating object counter
+% belongs to any other counter reset list) so as to have the floating
+% \Env{text} environment correctly reset the right counter with the
+% right label before the object number.
+% \begin{macrocode}
+\ifWFnew
+ \floatstyle{plain}
+ \ifcsname chapter\endcsname
+ \newfloat{text}{tbp}{lotx}[chapter]
+ \else
+ \newfloat{text}{tbp}{lotx}
+ \fi
+ \floatname{text}{Text}
+ \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
+% \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:
+%\begin{ttsintassi}
+%\cs{counterwithin}\marg{counter}\marg{main counter reset list}
+%\end{ttsintassi}
+%
% Next we define some dimensions, boxes, token registers, \TeX counters,
-% and alias names. The \cs{WF@correctlines@switch} \TeX numeric register
-% (not a \LaTeX counter) is going to be used a boolean switch; if its
-% value is zero, il means “false”, otherwise is “true”; in the other
+% and alias names, plus some color and macro definitions.
+% The \cs{WF@correctlines@switch} \TeX numeric register
+% (not a \LaTeX counter) is going to be used as a boolean switch: if its
+% value is zero, il means “false”, otherwise it is “true”; in the other
% definitions below, it will be set only to 0 or 1, depending on the
% presence of the optional star.
% \begin{macrocode}
@@ -630,51 +909,60 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\newtoks\WF@everypar
\newif\ifWF@float
\newcount\WF@correctlines@switch
-\newdimen\insertwidth
\let\@@parshape\parshape
\let\WF@@everypar\everypar
+\newdimen\insertwidth
+\newdimen\WFinsertwidthL
+\newdimen\WFinsertwidthH
+
+\definecolor{WFbackground}{rgb}{0.95,0.95,0.95}
+\definecolor{WFframe}{rgb}{0.1,0.1,0.1}
+\colorlet{WFtext}{black}
+\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}
+
+\def\WFscalefactor{0.8}%
+\newcommand*\WFscalewidth{%
+ \WFinsertwidthL=\fpeval{\WFscalefactor*0.5\columnwidth}\p@
+ \WFinsertwidthH=\fpeval{0.5\columnwidth/\WFscalefactor}\p@
+ \ifdim\insertwidth<\WFinsertwidthL
+ \insertwidth=\WFinsertwidthL
+ \else
+ \ifdim\insertwidth>\WFinsertwidthH
+ \insertwidth=\WFinsertwidthH
+ \fi
+ \fi
+}%
+
% \end{macrocode}
%
-% In what follows we are going to use very often the functionalities
-% of the \pack{xparse} package that are mostly already included into
-% the \LaTeX kernel; but, since we use one of this functionalities that
-% have not migrated to the \LaTeX kernel, we load it, as they remain
-% available with that package; nevertheless we specified a
-% \LaTeX format date insuring that the \LaTeXiii syntax is available.
%
-% Should the format file be an older one, 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}.
+% {\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 about in 2018; should the users
-% have available a definitely older \TeX system installation, they
+% \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 one; if they need to wrap text, they should
-% resort to some ingenious tricks to do it.
+% 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
+% 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
+% the traced \texttt{.log} file would become too large to be of any
+% 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
+% are sufficient to replace the extremely powerful \pack{tcolorbox}
+% functionalities needed by this \pack{wrapfig2} package.
%
-% The opening command of the \Env{wrapfloat} environment receives
-% the mandatory and optional arguments plus the name of the particular
-% object to be wrapped. It is used to define the prefix label of the
-% caption number in case that the object is described with a caption. The
-% optional star is not explicit, because it is going to be read by
-% the \cs{WF@wr} macro.
-%
-% The closing command of \Env{wrapfloat} performs most of
-% the work necessary to wrap the box that contains the object
-% to be wrapped, but certain tasks are demanded to other service
-% macros.
-%
-% It may 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}
-% has been used, it saves the \meta{overhang} value to be used when
-% wrapping is actually performed; then it verifies if the box height
-% is too high to fit, or is too short; possibly re-boxes this box
-% in the same box register with a negative initial vertical skip
-% that raises the box contents.
%
% The definitions of the \Env{wrapfigure} and \Env{wraptable}
% environments are very simple by means of the underlaying
@@ -690,105 +978,336 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \end{macrocode}
%
+% Notice that the argument descriptor \texttt{s} for the optional
+% star is not present in these definitions; if a star is being used,
+% it will be read by successive macros or environments.
+%
+% In order to include the text to be wrapped the floating object
+% \Env{text} has already been defined, but we need a suitable command
+% 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.
+% \begin{macrocode}
+\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}
+
+% \end{macrocode}
+%
+%
+% Its simple syntax is the following
+%\begin{ttsintassi}
+%\cs{includeframedtext}\oarg{text width}\marg{text}\oarg{settings}\oarg{radius}
+%\end{ttsintassi}
+%
+% The optional \meta{text width} is the (possibly scaled) width computed
+% by the \Env{wraptext} environment; but if the authors use this command
+% outside the \Env{wraptext} environment, they should specify a width;
+% 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
+% 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}.
+%
+% 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
+% 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}
+% environment, any coordinate is expressed in multiples of
+% \cs{unitlength}.
+%
+% For a rectangle with curved corners of a given radius \cs{R}
+% we have four quarter circles joined by straight lines; therefore
+% we need eight nodes.
+%
+% 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.
+%
+% 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.
+%
+% 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}}%
+%
+\edef\WFXds{\fpeval{-\xc+\R}}\edef\WFXsd{-\WFXds}%
+\edef\WFYuo{\fpeval{\yc-\R}}\edef\WFYou{-\WFYuo}%
+%
+\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{%
+ (\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*}%
+%
+\begin{picture}(\x,\y)(-\xc,-\yc)
+{\color{WFbackground}\expandafter\CurveStar\WFrectangle}%
+{\color{WFframe}\linethickness{#2}\expandafter\Curve\WFrectangle}%
+\put(0,0){\makebox(0,0)[cc]{\box0}}%
+\end{picture}
+\egroup}
+
+% \end{macrocode}
+% Its syntax is the following.
+%\begin{ttsintassi}\setfontsize{8.5}\obeylines
+%\cs{framedbox}\marg{text to be wrapped}\marg{frame thickness}\marg{frame separation}\oarg{corner radius}
+%\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
+% 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}.
+%
% The definition of the \Env{wraptext} environment is more detailed,
% because most of the computations must be done on the actual text
% to be wrapped, that does not have a specific width; moreover the
% inserted text must not be too wide, nor too short in order to avoid
-% problems for its justification or the justification of the wrapping
+% 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\%), while for the other environments the wrapped
-% material width is an \emph{braced optional parameter}.
-%
-% For what concerns the \Env{wraptext} environment, see below,
-% because the code is a little more complicated and requires some
-% explanation.
-% In facts the first 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 one line more or less
-% depending on the measure of the whole text, and that of the
-% inserted block and/or the measure of the indented wrapped 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.
+% too different from 50\%); as with the other wrapping environments, the
+% inserted material width is a \emph{braced optional parameter}.
+%
+% For what concerns \Env{wraptext}, the first 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
+% one line more or less depending on the measure of the whole text,
+% 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.
%
% 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
+% optional parameters, uses the separate opening and closing
% macros of the \Env{wrapfloat} environment; such procedure
-% apparently breaks this second availability of the input parameters,
+% 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},
% while assignment to \LaTeX\ named counters, through the
% \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 assigned at the beginning;
+% The \cs{NWF@box} box register has been allocated at the beginning;
% remember that \LaTeXiii registers of any kind are not limited in number
-% as they were some years ago even with \LaTeXe.
+% as they were some years ago with \LaTeXe.
+%
% The last opening commands are conceived to box the object to be
-% wrapped, typeset within a \Env{minipage} with the default or
-% specified width; such box, and the \Env{tcolorbox} and
-% \Env{minipage} environments are closed at the beginning of the
-% closing commands, so that what is necessary in order to place the
-% wrapped boxed text is easy to be executed.
-%
+% 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
+% 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
+% 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
+% 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
+% 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.
% The number of indented lines is computed by means of the
% \cs{fpeval} \LaTeXiii function; among the operands of this
-% function there is the value \texttt{2} used to take into
-% account the vertical space used by \Env{tcolorbox} to
-% separate the frame from its contents. It is possible that
-% a value of \texttt{3} might reduce the probability of using the
-% \meta{line number correction}. But it is not always true and we
-% found that the chosen value is a better choice.
+% function there is the number \texttt{2} used to take into
+% account the vertical space above and below the framed box.
+% It is possible that a value of \texttt{3} might reduce the
+% probability of using the \meta{line number correction}. But
+% it is not always true and we found that the chosen value is
+% a better choice.
%
% Eventually the opening \Env{wrapfloat} statement is created by
% expanding the whole line complete of 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.
+%
+% Notice that the syntax of the new \Env{wraptext} environment is
+% 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
+% \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.*.
% \begin{macrocode}
-\NewDocumentEnvironment{wraptext}%
- {O{l} D||{0.5\columnwidth} D<>{0} D(){figure}}%
-{% Open environment
- \insertwidth=#2\relax
- \def\textplacement{#1}%
- \def\textcorrection{#3}%
- \def\WF@caption@label{#4}%
- \begin{lrbox}\NWF@box% This box is to contain the framed text
- \minipage{\insertwidth}%
- \tcolorbox
-}{% Close environment
- \endtcolorbox\endminipage\end{lrbox}%
- \edef\NWF@wli% \NWF@wli is a macro, not a counter
- {%
- \fpeval{%
- round((\ht\NWF@box+\dp\NWF@box)/\baselineskip,0)+2+\textcorrection
- }%
+\ifWFnew
+\NewDocumentEnvironment{wraptext}{O{0} m O{0pt} G{0.5\columnwidth}}{%
+ \insertwidth=#4\WFscalewidth
+ \def\textplacement{#2}%
+ \def\textcorrection{#1}%
+ \def\textoverhang{#3}%
+ \bgroup\edef\x{\egroup\noexpand\wrapfloat{text}%
+ [\textcorrection]{\textplacement}[\textoverhang]{\insertwidth}*}\x%
+ \def\caption{\unskip
+ \refstepcounter\@captype
+ \let\@tempf\@caption
+ \unless\ifcsname @float@c@\@captype\endcsname
+ \expandafter\expandafter\let
+ \expandafter\@tempf\csname @float@c@\@captype\endcsname
+ \fi
+ \@dblarg{\@caption\@captype}%
}%
- \ifhmode\unskip\else\leavevmode\noindent\fi
- \bgroup\edef\x{\egroup\noexpand\wrapfloat{\WF@caption@label}[\NWF@wli]%
- {\textplacement}{\the\insertwidth}}\x
- \box\NWF@box % Output framed box containing text
- \endwrapfloat
- \ignorespaces
-}
+}{\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.
+%
+% Notice that the third optional argument contains the
+% \meta{line number correction}, therefore the star used with the
+% other environments is useless; if an asterisk is indadvertedly
+% specified, it is typeset as the first token of the wrapped test.
+%
+% The text to be wrapped, that forms the body of the environment,
+% must be first boxed into a correct width vertical box; this is
+% 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.
+% 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 %
+%
+ \NewDocumentEnvironment{wraptext}%
+ {O{l} D||{0.5\columnwidth} D<>{0} D(){text} }%
+ {%
+ \insertwidth=#2
+ \def\textplacement{#1}%
+ \def\textcorrection{#3}%
+ \def\WF@caption@label{#4}%
+ \setbox0\hbox\bgroup
+ \minipage{\dimexpr\insertwidth-2pt-6ex}%
+}{\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
+ }%
+ }%
+ \unles\ifhmode
+ \leavevmode\noindent
+ \fi
+ \bgroup\edef\x{\egroup\noexpand\wrapfloat{\WF@caption@label}[\NWF@wli]%
+ {\textplacement}{\the\insertwidth}}\x
+ \box\NWF@box
+ \endwrapfloat
+ \ignorespaces
+ }
+\fi
% \end{macrocode}
%
+% The opening command of the \Env{wrapfloat} environment receives
+% the mandatory and optional arguments plus the name of the particular
+% object to be wrapped. It is used to define the prefix label of the
+% caption number in case that the object is described with a caption. The
+% optional star is not explicit, because it is going to be read by
+% the \cs{WF@wr} macro.
+%
+% The closing command of \Env{wrapfloat} performs most of
+% the work necessary to wrap the box that contains the object
+% 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}
+% 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}
+% has been used, it saves the \meta{overhang} value to be used when
+% wrapping is actually performed; then it verifies if the box height
+% is too high to fit, or is too short; possibly re-boxes this box
+% 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 wrote the code in
-% \LaTeXe language, had to split in several macros in order to
-% handle the multitude of interspersed mandatory and optional
-% arguments.
+% 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.
%
% The main function of this environment is to handle the box that
% contains the figure, or the table, or the framed text, or what
-% else, so that the inserted box is preceded and followed by the
+% else, so that the inserted box is preceded and followed by
% suitable vertical spaces, and it is possible to compute the
% number of lines to be indented; often this computed number is correct;
% but in certain cases, when the code is used too close or
@@ -802,10 +1321,10 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% 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 not
+% 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, when its wrapping environment is not
-% specified with a floating \meta{placement} argument.
+% name of the wrapped object, even when its wrapping environment
+% is not specified with a floating \meta{location} argument.
%
% \begin{macrocode}
@@ -854,23 +1373,26 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \cs{WF@wli} is assigned the value zero. The same happens for the
% \meta{overhang} optional argument.
%
-% After these adjustments, it computes the box total height plus some
-% fixed amounts needed mostly to set the wrapped material below the
-% first wrapping text first line. Here is where the \LaTeXiii
+% After these adjustments, the software computes the box total height
+% plus some fixed amounts needed mostly to set the wrapped material
+% below the wrapping text first line. Here is where the \LaTeXiii
% \cs{fpeval} computing function comes into play so as to assign such
-% height to \cs{WF@size}. Some unusual macros are executed; they
-% were devised by Arseneau to deal with possibly floating wrapped
+% 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 does not accept the optional star; if
-% the user specifies it for this environment, an asterisk appears
-% at the beginning of the wrapped text.
-%
-% The braced \texttt{\#4} \meta{width} parameter (actually a
-% \meta{braced optional parameter}) may be specified
+% \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}.
+%
+% 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.
% \begin{macrocode}
\NewDocumentCommand\WF@wr{o m o m s}{%
\xdef\WF@wfname{wrap\@captype\space}%
@@ -992,7 +1514,7 @@ 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
- \@tempdima\pagedepth % save page depth
+ \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
@@ -1032,7 +1554,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\fi
\xdef\WF@place{\the\lccode\lccode\WF@place}%
}% twice to get only l or r
- \hbox to\z@{% llap o rlap depending on l or r; calc effective width
+ \hbox to\z@{% llap o rlap depending on l or r; determine effective width
\@tempdima\wd\WF@box \@tempdimb\WF@ovh
\advance\@tempdima-\@tempdimb \advance\@tempdima\columnsep
\@tempdimb\hsize \advance\@tempdimb-\@tempdima
@@ -1068,7 +1590,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%
% Here comes the very important macro that counts the wrapping indented
% lines, so that wrapping is correct; of course the limitations
-% of the \TeX and \LaTeX processing (needed to ship out a complete
+% of the \LaTeX processing (needed to ship out a complete
% page) forbid to take into account the spaces inserted between
% paragraphs and/or those inserted between entries of various
% listings. The idiosyncrasies of this package arise from the
@@ -1078,8 +1600,8 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% This macro counts the lines to be indented by rounding the division
% of the box height by the current base line skip. Notice that
% \texttt{WF@wrappedlines} is the name of a \LaTeX named counter,
-% not of a \TeX numeric register; therefore special LaTeX commands,
-% such as \cs{setocounter} or \cs{value}, have to be used in order
+% not of a \TeX numeric register; therefore special \LaTeX commands,
+% such as \cs{setcounter} or \cs{value}, have to be used in order
% to set or access the numerical value stored within the \TeX
% register associated to the \LaTeX counter name.
% \begin{macrocode}
@@ -1151,10 +1673,10 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \end{macrocode}
%
-% These macros are to modify the paragraph settings.
+% These macros modify the paragraph settings.
% \begin{macrocode}
\def\WF@modps{\begingroup
- \afterassignment\@tempdimb \@tempdima\WF@pspars % a=indent.num, b= width
+ \afterassignment\@tempdimb \@tempdima\WF@pspars % a=indent.num, b=width
\advance\@tempdima-\WF@adjtlm \advance\@tempdimb\WF@adjlw
\let\WF@wrapil\WF@pspars
\edef\@tempb{\@@parshape\c@WF@wrappedlines
@@ -1236,8 +1758,8 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
%
% The following code is one of those “dirty tricks” by which a macro
% defined within a group is executed with the help of an
-%\cs{expandafter} command that bypasses an \cs{endgroup}; by so doing
-% nothing local to the group remains in memory.
+%\cs{expandafter} command that bypasses an \cs{endgroup}; by so doing,
+% after execution nothing local to the group remains in memory.
% \begin{macrocode}
\begingroup
\toks0={\let\everypar\WF@@everypar
@@ -1279,7 +1801,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
% \end{macrocode}
%
% And this one is when two wrapping environments are too close to
-% one another so that the second one is forced to float.
+% one another so that the second one is forced to move.
% \begin{macrocode}
\def\WF@fltmes{% message for floats
\ifWF@float
@@ -1369,26 +1891,7 @@ X\ifdim\fontdimen1\font=0pt\kern-0.15em\fi
\fi
% \end{macrocode}
-% We never described the package options; this code was present
-% in Arseneau's code and we leave it here, with the necessary
-% package-name changes. We think that this \opz{verbose} option
-% was and remains useless, since the instances of command
-% \cs{WF@info} were mostly commented out in the original code;
-% in any case, input of this code is stopped if the
-% \cs{DeclareOption} command is not defined; this command was
-% defined with \LaTeXe; therefore might be a residual of the old
-% times when \LaTeXccix was still in use, more than 25 years
-% ago\dots
-% \begin{macrocode}
-\@ifundefined{DeclareOption}{\endinput}{%
-\def\WF@warning{\PackageWarning{wrapfig2}}%
-\DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig2}}}%
-\ProcessOptions
-\AtEndDocument{\WFclear}}%
-
-\endinput
-% \end{macrocode}
-
+%
%\iffalse
%</package>
%\fi
diff --git a/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty b/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty
index f805080f5af..0fe642f2490 100644
--- a/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty
+++ b/Master/texmf-dist/tex/latex/wrapfig2/wrapfig2.sty
@@ -7,20 +7,51 @@
%% wrapfig2.dtx (with options: `package')
%%
%% Copyright (C) 1991-2003 by Donald Arseneau (asnd@triumf.ca)
-%% Copyright (C) 2021 by Claudio Beccari (claudio.beccari@gmail.com)
+%% Copyright (C) 2021-2022 by Claudio Beccari (claudio.beccari@gmail.com)
%% License information appended
%%
\NeedsTeXFormat{LaTeX2e}[2019/01/01]
\ProvidesPackage{wrapfig2}%
- [2022-01-03 v.4.0.1 Wrapfig extended]
+ [2022-01-26 v.5.0.7 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
+ ****************************************************\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!}
+\expandafter\endinput\fi
+
+\def\WF@warning{\PackageWarning{wrapfig2}}
+\DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig2}}}
+\newif\ifWFnew \let\ifWFnew\iftrue
+\DeclareOption{WFold}{\let\ifWFnew\iffalse}
+\ProcessOptions
-\NeedsTeXFormat{LaTeX2e}[2020-01-01]
-\ProvidesPackage{wrapfig2}%
- [2021-11-30 v.4.0 Wrap text around figures, tables, framed text blocks]
-\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
-\ifcsdef{c@WF@wrappedlines}{\endinput}{}
-\ifcsdef{fpeval}{}{\RequirePackage{xfp}}
\RequirePackage{xparse}
+\@ifpackageloaded{xfp}{}{\RequirePackage{xfp}}
+\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
+\@ifpackageloaded{float}{}{\RequirePackage{float}}
+\@ifpackageloaded{color}{}{%
+ \@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}%
+ }
+\@ifpackageloaded{curve2e}{}{\RequirePackage{curve2e}}
+
+\ifWFnew
+ \floatstyle{plain}
+ \ifcsname chapter\endcsname
+ \newfloat{text}{tbp}{lotx}[chapter]
+ \else
+ \newfloat{text}{tbp}{lotx}
+ \fi
+ \floatname{text}{Text}
+ \let\WF@text@caption\float@caption
+\fi
\newdimen\wrapoverhang \wrapoverhang\z@
\newdimen\WF@size
@@ -30,10 +61,34 @@
\newtoks\WF@everypar
\newif\ifWF@float
\newcount\WF@correctlines@switch
-\newdimen\insertwidth
\let\@@parshape\parshape
\let\WF@@everypar\everypar
+\newdimen\insertwidth
+\newdimen\WFinsertwidthL
+\newdimen\WFinsertwidthH
+
+\definecolor{WFbackground}{rgb}{0.95,0.95,0.95}
+\definecolor{WFframe}{rgb}{0.1,0.1,0.1}
+\colorlet{WFtext}{black}
+\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}
+
+\def\WFscalefactor{0.8}%
+\newcommand*\WFscalewidth{%
+ \WFinsertwidthL=\fpeval{\WFscalefactor*0.5\columnwidth}\p@
+ \WFinsertwidthH=\fpeval{0.5\columnwidth/\WFscalefactor}\p@
+ \ifdim\insertwidth<\WFinsertwidthL
+ \insertwidth=\WFinsertwidthL
+ \else
+ \ifdim\insertwidth>\WFinsertwidthH
+ \insertwidth=\WFinsertwidthH
+ \fi
+ \fi
+}%
+
\NewDocumentEnvironment{wrapfigure}{o m o G{0pt}}%
{\wrapfloat{figure}[#1]{#2}[#3]{#4}}%
{\endwrapfloat}
@@ -42,31 +97,88 @@
{\wrapfloat{table}[#1]{#2}[#3]{#4}}%
{\endwrapfloat}
-\NewDocumentEnvironment{wraptext}%
- {O{l} D||{0.5\columnwidth} D<>{0} D(){figure}}%
-{% Open environment
- \insertwidth=#2\relax
- \def\textplacement{#1}%
- \def\textcorrection{#3}%
- \def\WF@caption@label{#4}%
- \begin{lrbox}\NWF@box% This box is to contain the framed text
- \minipage{\insertwidth}%
- \tcolorbox
-}{% Close environment
- \endtcolorbox\endminipage\end{lrbox}%
- \edef\NWF@wli% \NWF@wli is a macro, not a counter
- {%
- \fpeval{%
- round((\ht\NWF@box+\dp\NWF@box)/\baselineskip,0)+2+\textcorrection
- }%
+\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}
+
+\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}}%
+\edef\WFXds{\fpeval{-\xc+\R}}\edef\WFXsd{-\WFXds}%
+\edef\WFYuo{\fpeval{\yc-\R}}\edef\WFYou{-\WFYuo}%
+\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{%
+ (\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*}%
+\begin{picture}(\x,\y)(-\xc,-\yc)
+{\color{WFbackground}\expandafter\CurveStar\WFrectangle}%
+{\color{WFframe}\linethickness{#2}\expandafter\Curve\WFrectangle}%
+\put(0,0){\makebox(0,0)[cc]{\box0}}%
+\end{picture}
+\egroup}
+
+\ifWFnew
+\NewDocumentEnvironment{wraptext}{O{0} m O{0pt} G{0.5\columnwidth}}{%
+ \insertwidth=#4\WFscalewidth
+ \def\textplacement{#2}%
+ \def\textcorrection{#1}%
+ \def\textoverhang{#3}%
+ \bgroup\edef\x{\egroup\noexpand\wrapfloat{text}%
+ [\textcorrection]{\textplacement}[\textoverhang]{\insertwidth}*}\x%
+ \def\caption{\unskip
+ \refstepcounter\@captype
+ \let\@tempf\@caption
+ \unless\ifcsname @float@c@\@captype\endcsname
+ \expandafter\expandafter\let
+ \expandafter\@tempf\csname @float@c@\@captype\endcsname
+ \fi
+ \@dblarg{\@caption\@captype}%
}%
- \ifhmode\unskip\else\leavevmode\noindent\fi
- \bgroup\edef\x{\egroup\noexpand\wrapfloat{\WF@caption@label}[\NWF@wli]%
- {\textplacement}{\the\insertwidth}}\x
- \box\NWF@box % Output framed box containing text
- \endwrapfloat
- \ignorespaces
-}
+}{\endwrapfloat\ignorespaces}%
+\else %
+ \NewDocumentEnvironment{wraptext}%
+ {O{l} D||{0.5\columnwidth} D<>{0} D(){text} }%
+ {%
+ \insertwidth=#2
+ \def\textplacement{#1}%
+ \def\textcorrection{#3}%
+ \def\WF@caption@label{#4}%
+ \setbox0\hbox\bgroup
+ \minipage{\dimexpr\insertwidth-2pt-6ex}%
+}{\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
+ }%
+ }%
+ \unles\ifhmode
+ \leavevmode\noindent
+ \fi
+ \bgroup\edef\x{\egroup\noexpand\wrapfloat{\WF@caption@label}[\NWF@wli]%
+ {\textplacement}{\the\insertwidth}}\x
+ \box\NWF@box
+ \endwrapfloat
+ \ignorespaces
+ }
+\fi
\NewDocumentEnvironment{wrapfloat}{m o m o G{\z@}}%
@@ -182,7 +294,7 @@
\vskip-\parskip \global\WF@floatfalse
\let\pagetotal\maxdimen % kludge flag for "not top of page"
\else % outer page
- \@tempdima\pagedepth % save page depth
+ \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
@@ -222,7 +334,7 @@
\fi
\xdef\WF@place{\the\lccode\lccode\WF@place}%
}% twice to get only l or r
- \hbox to\z@{% llap o rlap depending on l or r; calc effective width
+ \hbox to\z@{% llap o rlap depending on l or r; determine effective width
\@tempdima\wd\WF@box \@tempdimb\WF@ovh
\advance\@tempdima-\@tempdimb \advance\@tempdima\columnsep
\@tempdimb\hsize \advance\@tempdimb-\@tempdima
@@ -306,7 +418,7 @@
}
\def\WF@modps{\begingroup
- \afterassignment\@tempdimb \@tempdima\WF@pspars % a=indent.num, b= width
+ \afterassignment\@tempdimb \@tempdima\WF@pspars % a=indent.num, b=width
\advance\@tempdima-\WF@adjtlm \advance\@tempdimb\WF@adjlw
\let\WF@wrapil\WF@pspars
\edef\@tempb{\@@parshape\c@WF@wrappedlines
@@ -459,12 +571,6 @@
\@tempa
\fi
-\@ifundefined{DeclareOption}{\endinput}{%
-\def\WF@warning{\PackageWarning{wrapfig2}}%
-\DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig2}}}%
-\ProcessOptions
-\AtEndDocument{\WFclear}}%
-
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
@@ -473,7 +579,7 @@
%% This work is "maintained"
%%
%% This work consists of file wrapfig2.dtx, and the derived files
-%% wrapfig2.sty and wrapfig2.pdf, plus the auxiliary file README.txt.
+%% wrapfig2.sty and wrapfig2.pdf, plus this file README.txt.
%%
%%
%% End of file `wrapfig2.sty'.
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 4861805e9ef..10490a7dc14 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -3118,6 +3118,7 @@ my $core_latex = "$Master/texmf-dist/tex/latex";
'uadocs' => 'latex', # requires interaction
'undolabl' => 'tex',
'velthuis' => 'latex', # requires interaction
+ 'wrapfig2' => 'etex',
'xduthesis' => 'tex',
'xecjk' => 'xecjk-xelatex',
'xmuthesis' => 'etex',