I'm working on a macro to help me inserting figures into my document with configurable placement. I'm using the pgfkeys package for parsing key=value parameters passed to that macro, one of them being the placement parameter:
\documentclass{article}
\usepackage{float}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{pgfkeys}
\pgfkeys{
/fig/.is family, /fig,
default/.style = {
pos =,
},
pos/.estore in = \figPos,
}
\newcommand\mymacro[2][]{
\pgfkeys{/fig, default, #1}
{\em Placement parameter is: \figPos}
\begin{figure}[\figPos]
\includegraphics{#2}
\end{figure}
}
\begin{document}
\section{Working as expected}
\lipsum[1]
\begin{figure}[t]
\includegraphics{image.jpg}
\end{figure}%
\lipsum[2]
\lipsum[3]
\section{Not working as expected}
\lipsum[1]
\mymacro[pos=t]{image.jpg}
\lipsum[2]
\lipsum[3]
\end{document}
When using the figure environment directly, the image gets positioned as expected, i.e. at the top of the page. However, when using the macro, the image gets included somewhere near the end of the document instead of close to its definition -- as though I had supplied an invalid placement parameter.
Any ideas and/or workarounds?
[]is given to the env. What memoir is doing is providing a user interface to set that default value. – daleif May 04 '17 at 20:33\def\fps@figure{t}– samcarter_is_at_topanswers.xyz May 04 '17 at 20:35pgfkeyspackage for parsingkey=valueparameters passed to that macro, one of them being the placement paramater:\mymacro[pos=t,foo=bar]{mumbo}{jumbo}. The\figPosmacro created bypgfkeyswhile parsing#1gets ignored just as described above. – Torsten Crass May 04 '17 at 20:39