-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbkindle_graphics.sty
33 lines (28 loc) · 954 Bytes
/
dbkindle_graphics.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
\usepackage{wrapfig}
\setlength{\intextsep}{0.25\baselineskip}
\newlength{\saveimagewidth}
\newsavebox{\saveimagebox}
\newcounter{figurecounter}
% Enclose the image in either wrapfigure of figure environment depending on its (rescaled) width
% The first parameter is treshold - multiple of textwith, the second parameter is image file name
\newcommand{\wrapifneeded}[2]{%
\savebox{\saveimagebox}{\includegraphics[width=\imgwidth,height=\imgheight,keepaspectratio=true]{#2}}
\settowidth{\saveimagewidth}{\usebox{\saveimagebox}}
\ifdim\saveimagewidth<#1\textwidth
\ifthenelse{\isodd{\value{figurecounter}}}{
\begin{wrapfigure}{R}{\saveimagewidth}
\usebox{\saveimagebox}
\end{wrapfigure}
}{
\begin{wrapfigure}{L}{\saveimagewidth}
\usebox{\saveimagebox}
\end{wrapfigure}
}
\else
\begin{figure}[!htbp] %
\centering %
\usebox{\saveimagebox}
\end{figure}
\fi
\stepcounter{figurecounter}
}