Placing a figure with a command for the file in mkiv
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
Hi all, I have a document (sort of proceedings of a meeting) which have to contain several pages, with each page dedicated to an author and a specific figure (say a photo). In mkii I used to do have a command like \define\authorpicture{hacker.jpg} and then use a command like: \externalfigure[\authorpicture] to include that figure in the text, and everythinng worked ver nicely in my big document. Unfortunately this scheme does not work anymore in mkiv… How can I change the following code (which works in mkii) in order to have it work in mkiv? Thanks in advance for any help: OK %%% begin dynamic-filename-figure.tex \starttext \define\authorpicture{hacker.jpg} \placefigure[here][fig:Myfigure]{} {\externalfigure[\authorpicture]} \stoptext %%% end dynamic-filename-figure.tex
![](https://secure.gravatar.com/avatar/b79687264c3e06cba13b54d05b12a9f5.jpg?s=120&d=mm&r=g)
Otared Kavian mailto:otared@gmail.com 27. Januar 2018 um 11:28 Hi all,
I have a document (sort of proceedings of a meeting) which have to contain several pages, with each page dedicated to an author and a specific figure (say a photo). In mkii I used to do have a command like \define\authorpicture{hacker.jpg} and then use a command like: \externalfigure[\authorpicture] to include that figure in the text, and everythinng worked ver nicely in my big document.
Unfortunately this scheme does not work anymore in mkiv… How can I change the following code (which works in mkii) in order to have it work in mkiv?
Thanks in advance for any help: OK
%%% begin dynamic-filename-figure.tex \starttext \define\authorpicture{hacker.jpg}
\defineexpandable\...{...} Wolfgang
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
On 27 Jan 2018, at 11:43, Wolfgang Schuster
wrote: […] \defineexpandable\...{…}
Hi Wolfgang, Thanks again! Indeed \defineexpandable\authorpicture{hacker.jpg} solves the problem in the simplified case I was reporting. However in the real case, the file « hacker.jpg » is in fact a file which depends on other variables, and when I include \defineexpandable in the \getvariable environment then it does not work anymore: saying \defineexpandable\authorpicture{\getvariable{talk}{picture}} or \defineexpandable\authorpicture{\expanded{\getvariable{talk}{picture}}} or \defineexpandable\authorpicture{\expandafter\getvariable{talk}{picture}} does not solve the problem. Below is a minimal example showing the issue (with what you taught me last week…). Best regards: OK \starttext \startbuffer[pagetalk] \starttabulate[|f{\bi}l|p|][before=]% \NC Speaker \EQ \getvariable{talk}{speakerfirstname} {\sc \getvariable{talk}{speakername}} \NC\NR \NC Title \EQ \getvariable{talk}{title} \NC\NR \stoptabulate \defineexpandable\authorpicture{\getvariable{talk}{picture}} \placefigure[here][]{} {\externalfigure[\authorpicture]} \page \stopbuffer \setvariable{talk}{set}{\getbuffer[pagetalk]} \setvariables[talk]% [speakername={Hacker}, title={Up to date hacking}, picture=hacker.jpg ] \stoptext
![](https://secure.gravatar.com/avatar/b79687264c3e06cba13b54d05b12a9f5.jpg?s=120&d=mm&r=g)
Otared Kavian mailto:otared@gmail.com 27. Januar 2018 um 12:31
Hi Wolfgang,
Thanks again! Indeed
\defineexpandable\authorpicture{hacker.jpg}
solves the problem in the simplified case I was reporting. However in the real case, the file « hacker.jpg » is in fact a file which depends on other variables, and when I include \defineexpandable in the \getvariable environment then it does not work anymore: saying
\defineexpandable\authorpicture{\getvariable{talk}{picture}} or \defineexpandable\authorpicture{\expanded{\getvariable{talk}{picture}}} or \defineexpandable\authorpicture{\expandafter\getvariable{talk}{picture}} does not solve the problem.
Below is a minimal example showing the issue (with what you taught me last week…).
Best regards: OK
\starttext \startbuffer[pagetalk] \starttabulate[|f{\bi}l|p|][before=]% \NC Speaker \EQ \getvariable{talk}{speakerfirstname} {\sc \getvariable{talk}{speakername}} \NC\NR \NC Title \EQ \getvariable{talk}{title} \NC\NR \stoptabulate \defineexpandable\authorpicture{\getvariable{talk}{picture}} \placefigure[here][]{} {\externalfigure[\authorpicture]}
You can put the \getvariable command in \externalfigure. \startplacefigure[location=here] \externalfigure[\getvariable{talk}{picture}] \stopplacefigure
\page \stopbuffer
\setvariable{talk}{set}{\getbuffer[pagetalk]}
\setvariables[talk]% [speakername={Hacker}, title={Up to date hacking}, picture=hacker.jpg ] You’re missing a coma after “picture=hacker.jpg” which results in “jpeg ” (which a space at the end) as file extension for the image.
Wolfgang
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
On 27 Jan 2018, at 12:39, Wolfgang Schuster
wrote: […] […] You’re missing a coma after “picture=hacker.jpg” which results in “jpeg ” (which a space at the end) as file extension for the image.
Yes indeed this was the issue… In fact I had tested « picture={hacker.jpg} » without the comma and that one also did not work, while with a comma as in « picture={hacker.jpg}, » the filename is well understood. Many thanks and best regards: OK
participants (2)
-
Otared Kavian
-
Wolfgang Schuster