summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/swfigure/swfigure.sty')
-rw-r--r--Master/texmf-dist/tex/latex/swfigure/swfigure.sty62
1 files changed, 40 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/latex/swfigure/swfigure.sty b/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
index 67ace027b68..8b6fdca0b9b 100644
--- a/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
+++ b/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
@@ -11,9 +11,8 @@
%%
\NeedsTeXFormat{LaTeX2e}[2020/01/01]
\ProvidesPackage{swfigure}%
- [2020-10-11 v.0.9.07 Managing large and spread wide figures]
+ [2020-10-13 v.0.9.08 Managing large and spread wide figures]
\RequirePackage{etoolbox}
-\RequirePackage{xparse}
\RequirePackage{xfp}
\ExplSyntaxOn
@@ -44,6 +43,7 @@
\newsavebox\RFbox
\newdimen\VS@textwidth
\newcount\VS@lines
+\newif\if@SWtmode
\NewDocumentCommand\DFcaption{O{#2} m o}{\refstepcounter{figure}%
\vtop to 0pt{\hsize=\textheight\parindent=0pt\leavevmode
@@ -54,7 +54,8 @@
\DeclareRobustCommand\cleartoevenpage{%
\clearpage\ifodd\value{page}\null\clearpage\fi}
-\NewDocumentEnvironment{DFimage}{O{SW} m O{#4} m o D(){0.8} D<>{0}}{%
+\NewDocumentEnvironment{DFimage}{%
+ O{SW} m O{#4} m o D(){0.8} D<>{0} D||{0.25}}{%
\ifstrequal{#1}{SW}%
{%
\SWfigure{#2}[#3]{#4}[#5]%
@@ -69,7 +70,7 @@
}%
{\ifstrequal{#1}{VS}%
{%
- \VSfigure{#2}[#3]{#4}[#5](#6)<#7>%
+ \VSfigure{#2}[#3]{#4}[#5](#6)<#7>|#8|%
}%
{\ifstrequal{#1}{HS}
{%
@@ -90,7 +91,10 @@
}%
\NewDocumentCommand\SWfigure{m O{#3} m o}{%
-\unless\ifvmode
+\ifvmode
+ \@SWtmodefalse
+\else
+ \@SWtmodetrue
\csuse{@bsphack}%
\vadjust{\vspace{0pt plus1fill}\csuse{@esphack}\newpage}%
\fi
@@ -120,7 +124,7 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
\makebox(0,0)[lb]{\hspace*{1em}\raisebox{0.5\textheight}{%
\rotatebox[origin=tc]{90}{\DFcaption[#2]{#3}[#4]%
}}}}\vss}%
-\end{figure}\clearpage}
+\end{figure}\clearpage\if@SWtmode\noindent\fi}
\NewDocumentCommand\NFfigure{m O{#3} m o d()}{%
\begin{figure}[p]
@@ -147,14 +151,14 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
{\scalebox{\RFy}{\box\RFbox}}%
\endfigure}
-\NewDocumentCommand\VSfigure{m O{#3} m o d() D<>{0}}{%
+\NewDocumentCommand\VSfigure{m O{#3} m o d() d<> d||}{%
\setbox\DFtotalimage=\hbox{\includegraphics{#1}}
\DFwidth=\wd\DFtotalimage \DFheight=\ht\DFtotalimage
\edef\VS@aspectratio{\fpeval{\DFheight/\DFwidth}}
\fptest{ \VS@aspectratio < 2 }%
{\begin{center}\ttfamily
===========================================\\
- Figure #2 is not tall enough.\\
+ Image \textit{#1} is not tall enough.\\
Consider using a display mode different\\
from VS; may be NF or RF are better suited.\\
===========================================\\
@@ -163,19 +167,33 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
\end{center}
}%
{\edef\VS@factor{\fpeval{#5\textheight/\DFheight}}%
- \setbox\DFtotalimage=
- \hbox{\scalebox{\VS@factor}{\box\DFtotalimage}}%
- \edef\VS@width{\fpeval{\VS@factor*\DFwidth}\p@}%
- \setbox\DFtotalimage=\vbox{\hsize=\VS@width%
- \def\@captype{figure}\box\DFtotalimage
- \caption[#2]{#3}%
- \IfValueT{#4}{\label{#4}}\relax}
- \VS@lines=
- \fpeval{round(\ht\DFtotalimage/\baselineskip,0)+#6}%
- \begin{wrapfigure}[\VS@lines]{O}[0pt]{\VS@width}%
- \box\DFtotalimage
- \end{wrapfigure}}%
-}
+ \fptest{\VS@factor>1 || \VS@factor\DFwidth < #7\textwidth}%
+ {%
+ \begin{center}\ttfamily
+ =================================================\\
+ The scaled image \textit{#1} is too slim. \\
+ Maybe directly using the wrapfig package might \\
+ solve this problem. \\
+ =================================================\\
+ Nothing done!\\
+ =================================================
+ \end{center}
+ }%
+ {\setbox\DFtotalimage=
+ \hbox{\scalebox{\VS@factor}{\box\DFtotalimage}}%
+ \edef\VS@width{\fpeval{\VS@factor*\DFwidth}\p@}%
+ \setbox\DFtotalimage=\vbox{\hsize=\VS@width%
+ \def\@captype{figure}\box\DFtotalimage
+ \caption[#2]{#3}%
+ \IfValueT{#4}{\label{#4}}\relax}
+ \VS@lines=
+ \fpeval{round(\ht\DFtotalimage/\baselineskip,0)+#6}%
+ \begin{wrapfigure}[\VS@lines]{O}[0pt]{\VS@width}%
+ \box\DFtotalimage
+ \end{wrapfigure}%
+ }%
+ }%
+ }%
\NewDocumentCommand\HSfigure{m o m o d()}{%
\unless\ifvmode
@@ -227,7 +245,7 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
%%
%% This work is "maintained"
%%
-%% This work consists of files swfigure.dtx and READEME.txt, and the derived
+%% This work consists of files swfigure.dtx and README.txt, and the derived
%% files swfigure.sty and swfigure.pdf
%%
%%