summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-12-23 22:13:25 +0000
committerKarl Berry <karl@freefriends.org>2020-12-23 22:13:25 +0000
commite7d80cd91220015119cc3d6ff3f3594bdb7b3753 (patch)
treeae1cb1800e854a328c8df17f276437ddd6994fa1 /Master/texmf-dist/tex/latex
parent0c74445512fcee63b6eac2575a08f36b47178e19 (diff)
swfigure (23dec20)
git-svn-id: svn://tug.org/texlive/trunk@57211 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/swfigure/swfigure.sty150
1 files changed, 134 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/latex/swfigure/swfigure.sty b/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
index dcadb523c24..f63332322e5 100644
--- a/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
+++ b/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
@@ -11,7 +11,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[2020/01/01]
\ProvidesPackage{swfigure}%
- [2020-11-10 v.0.9.14 Managing large and spread wide figures]
+ [2020-12-23 v.0.9.18 Managing large and spread wide figures]
\RequirePackage{etoolbox}
\RequirePackage{xfp}
@@ -31,8 +31,6 @@
\ExplSyntaxOff
-\RequirePackage{trace}
-
\RequirePackage{graphicx}
\RequirePackage{afterpage}
\RequirePackage{wrapfig}
@@ -49,6 +47,7 @@
\newdimen\DFheight
\newdimen\DFhalfheight
\newdimen\FigSpace
+\newdimen\TScaptionwidth
\def\SWcaptionShift{1em}%
\def\FScaptionShift{2em}%
\newsavebox\DFtotalimage
@@ -65,7 +64,7 @@
\addcontentsline{lof}{figure}{\protect\numberline{\thefigure}#1}
\IfValueT{#3}{\label{#3}}\relax%
}
-\NewDocumentCommand\DFcaptionP{O{#2} m o D!!{black}}%
+\NewDocumentCommand\DFcaptionP{O{#2} m o D!!{\color{black}}}%
{\refstepcounter{figure}%
\vbox to 0pt{\vss\hsize=\textheight\parindent=0pt\leavevmode
#4\relax Figure \thefigure\quad #2}%
@@ -79,7 +78,7 @@
\@SWtmodefalse
\else
\unskip\@SWtmodetrue\linebreak
- \vadjust{\vspace{0pt plus1fill}\newpage}%
+ \vadjust{\vspace{0pt plus1fill}\par}%
\fi}
\newcommand\reset@tmode{\if@SWtmode\expandafter\noindent\ignorespaces\fi}
@@ -89,10 +88,12 @@
\ifodd\c@page\afterpage{#1}\else#1\fi%
}
+\newcommand\cleartopage{\set@tmode@newpage\clearpage}
+
\NewDocumentEnvironment{DFimage}%
- {O{SW} m O{#4} m o D(){0.8} D<>{0} D||{0.25} D!!{}}%
+ { O{SW} m O{#4} m o D(){0.8} D<>{0} D||{0.25} D!!{} }%
{%
- \SetList{\DisplayModeList}{SW,HS,VS,FS,NF,RF}%
+ \SetList{\DisplayModeList}{SW,HS,VS,FS,NF,RF,TH,TW}%
\TestList{\DisplayModeList}{#1}%
{\csuse{#1figure}{#2}[#3]{#4}[#5](#6)<#7>|#8|!#9!%
\fptest{\CompStrings{\@currenv}{DFimage}}{}{\reset@tmode}%
@@ -105,13 +106,13 @@
\aftergroup\reset@tmode
}%
-\NewDocumentCommand\DFwarning{ o m o m o d() d<> d|| d!!}%
-{\PackageWarning{swfigure}%
+\NewDocumentCommand\DFwarning{ o m o m }{%
+\PackageWarning{swfigure}%
{********************************************\MessageBreak
Option #1\space is not valid. Nothing done \MessageBreak
\MessageBreak
Image #2 was not processed \MessageBreak
- *******************************************\MessageBreak
+ ********************************************\MessageBreak
}%
}
@@ -176,22 +177,22 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
\DFwidth=\wd\DFtotalimage \DFheight=\ht\DFtotalimage
\edef\VS@aspectratio{\fpeval{\DFheight/\DFwidth}}
\fptest{ \VS@aspectratio < 2 }%
- {\begin{center}\ttfamily
+ {\begin{center}\ttfamily\relax
===========================================\\
- Image \textit{#1} is not tall enough.\\
- Consider using a display mode different\\
+ Image #1 is not tall enough. \\
+ Consider using a display mode different \\
from VS; may be NF or RF are better suited.\\
===========================================\\
- Nothing done!\\
+ Nothing done! \\
===========================================
\end{center}
}%
{\edef\VS@factor{\fpeval{#5\textheight/\DFheight}}%
\fptest{\VS@factor>1 || \VS@factor\DFwidth < #7\textwidth}%
{%
- \begin{center}\ttfamily
+ \begin{center}\ttfamily\relax
=================================================\\
- The scaled image \textit{#1} is too slim. \\
+ The scaled image #1 is too slim. \\
Maybe directly using the wrapfig package might \\
solve this problem. \\
=================================================\\
@@ -250,6 +251,7 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
}%
}%
}
+
\NewDocumentCommand\FSfigure{m o m o d() d<> d|| d!!}{%
\fptest{\CompStrings{\@currenv}{DFimage}}{}{\bgroup}%
\pagestyle{empty}%
@@ -312,6 +314,122 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
}\clearpage
\fptest{\CompStrings{\@currenv}{DFimage}}{}{\egroup}%
\reset@tmode}
+
+\NewDocumentCommand\THfigure{m o m o d() d<> d|| d!!}{%
+ \setbox\DFtotalimage=\hbox{\includegraphics{#1}}%
+ \DFheight=\ht\DFtotalimage \DFwidth=\wd\DFtotalimage
+ \edef\DFscalefactor{\fpeval{\paperheight/\DFheight}}
+ \setbox\DFimageI\hbox{%
+ \scalebox{\DFscalefactor}{\usebox{\DFtotalimage}}}%
+ \DFwidth=\wd\DFimageI
+ \ifdim\dimexpr\paperwidth-\DFwidth < 2\externalmargin\relax
+ \PackageWarning{swfigure}{%
+ *******************************************\MessageBreak
+ Figure #1 is too wide to be set in a \MessageBreak
+ Total Height display mode. \MessageBreak
+ There is not enough space for its caption. \MessageBreak
+ Expect questionable results. \MessageBreak
+ *******************************************\MessageBreak}%
+ \fi
+ \FigSpace=\DFwidth
+ \dimen10=\dimexpr\topmargin+1in-(\paperheight-\headsep-\headheight
+ -\textheight-\footskip)/2\relax
+ \TScaptionwidth=\dimexpr\paperwidth-\FigSpace-3\columnsep\relax
+ \cleartopage
+ \thispagestyle{empty}%
+ \begin{figure}
+ \ifodd\c@page\relax% odd page
+ \begin{minipage}[c][\textheight][t]{\textwidth}% minibox1
+ \vspace*{\dimen10}%
+ \makebox[\textwidth][l]{\hspace*{-\internalmargin}% hbox2
+ \vbox to\textheight{\vss% vbox3
+ \hbox to\paperwidth{% hbox4
+ \parbox{\FigSpace}{\box\DFimageI}%
+ \hspace{\columnsep}%
+ \makebox[\TScaptionwidth]{%
+ \parbox{#5\TScaptionwidth}{%
+ \caption[#2]{#3}\IfValueT{#4}{\label{#4}}\relax}%
+ }%
+ }% end hbox4
+ \vss}% end vbox3
+ }% end hbox2
+ \end{minipage}% end minibox1
+ \else % even page
+ \begin{minipage}[c][\textheight][t]{\textwidth}
+ \vspace*{\dimen10}%
+ \makebox[\textwidth][l]{\kern-\externalmargin
+ \vbox to\textheight{\vss
+ \hbox to\paperwidth{\hss
+ \hbox to\TScaptionwidth{\hss
+ \parbox{#5\TScaptionwidth}{%
+ \caption[#2]{#3}\IfValueT{#4}{\label{#4}}\relax}%
+ }\hspace{\columnsep}%
+ \parbox{\FigSpace}{\box\DFimageI}%
+ }\vss
+ }%
+ }%
+ \end{minipage}%
+ \fi
+ \end{figure}%
+ \clearpage\reset@tmode
+}
+
+\NewDocumentCommand\TWfigure{m o m o d() d<> d|| d!!}{%
+ \setbox\DFtotalimage=\hbox{\includegraphics{#1}}%
+ \DFheight=\ht\DFtotalimage \DFwidth=\wd\DFtotalimage
+ \FigSpace=\dimexpr\internalmargin+0.80\textwidth\relax
+ \TScaptionwidth=\dimexpr\paperwidth-\FigSpace-2\columnsep\relax
+ \edef\DFscalefactor{\fpeval{\FigSpace/\DFwidth}}
+ \setbox\DFimageI=\hbox{\scalebox{\DFscalefactor}{\box\DFtotalimage}}
+ \DFwidth=\wd\DFimageI \DFheight\ht\DFimageI
+ \cleartopage
+ \thispagestyle{empty}%
+ \ifodd\value{page}% odd numbered page
+ \begin{figure}
+ \setbox\DFimageII=\hbox{%
+ \parbox{\FigSpace}{\box\DFimageI}\hspace{\columnsep}%
+ \begin{minipage}{\TScaptionwidth}\centering
+ \parbox{#5\hsize}{\caption[#2]{#3}%
+ \IfValueT{#4}{\label{#4}}\relax}%
+ \end{minipage}
+ }%
+ \DFheight=\ht\DFimageII \dimen8=\dp\DFimageII
+ \advance\DFheight by\dp\DFimageII
+ \dp\DFimageII=\z@ \ht\DFimageII=\DFheight
+ \dimen10=\fpeval{\topskip+1in+\headheight+\headsep}\p@
+ \advance\dimen8 by\baselineskip
+ \advance\DFheight by-\dimen10\relax
+ \vbox to\DFheight{\vss
+ \hbox{\raise \dimen8\hbox to\textwidth{%
+ \hspace{-\internalmargin}\box\DFimageII\hss}}%
+ }%
+ \end{figure}
+ \else% even numbered page
+ \begin{figure}
+ \setbox\DFimageII=\hbox{%
+ \begin{minipage}{\TScaptionwidth}\centering
+ \parbox{#5\hsize}{\caption[#2]{#3}%
+ \IfValueT{#4}{\label{#4}}\relax}%
+ \end{minipage}
+ \hspace{\columnsep}%
+ \parbox{\FigSpace}{\box\DFimageI}
+ }%
+ \DFheight=\ht\DFimageII \dimen8=\dp\DFimageII
+ \advance\DFheight by\dp\DFimageII
+ \dp\DFimageII=\z@ \ht\DFimageII=\DFheight
+ \dimen10=\fpeval{\topskip+1in+\headheight+\headsep}\p@
+ \advance\dimen8 by\baselineskip
+ \advance\DFheight by-\dimen10\relax
+ \vbox to\DFheight{\vss
+ \hbox{\raise \dimen8\hbox to\textwidth{\hss%
+ \box\DFimageII\hspace{-\internalmargin}}}%
+ }%
+ \hbox to\textwidth{\hspace{-\internalmargin}\box\DFimageII\hss}
+ \end{figure}%
+ \fi
+ \reset@tmode
+}
+
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of