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.sty213
1 files changed, 141 insertions, 72 deletions
diff --git a/Master/texmf-dist/tex/latex/swfigure/swfigure.sty b/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
index a12aaee0882..dcadb523c24 100644
--- a/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
+++ b/Master/texmf-dist/tex/latex/swfigure/swfigure.sty
@@ -11,15 +11,24 @@
%%
\NeedsTeXFormat{LaTeX2e}[2020/01/01]
\ProvidesPackage{swfigure}%
- [2020-10-18 v.0.9.11 Managing large and spread wide figures]
+ [2020-11-10 v.0.9.14 Managing large and spread wide figures]
\RequirePackage{etoolbox}
\RequirePackage{xfp}
\ExplSyntaxOn
-\AtBeginDocument{%
-\ProvideExpandableDocumentCommand\fptest{m m m}{%
- \fp_compare:nTF{#1}{#2}{#3}}
-}
+\ProvideExpandableDocumentCommand\CompStrings{m m}{%
+ \str_if_eq_p:nn{#1}{#2}}
+
+ \ProvideExpandableDocumentCommand\fptest{m m m}{%
+ \fp_compare:nTF{#1}{#2}{#3}}
+
+ \ProvideExpandableDocumentCommand\SetList{m m}{%
+ \seq_clear_new:N #1
+ \seq_set_from_clist:Nn \DisplayModeList {#2}}
+
+ \ProvideExpandableDocumentCommand\TestList{m m m m}{%
+ \seq_if_in:NnTF #1 {#2}{#3}{#4}}
+
\ExplSyntaxOff
\RequirePackage{trace}
@@ -29,14 +38,19 @@
\RequirePackage{wrapfig}
\newdimen\internalmargin
-\internalmargin=\dimexpr\oddsidemargin+1in+1bp\relax
+ \internalmargin=\dimexpr\oddsidemargin+1in+1bp\relax
+\newdimen\externalmargin
+ \externalmargin=\dimexpr\evensidemargin+1in
\newdimen\spreadwidth
-\spreadwidth=\dimexpr 2\textwidth+2\internalmargin\relax
+ \spreadwidth=\dimexpr 2\textwidth+2\internalmargin\relax
\newdimen\DFwidth
\newdimen\DFheight
\newdimen\DFhalfwidth
\newdimen\DFheight
+\newdimen\DFhalfheight
\newdimen\FigSpace
+\def\SWcaptionShift{1em}%
+\def\FScaptionShift{2em}%
\newsavebox\DFtotalimage
\newsavebox\DFimageI
\newsavebox\DFimageII
@@ -51,60 +65,57 @@
\addcontentsline{lof}{figure}{\protect\numberline{\thefigure}#1}
\IfValueT{#3}{\label{#3}}\relax%
}
+\NewDocumentCommand\DFcaptionP{O{#2} m o D!!{black}}%
+ {\refstepcounter{figure}%
+ \vbox to 0pt{\vss\hsize=\textheight\parindent=0pt\leavevmode
+ #4\relax Figure \thefigure\quad #2}%
+ \addcontentsline{lof}{figure}{\protect\numberline{\thefigure}#1}
+ \IfValueT{#3}{\label{#3}}\relax%
+}
+
\newcommand\set@tmode@newpage{%
\ifvmode
\@SWtmodefalse
\else
- \@SWtmodetrue
- \@bsphack\vadjust{\vspace{0pt plus1fill}\@esphack\newpage}%
+ \unskip\@SWtmodetrue\linebreak
+ \vadjust{\vspace{0pt plus1fill}\newpage}%
\fi}
\newcommand\reset@tmode{\if@SWtmode\expandafter\noindent\ignorespaces\fi}
-\NewDocumentCommand\cleartoeven{ o }{%
- \IfValueTF{#1}%
- {\set@tmode@newpage
- \ifodd\value{page}\afterpage{#1}\else#1\fi}%
- {\ifodd\value{page}\null\clearpage\fi}}
+\newcommand\cleartoeven[1]{%
+ \set@tmode@newpage\clearpage
+ \ifodd\c@page\afterpage{#1}\else#1\fi%
+ }
-\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]%
+\NewDocumentEnvironment{DFimage}%
+ {O{SW} m O{#4} m o D(){0.8} D<>{0} D||{0.25} D!!{}}%
+{%
+ \SetList{\DisplayModeList}{SW,HS,VS,FS,NF,RF}%
+ \TestList{\DisplayModeList}{#1}%
+ {\csuse{#1figure}{#2}[#3]{#4}[#5](#6)<#7>|#8|!#9!%
+ \fptest{\CompStrings{\@currenv}{DFimage}}{}{\reset@tmode}%
}%
- {\ifstrequal{#1}{NF}%
- {%
- \NFfigure{#2}[#3]{#4}[#5](#6)%
- }%
- {\ifstrequal{#1}{RF}% OK
- {%
- \RFfigure{#2}[#3]{#4}[#5]%
- }%
- {\ifstrequal{#1}{VS}%
- {%
- \VSfigure{#2}[#3]{#4}[#5](#6)<#7>|#8|%
- }%
- {\ifstrequal{#1}{HS}
- {%
- \HSfigure{#2}[#3]{#4}[#5](#6)%
- }%
- {\PackageWarning{swfigure}%
- {%
- **************************************\MessageBreak
- Option #1\space is not valid \MessageBreak
- Nothing done \MessageBreak
- Image #2\space was not processed \MessageBreak
- **************************************\MessageBreak}%
- }%
- }%
- }%
- }%
+ {%
+ \DFwarning[#1]{#2}[#3]{#4}
}%
}%
+{%
+ \aftergroup\reset@tmode
+}%
+
+\NewDocumentCommand\DFwarning{ o m o m o d() d<> d|| d!!}%
+{\PackageWarning{swfigure}%
+ {********************************************\MessageBreak
+ Option #1\space is not valid. Nothing done \MessageBreak
+ \MessageBreak
+ Image #2 was not processed \MessageBreak
+ *******************************************\MessageBreak
+ }%
+}
-\NewDocumentCommand\SWfigure{m O{#3} m o}{%
+\NewDocumentCommand\SWfigure{m o m o d() d<> d|| d!!}{%
\setbox\DFtotalimage=\hbox{\includegraphics{#1}}%
\DFwidth=\wd\DFtotalimage \DFhalfwidth=0.5\DFwidth
\DFheight=\ht\DFtotalimage
@@ -120,31 +131,31 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
{\edef\DFscalefactor{\fpeval{\FigSpace/\DFhalfwidth}}}%
\setbox\DFimageI=\hbox{\scalebox{\DFscalefactor}{\usebox{\DFimageI}}}%
\setbox\DFimageII=\hbox{\scalebox{\DFscalefactor}{\usebox{\DFimageII}}}%
-\cleartoeven[%
+\cleartoeven{%
\begin{figure}[p]%
- \vbox to\textheight{\vss\hsize=\textwidth%\
+ \vbox to\textheight{\vss\hsize=\textwidth%
\makebox[\hsize][l]{\makebox[\FigSpace][r]{\box\DFimageI}}\vss}%
- \end{figure}\clearpage
+ \end{figure}\newpage
\begin{figure}[p]%
\vbox to\textheight{\vss\hsize=\textwidth
\makebox[\hsize][r]{\makebox[\FigSpace][l]{\box\DFimageII}%
- \makebox(0,0)[lb]{\hspace*{1em}\raisebox{0.5\textheight}{%
+ \makebox(0,0)[lb]{\hspace*{\SWcaptionShift}\raisebox{0.5\textheight}{%
\rotatebox[origin=tc]{90}{\DFcaption[#2]{#3}[#4]%
%
}}}}\vss}%
\end{figure}%
-]\clearpage\reset@tmode}
+}\clearpage\reset@tmode}
-\NewDocumentCommand\NFfigure{m O{#3} m o d()}{%
+\NewDocumentCommand\NFfigure{m o m o d() d<> d|| d!!}{%
\begin{figure}[p]
- \includegraphics[width=\linewidth,height=#5\textheight,
+ \includegraphics[width=\linewidth, height=#5\textheight,
keepaspectratio]{#1}%
\caption[#2]{#3}%
\IfValueT{#4}{\label{#4}}\relax
\end{figure}
}
-\NewDocumentCommand\RFfigure{m O{#3} m o}{%
+\NewDocumentCommand\RFfigure{m o m o d() d<> d|| d!!}{%
\dimen8=\textwidth\dimen10=\textheight
\figure[p]\setbox\RFbox=\hbox{%
\rotatebox[origin=cc]{90}{\parbox[b][\dimen8][c]{\dimen10}%
@@ -160,7 +171,7 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
{\scalebox{\RFy}{\box\RFbox}}%
\endfigure}
-\NewDocumentCommand\VSfigure{m O{#3} m o d() d<> d||}{%
+\NewDocumentCommand\VSfigure{m o m o d() d<> d|| d!!}{%
\setbox\DFtotalimage=\hbox{\includegraphics{#1}}
\DFwidth=\wd\DFtotalimage \DFheight=\ht\DFtotalimage
\edef\VS@aspectratio{\fpeval{\DFheight/\DFwidth}}
@@ -197,16 +208,15 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
\IfValueT{#4}{\label{#4}}\relax}
\VS@lines=
\fpeval{round(\ht\DFtotalimage/\baselineskip,0)+#6}%
- \begin{wrapfigure}[\VS@lines]{O}[0pt]{\VS@width}%
+ \begin{wrapfigure}[\VS@lines]{o}[0pt]{\VS@width}%
\box\DFtotalimage
\end{wrapfigure}%
}%
}%
}%
-\NewDocumentCommand\HSfigure{m o m o d()}{%
- \cleartoeven
- \setbox\DFtotalimage=\hbox{\includegraphics{#1}}
+\NewDocumentCommand\HSfigure{m o m o d() d<> d|| d!!}{%
+ \setbox\DFtotalimage=\hbox{\includegraphics{#1}}%
\DFwidth=\wd\DFtotalimage \DFhalfwidth=0.5\DFwidth
\FigSpace=0.5\spreadwidth%
\setbox\DFimageI\hbox{\bgroup
@@ -214,7 +224,7 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
trim = 0 0 \the\DFhalfwidth\space 0]}\x{#1}}%
\setbox\DFimageII\hbox{\bgroup
\edef\x{\egroup\noexpand\includegraphics*[%
- trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
+ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
\edef\DFscalefactor{\fpeval{\FigSpace/\DFhalfwidth}}%
\setbox\DFimageI=\hbox{%
\scalebox{\DFscalefactor}{\usebox{\DFimageI}}}%
@@ -228,21 +238,80 @@ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
\vtop{\hsize\dimen10\parindent\z@
\textwidth=\hsize
\DFcaption[#2]{#3}[#4]%
- }%
+ }\vspace*{2\baselineskip}%
}%
}%
\setbox\DFimageI=\vbox to\ht\DFimageII{\box\DFimageI\vss}%
- \begin{figure}[t]
- \makebox[\textwidth][l]{%
- \makebox[\DFhalfwidth][l]{\box\DFimageI}}%
- \end{figure}
- \afterpage{%
- \begin{figure}[t]
- \makebox[\textwidth][r]{%
- \makebox[\DFhalfwidth][r]{\box\DFimageII}}%
- \end{figure}%
- }
+ \cleartoeven{%
+ \hb@xt@\textwidth{%
+ \makebox[\DFhalfwidth][l]{\box\DFimageI}\hss}%
+ \afterpage{\hb@xt@\textwidth{%
+ \hss\makebox[\DFhalfwidth][r]{\box\DFimageII}}%
+ }%
+ }%
}
+\NewDocumentCommand\FSfigure{m o m o d() d<> d|| d!!}{%
+ \fptest{\CompStrings{\@currenv}{DFimage}}{}{\bgroup}%
+ \pagestyle{empty}%
+ \setbox\DFtotalimage=\hbox{\includegraphics{#1}}%
+ \DFwidth=\wd\DFtotalimage \DFheight=\ht\DFtotalimage
+ \ifdim \DFheight < \DFwidth
+ \DFhalfwidth=0.5\DFwidth
+ \setbox\DFimageI\hbox{\bgroup
+ \edef\x{\egroup\noexpand\includegraphics*[%
+ trim = 0 0 \the\DFhalfwidth\space 0]}\x{#1}}%
+ \setbox\DFimageII\hbox{\bgroup
+ \edef\x{\egroup\noexpand\includegraphics*[%
+ trim = \the\DFhalfwidth\space 0 0 0]}\x{#1}}%
+ \DFwidth=\DFhalfwidth \DFheight=\ht\DFtotalimage
+ \else
+ \DFhalfheight=0.5\DFheight
+ \setbox\DFimageII\hbox{\bgroup
+ \edef\x{\egroup\noexpand\includegraphics*[%
+ trim = 0 0 0 \the\DFhalfheight\space]}\x{#1}}% bottom half
+ \setbox\DFimageI\hbox{\bgroup
+ \edef\x{\egroup\noexpand\includegraphics*[%
+ trim = 0 \the\DFhalfheight\space 0 0]}\x{#1}}% tophalf
+ \setbox\DFimageI=\hbox{\rotatebox[origin=cc]{90}{\box\DFimageI}}
+ \setbox\DFimageII=\hbox{\rotatebox[origin=cc]{90}{\box\DFimageII}}
+ \DFwidth=\DFhalfheight \DFheight=\wd\DFtotalimage
+ \fi
+\fptest{\DFheight/\DFwidth > \paperheight/\paperwidth}%
+ {\edef\DFscalefactor{\fpeval{\paperheight/\DFheight}}}%
+ {\edef\DFscalefactor{\fpeval{\paperwidth/\DFwidth}}}%
+ \setbox\DFimageI=\hbox{\scalebox{\DFscalefactor}{\usebox{\DFimageI}}}%
+ \setbox\DFimageII=\hbox{\scalebox{\DFscalefactor}{\usebox{\DFimageII}}}%
+\cleartoeven{%
+ \begin{figure}[p]%
+ \vbox to\textheight{\vss\hsize=\textwidth% vbox 1
+ \hbox to\hsize{\hspace*{-\externalmargin}% hbox 1
+ \vbox to\paperheight{\vss% vbox 2
+ \hbox to\paperwidth{\hss\box\DFimageI}% hbox 2 end hbox 2
+ \vss}% end vbox 2
+ \hss}% end hbox 1
+ \vss}% end vbox 1
+ \end{figure}\newpage
+ \begin{figure}[p]%
+ \vbox to\textheight{\vss\hsize=\textwidth% vbox 1
+ \hbox to\hsize{\hspace*{-\internalmargin}% hbox 1
+ \vbox to\paperheight{\vss% vbox 2
+ \hbox to\paperwidth{% hbox 2
+ \box\DFimageII\makebox(0,0)[lb]{% mbox 3
+ \hspace*{-\FScaptionShift}%
+ \raisebox{0.5\textheight}{% raisebox
+ \rotatebox[origin=bc]{90}{% rotatebox
+ \DFcaptionP[#2]{#3}[#4]!#8!%
+ }% end rotatebox
+ }% end raisebox
+ }% end mbox 3
+ }% end hbox 2
+ \vss}% end vbox 2
+ \hss}% end hbox 1
+ \vss}% end vbox 1
+ \end{figure}%
+}\clearpage
+\fptest{\CompStrings{\@currenv}{DFimage}}{}{\egroup}%
+\reset@tmode}
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of