From a2397d8719898ee84e458ea2714716d345c64663 Mon Sep 17 00:00:00 2001 From: Karl Berry 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.dtx | 159 ++++++++++++++++++--- 1 file changed, 139 insertions(+), 20 deletions(-) (limited to 'Master/texmf-dist/source/latex/combinedgraphics') diff --git a/Master/texmf-dist/source/latex/combinedgraphics/combinedgraphics.dtx b/Master/texmf-dist/source/latex/combinedgraphics/combinedgraphics.dtx index 436925c88fa..1ebb72a6859 100644 --- a/Master/texmf-dist/source/latex/combinedgraphics/combinedgraphics.dtx +++ b/Master/texmf-dist/source/latex/combinedgraphics/combinedgraphics.dtx @@ -3,7 +3,7 @@ % % DocStrip file for combinedgraphics package % -% Copyright 2009,2011 Christian Schneider +% Copyright 2009,2011,2012 Christian Schneider % % cgr@addto@macro: identical to l@addto@macro from koma-script % bundle v2.9t @@ -34,7 +34,7 @@ % \iffalse %\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] %<*driver> \documentclass[a4paper]{ltxdoc} \usepackage{combinedgraphics} @@ -70,10 +70,15 @@ % \changes{v0.1.0-alpha}{2011/06/12}{added options for changing the inclusion % order of \LaTeX{} and vector graphics parts} % \changes{v0.1.1-alpha}{2011/06/15}{fix in Makefiles of package} +% \changes{v0.2.0}{2012/01/04}{added options for scaling vector graphics +% part to a certain width or height, respectively, plus removed ``alpha'' +% from version} +% \changes{v0.2.1}{2012/01/07}{simplified a macro} +% \changes{v0.2.2}{2012/07/12}{added comments to test file} % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% \CheckSum{574} +% \CheckSum{704} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -104,16 +109,11 @@ % % \title{The \textsf{combinedgraphics} package\thanks{This document corresponds % to \textsf{combinedgraphics}~\fileversion, dated~\filedate. Copyright -% 2009,2011 Christian Schneider \texttt{}.}} +% 2009,2011,2012 Christian Schneider \texttt{}.}} % \author{Christian Schneider\\ \texttt{}} % % \maketitle % -% \begin{center} -% \large\textbf{\textsf{Warning: This is alpha software and may -% contain serious bugs! Use with caution and on your own risk! Check output!}} -% \end{center} -% % \tableofcontents % \clearpage % @@ -137,7 +137,16 @@ % hidden under shaded areas) % \item rescaling and rotating of complete graphics (similar to % |\includegraphics| from \textsf{graphicx} package) +% \item scaling the vector graphics part (without affecting the font) to +% a defined width or height of the graphics, which might, e.g., be of +% importance for graphics that are intended for publication in a journal +% requesting a certain size of graphics % \end{itemize} +% +% A test PDF file with extensively commented examples is shipped with this +% package and a BASH script (\texttt{texpic2epspdf.sh}) to convert combined +% EPS/\LaTeX{} and PDF/\LaTeX{} graphics to EPS or PDF files with text part +% included. % \end{abstract} % % \section{The Combined EPS/\LaTeX{} format} @@ -211,6 +220,19 @@ % package option) % \item[\texttt{vecscale}=\meta{value}] scaling factor for rescaling the % graphics without affecting the font of the \LaTeX{} part +% (Note that this will overwrite |vecwidth| or |vecheight|, if they are +% specified before.) +% \item[\texttt{vecwidth}=\meta{value}] analogous to |vecscale|, but +% the scaling factor will be calculated such that the new width of the +% total graphics will be \meta{value}; the aspect ratio will be preserved +% (Note that this will overwrite |vecscale| or |vecheight|, if they are +% specified before.) +% \item[\texttt{vecheight}=\meta{value}] analogous to |vecscale|, but +% the scaling factor will be calculated such that the new (total) height of +% the total graphics will be \meta{value}; the aspect ratio will be +% preserved +% (Note that this will overwrite |vecscale| or |vecwidth|, if they are +% specified before.) % \item[\texttt{vecinclude}=\meta{value}] generate code to include the vector % graphics part; \meta{value}s are: |auto| to automatically determine if % code is required (default), |true|/|false| to always/never generate @@ -227,7 +249,8 @@ % % Note: If the vector graphics part is already included by the \LaTeX{} part, % |vecinclude| and |vecscale| will require the vector graphics part to be -% included by an |\includegraphics| command for proper functioning. Furthermore, +% included by an |\includegraphics| command for proper functioning. Other +% graphics inclusion macros will not be detected. Furthermore, % |vecscale| also requires that the \LaTeX{} part puts its text inside a % |picture| environment whose scaling is set with % |\setlength{\unitlength}|\marg{some length}. These two prerequisites are @@ -304,6 +327,12 @@ % \item[\texttt{textcolorcmd}=\meta{value}] name of a command (\emph{without} % leading backslash) for recoloring text in \LaTeX{} part % \item[\texttt{vecscale}=\meta{value}] see section~\ref{sec:basic} +% \item[\texttt{vecwidth}=\meta{value}] see section~\ref{sec:basic}; in +% contrast to the macro options, you must not use a length as \meta{value} +% here (workaround: use |\the\somelength|) +% \item[\texttt{vecheight}=\meta{value}] see section~\ref{sec:basic}; in +% contrast to the macro options, you must not use a length as \meta{value} +% here (workaround: use |\the\somelength|) % \item[\texttt{vecinclude}=\meta{value}] see section~\ref{sec:basic} % \item[\texttt{vecfirst}=\meta{value}] see section~\ref{sec:basic} % \end{mydescription} @@ -312,8 +341,7 @@ % % Please report bugs and problems or send suggestions for this package to % Christian Schneider. Check for updates before reporting bugs at the website -% mentioned above. Do \emph{not} bother Markus Kohm or Frank Neukam with bugs, -% problems or suggestions concerning this package! +% mentioned above. % % \StopEventually{\PrintChanges\PrintIndex} % @@ -331,9 +359,11 @@ % % \subsection{Package options} % -% This |if| is required to remember the inclusion order. +% This |if| is required to remember the inclusion order. The macro specifies +% the package option from |vecscale|, |vecwidth|, |vecheight| used last. % \begin{macrocode} \newif\ifcgr@vecfirst +\def\cgr@vecscale@type{0} % \end{macrocode} % % Definitions of package options as \meta{key}|=|\meta{value} pairs. The @@ -343,7 +373,12 @@ \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}} % \end{macrocode} @@ -412,6 +447,23 @@ } % \end{macrocode} % +% |vecwidth| and |vecheight|, respectively, calculate the scaling factor for +% |vecscale| such that the width or (total) height of the vector graphics part +% equals the specified \meta{dimen}. |\vecscale| is set to |-1| to indicate +% that the factor shall be calculated. +% \begin{macrocode} +\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}% +} +% \end{macrocode} +% % |vecinclude| switches between the different \meta{value}s by setting % |\cgr@vecinclude| to one of the for macros % |\cgr@requires@graphics|\meta{value}. @@ -585,6 +637,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{} @@ -652,12 +705,31 @@ }% % \end{macrocode} % +% Afterwards, a macro containing the name of the \LaTeX{} and vector graphics +% part, respectively, is initialized. +% \begin{macrocode} + \def\cgr@vecfile{#2}% + \def\cgr@texfile{#2}% +% \end{macrocode} +% % If set, the package options will be processed. (Suggestions for easier % handling of package options are welcome.) % \begin{macrocode} - \@ifundefined{cgr@vecscale@default}{}{% - \cgr@setopts@combgrphcs{vecscale=\cgr@vecscale@default}% - }% + \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}% }% @@ -672,10 +744,8 @@ }% % \end{macrocode} % -% Afterwards, the macro containing the name of the vector graphics part is -% initialized and the options passed the the macro are processed. +% Now, the options passed the the macro are processed. % \begin{macrocode} - \def\cgr@vecfile{#2}% \cgr@setopts@combgrphcs{#1}% % \end{macrocode} % @@ -850,6 +920,55 @@ } % \end{macrocode} % +% The way of calculating the scaling factor for |vecwidth| and |vecheight| is +% a simplified and adapted version of |\ratio| from the |calc.sty| package. +% First, the width or (total) height of the original graphics part is measured. +% In order to do this, the graphics are put into a box. +% Afterwards, the places before the decimal point are calculated by \TeX{}'s +% built-in integer division. Finally, the decimal places are calculated with +% an algorithm as division has been taught at school. +% \begin{macrocode} +\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}% +} +% \end{macrocode} +% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \Finale -- cgit v1.2.3