I'm trying to implement a macro which is a wrapper over the graphicx \includegraphics
command (because I'd like to pass the parameters for cropping in a key-value fashion). While doing so, at first I introduced a key to set the width
(option of includegraphics
). Later on I needed the same macro where I set the scale
and height
option.
Now I have three macros doing basically the same which I'd like to merge into one. I saw there is the .is choice
key which I tried using, but there I fail to additionally pass a value and later on passing the key-value pair to graphicx. But see my try:
\documentclass{article}
\usepackage{pgfkeys}
\usepackage{graphicx}
% \pgfkeys{
% /testing/.cd,
% scaling/.is choice,
% scaling/width/.code=\def\testing{width=#1},
% scaling/height/.code=\def\testing{height=#1},
% scaling/scale/.code=\def\testing{scale=#1},
% }
\pgfkeys{
/graphicx/.cd,
left/.initial=0cm, left/.default=0cm,
% left/.store in=\owngraphicx@left,
right/.initial=0cm, right/.default=0cm,
top/.initial=0cm, top/.default=0cm,
bottom/.initial=0cm, bottom/.default=0cm,
page/.initial={1}, page/.default={1},
width/.initial=\linewidth, width/.default=\linewidth,
}
\newcommand{\slidesS}[2][]{%
\pgfkeys{/graphicx/.cd,left,right,top,bottom,page,#1}%
\fbox{%
\includegraphics[%
page=\pgfkeysvalueof{/graphicx/page},%
scale=\pgfkeysvalueof{/graphicx/width},%
clip,%
trim=\pgfkeysvalueof{/graphicx/left} \pgfkeysvalueof{/graphicx/bottom} \pgfkeysvalueof{/graphicx/right} \pgfkeysvalueof{/graphicx/top},%
]{#2}%
}%
}
\newcommand{\slidesW}[2][]{%
\pgfkeys{/graphicx/.cd,left,right,top,bottom,page,#1}%
\fbox{%
\includegraphics[%
page=\pgfkeysvalueof{/graphicx/page},%
width=\pgfkeysvalueof{/graphicx/width},%
clip,%
trim=\pgfkeysvalueof{/graphicx/left} \pgfkeysvalueof{/graphicx/bottom} \pgfkeysvalueof{/graphicx/right} \pgfkeysvalueof{/graphicx/top},%
]{#2}%
}%
}
\newcommand{\slidesH}[2][]{%
\pgfkeys{/graphicx/.cd,left,right,top,bottom,page,#1}%
\fbox{%
\includegraphics[%
page=\pgfkeysvalueof{/graphicx/page},%
height=\pgfkeysvalueof{/graphicx/width},%
clip,%
trim=\pgfkeysvalueof{/graphicx/left} \pgfkeysvalueof{/graphicx/bottom} \pgfkeysvalueof{/graphicx/right} \pgfkeysvalueof{/graphicx/top},%
]{#2}%
}%
}
\newcommand{\inputFile}{image.png}
\begin{document}
% \pgfkeys{
% /testing/.cd,
% scaling={height=10cm},
% }
\slidesS[left=1.8982075471698134cm, right=10cm, bottom=1cm, top=5.75cm, width=1]{\inputFile}
% \includegraphics[\testing]{\inputPdfFile}
\end{document}
the commented things are me trying to capture key+value of the is choice
.
Any ideas on how to properly do this (using \testing
in \includegraphics
does not work, since width=10cm
is perceived as an option, not as key=value I think)