From a2397d8719898ee84e458ea2714716d345c64663 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 27 Jul 2012 18:22:41 +0000
Subject: combinedgraphics (16jul12)

git-svn-id: svn://tug.org/texlive/trunk@27198 c570f23f-e606-0410-a88d-b1316a301751
---
 .../latex/combinedgraphics/combinedgraphics.sty    | 81 ++++++++++++++++++++--
 1 file changed, 75 insertions(+), 6 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/combinedgraphics/combinedgraphics.sty')

diff --git a/Master/texmf-dist/tex/latex/combinedgraphics/combinedgraphics.sty b/Master/texmf-dist/tex/latex/combinedgraphics/combinedgraphics.sty
index ae2ec9a83b5..383fd7d3267 100644
--- a/Master/texmf-dist/tex/latex/combinedgraphics/combinedgraphics.sty
+++ b/Master/texmf-dist/tex/latex/combinedgraphics/combinedgraphics.sty
@@ -35,16 +35,22 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{combinedgraphics}
-  [2011/06/15 v0.1.1-alpha inclusion of combined EPS/LaTeX graphics]
+  [2012/07/13 v0.2.2 inclusion of combined EPS/LaTeX graphics]
 \RequirePackage{keyval}
 \RequirePackage{graphicx}
 \RequirePackage{color}
 \newif\ifcgr@vecfirst
+\def\cgr@vecscale@type{0}
 \newcommand*\cgr@defopts{\define@key{cgr}}
 \newcommand*\cgr@setopts{\setkeys{cgr}}
 \cgr@defopts{textfontcmd}{\gdef\cgr@textfont@default{\@nameuse{#1}}}
 \cgr@defopts{textcolorcmd}{\gdef\cgr@textcolor@default{\@nameuse{#1}}}
-\cgr@defopts{vecscale}{\gdef\cgr@vecscale@default{#1}}
+\cgr@defopts{vecscale}{\gdef\cgr@vecscale@default{#1}%
+  \gdef\cgr@vecscale@type{0}}
+\cgr@defopts{vecwidth}{\gdef\cgr@vecwidth@default{#1}%
+  \gdef\cgr@vecscale@type{1}}
+\cgr@defopts{vecheight}{\gdef\cgr@vecheight@default{#1}%
+  \gdef\cgr@vecscale@type{2}}
 \cgr@defopts{vecinclude}{\gdef\cgr@vecinclude@default{#1}}
 \cgr@defopts{vecfirst}{\gdef\cgr@vecfirst@default{#1}}
 \DeclareOption*{%
@@ -81,6 +87,16 @@
   \def\setlength{\cgr@setlength}%
   \def\includegraphics{\cgr@includegraphics}%
 }
+\cgr@defopts@combgrphcs{vecwidth}{%
+  \cgr@vecscale@wd{\cgr@texfile}{\cgr@vecfile}{#1}%
+  \def\setlength{\cgr@setlength}%
+  \def\includegraphics{\cgr@includegraphics}%
+}
+\cgr@defopts@combgrphcs{vecheight}{%
+  \cgr@vecscale@ht{\cgr@texfile}{\cgr@vecfile}{#1}%
+  \def\setlength{\cgr@setlength}%
+  \def\includegraphics{\cgr@includegraphics}%
+}
 \cgr@defopts@combgrphcs{vecinclude}{%
   \def\cgr@vecinclude{\@nameuse{cgr@requires@graphics#1}}%
 }
@@ -213,6 +229,7 @@
 \def\cgr@vecscale{1}
 \def\cgr@vecinclude{\cgr@requires@graphicsauto}
 \cgr@vecfirsttrue
+\def\cgr@texfile{}
 \def\cgr@vecfile{}
 \def\cgr@curr@hscale{}
 \def\cgr@curr@vscale{}
@@ -250,9 +267,23 @@
       %% inclusion of \LaTeX{} part
       \input{#2}%
     }%
-    \@ifundefined{cgr@vecscale@default}{}{%
-      \cgr@setopts@combgrphcs{vecscale=\cgr@vecscale@default}%
-    }%
+    \def\cgr@vecfile{#2}%
+    \def\cgr@texfile{#2}%
+    \if0\cgr@vecscale@type%
+      \@ifundefined{cgr@vecscale@default}{}{%
+        \cgr@setopts@combgrphcs{vecscale=\cgr@vecscale@default}%
+      }%
+    \fi%
+    \if1\cgr@vecscale@type%
+      \@ifundefined{cgr@vecwidth@default}{}{%
+        \cgr@setopts@combgrphcs{vecwidth=\cgr@vecwidth@default}%
+      }%
+    \fi%
+    \if2\cgr@vecscale@type%
+      \@ifundefined{cgr@vecheight@default}{}{%
+        \cgr@setopts@combgrphcs{vecheight=\cgr@vecheight@default}%
+      }%
+    \fi%
     \@ifundefined{cgr@textfont@default}{}{%
       \cgr@setopts@combgrphcs{textfont=\cgr@textfont@default}%
     }%
@@ -265,7 +296,6 @@
     \@ifundefined{cgr@vecfirst@default}{}{%
       \cgr@setopts@combgrphcs{vecfirst=\cgr@vecfirst@default}%
     }%
-    \def\cgr@vecfile{#2}%
     \cgr@setopts@combgrphcs{#1}%
     \cgr@curr@pic%
   \endgroup%
@@ -387,6 +417,45 @@
     \fi%
   \@tempa%
 }
+\newcount\cgr@tempdigit
+\newcommand*\cgr@vecscale@wd[3]{%
+  \cgr@vecscale@graphicsbox{#1}{#2}%
+  \cgr@vecscale@calc{\wd\@tempboxa}{#3}%
+}
+\newcommand*\cgr@vecscale@ht[3]{%
+  \cgr@vecscale@graphicsbox{#1}{#2}%
+  \@tempdimc=\ht\@tempboxa%
+  \advance\@tempdimc by\dp\@tempboxa%
+  \cgr@vecscale@calc{\@tempdimc}{#3}%
+}
+\newcommand*\cgr@vecscale@graphicsbox[2]{%
+  \setbox\@tempboxa\hbox{%
+    \begingroup%
+      \def\setlength{\cgr@setlength@orig}%
+      \def\includegraphics{\cgr@gobble@optone}%
+      \input{#1}%
+    \endgroup%
+  }%
+}
+\newcommand*\cgr@vecscale@calc[2]{%
+  \@tempdimb=#1%
+  \@tempcntb=\@tempdimb%
+  \@tempdima=#2%
+  \@tempcnta=\@tempdima%
+  \cgr@tempdigit=\@tempcnta%
+  \divide\cgr@tempdigit by\@tempcntb%
+  \edef\cgr@vecscale{\the\cgr@tempdigit.}%
+  \cgr@next@digit\cgr@next@digit\cgr@next@digit%
+  \cgr@next@digit\cgr@next@digit\cgr@next@digit%
+}
+\newcommand*\cgr@next@digit{%
+  \multiply\cgr@tempdigit by\@tempcntb%
+  \advance\@tempcnta by-\cgr@tempdigit%
+  \multiply\@tempcnta by10%
+  \cgr@tempdigit=\@tempcnta%
+  \divide\cgr@tempdigit by\@tempcntb%
+  \edef\cgr@vecscale{\cgr@vecscale\the\cgr@tempdigit}%
+}
 \endinput
 %%
 %% End of file `combinedgraphics.sty'.
-- 
cgit v1.2.3

