summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/novel/novel-Images.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/novel/novel-Images.sty')
-rw-r--r--Master/texmf-dist/tex/lualatex/novel/novel-Images.sty144
1 files changed, 89 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/lualatex/novel/novel-Images.sty b/Master/texmf-dist/tex/lualatex/novel/novel-Images.sty
index bf74e1c31f1..64bab0fa1ff 100644
--- a/Master/texmf-dist/tex/lualatex/novel/novel-Images.sty
+++ b/Master/texmf-dist/tex/lualatex/novel/novel-Images.sty
@@ -13,7 +13,7 @@
%%
%%
\ProvidesFile{novel-Images.sty}%
-[2017/11/12 v1.43.1 LaTeX file (image placement)]
+[2017/11/17 v1.46 LaTeX file (image placement)]
%%
@@ -72,14 +72,26 @@
\gdef\imagestarred{false}
\gdef\imagefilename{unknown}
% Neutralize \includegraphics, so it is no longer a user command:
-\let\@includegraphics\includegraphics\relax
-\let\includegraphics\relax
+\LetLtxMacro\novel@includegraphics\includegraphics\relax
+\LetLtxMacro\includegraphics\relax
\newcommand\includegraphics[2][]{
\ClassError{novel}{Cannot use \string\includegraphics\space on page \thepage}
{The `novel' class has its own commands for placing images. See docs.^^J%
You cannot use the \string\includegraphics\space command.}%
}
%
+\newcommand\pushtextdown[1]{%
+ \ifthenelse{\equal{#1}{} \OR \equal{#1}{ } \OR \equal{#1}{0}}{%
+ \def\@howmuchdown{0em}%
+ }{%
+ \def\@howmuchdown{#1}%
+ }%
+ ~\par\vspace*{-\nbs}\vspace*{\@howmuchdown}\par%
+}
+%
+\newlength\@mytotalht
+\newif\if@imgExtOK%
+%
% \InlineImage can be used in body, header, footer.
% However, macros such as \imagefilename, \imagewidth, etc.
% are only set or re-set when the image in in the body.
@@ -90,7 +102,7 @@
%
\ExplSyntaxOn
\DeclareDocumentCommand \InlineImage { s O{0pt} m }{%
- \newif\if@imgExtOK%
+ \@imgExtOKfalse%
\IfEndWith{#3}{png}{\@imgExtOKtrue}{}%
\IfEndWith{#3}{PNG}{\@imgExtOKtrue}{}%
\IfEndWith{#3}{jpg}{\@imgExtOKtrue}{}%
@@ -112,7 +124,7 @@
\def\@myily{0pt}}{\def\@myily{\@myilya}%
}%
\iftoggle{@inheadfoot}{}{\gdef\imagefilename{#3}}% for possible later use
- \gdef\my@graphic{\@includegraphics[draft=false]{#3}}%
+ \gdef\my@graphic{\novel@includegraphics[draft=false]{#3}}%
\setlength\@imagewidth{\widthof{\my@graphic}}%
\global\@imagewidth=\@imagewidth%
\iftoggle{@inheadfoot}{}{\setlength\imagewidth{\@imagewidth}}%
@@ -159,8 +171,7 @@
%
%%
-
-
+%% RE-DEFINED in V. 1.46. Now must be placed within linegap environment.
%% \BlockImage[alignment]{image}[text]
% Alignment may have up to 3 comma-separated values. Default is [c]
% First alignment: l, c, r (left, center, right).
@@ -175,14 +186,30 @@
% If image is centered, the text will automatically be centered, so that
% it necessarily overlies the image.
% \forceindent or \backindent may be needed. Text may have several paragraphs.
-% Subsequent text (after all that) will clear the image bottom, and also
-% be at the baseline grid. Beware of using this command near bottom of page.
+% Beware of using this command near bottom of page.
+% Use linegap environment to clear both image and accompanying text.
+% To displace accompanying text, begin it with \vspace*{length}\par.
+% Use adjustwidth environment between linegap and BlockImage centered,
+% if you have accompanying text that you wish to confine in width.
\ExplSyntaxOn
\DeclareDocumentCommand \BlockImage { O{c} m +O{} }{
\iftoggle{@inheadfoot}{%
\ClassError{novel}{Cannot~use~BlockImage~in~header~or~footer}%
{Header~footer~allow~InlineImage~but~not~BlockImage.}%
}{}%
+ \@imgExtOKfalse%
+ \IfEndWith{#2}{png}{\@imgExtOKtrue}{}%
+ \IfEndWith{#2}{PNG}{\@imgExtOKtrue}{}%
+ \IfEndWith{#2}{jpg}{\@imgExtOKtrue}{}%
+ \IfEndWith{#2}{JPG}{\@imgExtOKtrue}{}%
+ \IfEndWith{#2}{jpeg}{\@imgExtOKtrue}{}%
+ \IfEndWith{#2}{JPEG}{\@imgExtOKtrue}{}%
+ \if@imgExtOK\else%
+ \ClassError{novel}{^^JImage~`#2'~format~not~allowed,~page~\thepage}%
+ {^^JImage~`#2'~has~file~type~not~allowed~in~`novel'~class.^^J%
+ Must~have~file~extension~png,~jpg,~jpeg~(or~capitalized).^^J%
+ Others~such~as~pdf~bmp,~tiff,~eps,~pdf,~svg~are~not~allowed.^^J}%
+ \fi%
% Allows empty or blank to be used, and still provide default values:
\ifthenelse{\equal{#1}{} \OR \equal{#1}{\space}}{%
\def\@myargs{c}}{\def\@myargs{#1}%
@@ -196,57 +223,64 @@
\ifthenelse{\equal{\@myyt}{}\OR\equal{\@myyt}{0}}{%
\def\@myy{0pt}}{\def\@myy{\@myyt}%
}
- \newdimen\@sbsheight
+ %
+ \gdef\my@graphic{\novel@includegraphics[draft=false]{#2}}%
+ \setlength\@imagewidth{\widthof{\my@graphic}}%
+ \global\@imagewidth=\@imagewidth%
+ \setlength\@imageheight{\heightof{\my@graphic}}%
+ \global\@imageheight=\@imageheight%
+ \setlength\@imagehoffset{\@myx}%
+ \IfBeginWith{\@myy}{b}{%
+ \ClassError{novel}{Cannot~use~voffset~`b'~in~\stringBlockImage,~page~\thepage}%
+ {The~`b'~voffset~only~works~with~\string\InlineImage\space,~not~\string\BlockImage.}
+ }{%
+ \setlength\@imagevoffset{-\@imageheight}%
+ \addtolength\@imagevoffset{\@myy}%
+ }%
+ %
+ \setlength\@mytotalht{0pt}%
+ \addtolength\@mytotalht{\@imageheight}%
+ \addtolength\@mytotalht{-\@myy}%
+ \addtolength\@mytotalht{1em}%
+ \def\@mytotalhtnum{\strip@pt\@mytotalht}%
+ \FPdiv{\@mytotalhtnum}{\@mytotalhtnum}{\nbsnum}%
+ \FPadd{\@mytotalhtnum}{\@mytotalhtnum}{0.5}%
+ \FPround{\@mytotalhtnum}{\@mytotalhtnum}{0}%
+ %
+ \begin{linegap}{\@mytotalhtnum}%
+ %
\ifthenelse{\equal{\@myalign}{c}\OR\equal{\@myalign}{}}{%
- {\centering\strut\InlineImage*[{\@myx-0.5\imagewidth},{\@myy}]{#2}\par}
- \vspace*{-\nbs}
- {\centering\strut #3\par}
- \setbox0=\vbox{{\centering #3\par}}
- }{}
+ {\centering%
+ \makebox[0pt][l]{%
+ \hspace{\dimexpr\@myx-0.5\@imagewidth}%
+ \stake\smash{\raisebox{\dimexpr\@myy-\@imageheight}{\my@graphic}}%
+ }%
+ \par}%
+ \vspace*{-\nbs}%
+ {\centering #3\par}%
+ }{}%
\ifthenelse{\equal{\@myalign}{r}}{%
- \noindent\InlineImage[{\textwidth-\imagewidth+\@myx},{\@myy}]{#2}\par%
- \vspace{-\nbs}
- \begin{adjustwidth}{0pt}{\imagewidth+\parindent}%
- #3\par%
+ \noindent\makebox[0pt][l]{%
+ \hspace{\dimexpr\textwidth+\@myx-\@imagewidth}%
+ \stake\smash{\raisebox{\dimexpr\@myy-\@imageheight}{\my@graphic}}%
+ }\par%
+ \vspace{-2\nbs}%
+ \begin{adjustwidth}{0pt}{\@imagewidth+\parindent}%
+ \strut\par #3\par%
\end{adjustwidth}%
- \setbox0=\vbox{%
- \begin{adjustwidth}{0pt}{\imagewidth+\parindent}%
- #3\par%
- \end{adjustwidth}%
- }%
- }{}
+ }{}%
\ifthenelse{\equal{\@myalign}{l}}{%
- \noindent\InlineImage*[{\@myx},{\@myy}]{#2}\par%
- \vspace{-\nbs}
- \begin{adjustwidth}{\imagewidth+\parindent}{0pt}%
- #3\par%
+ \noindent\makebox[0pt][l]{%
+ \hspace{\@myx}%
+ \stake\smash{\raisebox{\dimexpr\@myy-\@imageheight}{\my@graphic}}%
+ }\par%
+ \vspace{-2\nbs}%
+ \begin{adjustwidth}{\@imagewidth+\parindent}{0pt}%
+ \strut\par #3\par%
\end{adjustwidth}%
- \setbox0=\vbox{%
- \begin{adjustwidth}{\imagewidth+\parindent}{0pt}%
- #3\par%
- \end{adjustwidth}%
- }%
- }{}
- % portion here, inspired by post from user Killian Foth,
- % at stackoverflow.com, license CC-by-sa-3.0.
- \@sbsheight=\ht0 \advance\@sbsheight by \dp0
- \def\@sbsheightnum{\strip@pt\@sbsheight}
- \FPdiv{\@roughlines}{\@sbsheightnum}{\nbsnum}
- \FPadd{\@roughlines}{\@roughlines}{0.5} % round up, not down
- \FPround{\@roughlines}{\@roughlines}{0}
-
- \gdef\@imageheightnum{\strip@pt\@imageheight}%
- \FPdiv{\@imagelines}{\@imageheightnum}{\nbsnum}%
- \FPadd{\@imagelines}{\@imagelines}{0.5}% round up to integer, not down
- \FPround{\@imagelines}{\@imagelines}{0}%
- \FPclip{\@imagelines}{\@imagelines}%
- \gdef\imagelineskip{\@imagelines}%
- \FPclip{\@roughlines}{\@roughlines}
- \FPadd{\@adjimagelines}{\imagelineskip}{1} % \imagelineskip from \InlineImage*
- \FPsub{\@skipme}{\@adjimagelines}{\@roughlines}
- \FPmax{\@skipme}{\@skipme}{0}
- \vspace{\@skipme\nbs}
-}
+ }{}%
+ \end{linegap}%
+} % end \BlockImage
\ExplSyntaxOff
%%