On 7-8-2012 14:51, Sietse Brouwer wrote:
Hi Robert, Debugged and all, here you go. Cheers, Sietse
\useexternalfigure[img:fig:cow][cow.pdf] \useexternalfigure[img:fig:mill][mill.png]
\starttext
Actually, this is something that should be doable with user data weren't it that for floats that's not yet available. So I've added it to the core (will be in next upload) ... % macros=mkvi \unprotect % let's pick up two arguments \unexpanded\def\strc_floats_start_place#tag% {\flushnotes \page_otr_command_flush_side_floats % here ! \strc_floats_begin_group \strc_floats_set_current_tag{#tag}% \dodoubleempty\strc_floats_start_place_indeed} % and store the user data for a while \def\strc_floats_start_place_indeed[#settings][#userdata]% {\strc_floats_reset_variables \edef\savedfloatlocation{\floatcaptionparameter\c!location}% \setupcurrentfloatcaption[\c!location=,\c!reference=,\c!title=,\c!marking=,\c!list=,\c!bookmark=,#settings]% \def\savedfloatuserdata{#2}% \edef\floatlocation{\floatcaptionparameter\c!location}% \setupcurrentfloatcaption[\c!location=\savedfloatlocation]% \ifx\floatlocation\empty \edef\floatlocation{\floatparameter\c!default}% \fi \doifinsetelse\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal \bgroup \ignorespaces} % here we need to expand it one level (else detokenize will spoil it) \def\strc_floats_place_packaged_boxes {\expandafter\strc_floats_place_packaged_boxes_indeed\expandafter{\savedfloatuserdata}} \def\strc_floats_place_packaged_boxes_indeed#userdata% {\bgroup \ifconditional\usesamefloatnumber \globallet\currentfloatnumber \previousfloatnumber \globallet\currentfloatattribute \empty \globallet\currentfloatsynchronize\relax \else \ifnofloatnumber \else \ifnofloatcaption \else \strc_counters_increment{\strc_counters_the\currentfloat}% \fi \fi \strc_counters_register_component {float}% \setupcurrentfloatcaption \floatcaptionparameter \detokenizedfloatcaptionparameter \relax \relax \relax [\c!name=\currentfloat,% \s!counter=\strc_counters_the\currentfloat,% \s!hascaption=\ifnofloatcaption \v!no\else\v!yes\fi,% \s!hasnumber=\ifnofloatnumber \v!no\else\v!yes\fi,% \s!hastitle=\ifemptyfloatcaption\v!no\else\v!yes\fi]% [#userdata]% \globallet\previousfloatnumber \m_strc_counters_last_registered_index \globallet\currentfloatnumber \m_strc_counters_last_registered_index \globallet\currentfloatattribute \m_strc_counters_last_registered_attribute \globallet\currentfloatsynchronize\m_strc_counters_last_registered_synchronize \fi % \global\setfalse\usesamefloatnumber % one shot % check float box \strc_floats_set_natural_dimensions\nextbox \global\setbox\floatbox\vbox{\floatparameter\c!command{\box\nextbox}}% \strc_floats_set_natural_dimensions\floatbox \ifdim\htdp\floatbox=\zeropoint \showmessage\m!floatblocks{11}\empty \global\setbox\floatbox\vbox {\dostarttagged\t!floatcontent\empty \strc_floats_place_empty_box \dostoptagged}% \fi % deal with lack of caption \global\setbox\floatbox\vbox \floatcaptionattribute {\doifelsemainfloatbody\currentfloatsynchronize\donothing \unvbox\floatbox \ifnofloatcaption \vss \fi}% gets rid of the depth (unless tabulate) \egroup % place the float \strc_floats_set_box \strc_floats_get_box \global\insidefloatfalse} % we need a raw untagged and expandable fetch: \def\rawstructurelistuservariable#name% {\ctxcommand{listuserdata("\currentlist",\currentlistindex,"#name")}} \protect % so, after some 5 lines patching we can do: \starttext \startplacefigure[reference=fig:mill,title={A Mill}][resource=mill] \externalfigure[mill] \stopplacefigure \startplacefigure[reference=fig:cow,title={A Cow}][resource=cow] \externalfigure[cow] \stopplacefigure \page \unexpanded\def\FigureListEntry#1#2#3% {\dontleavehmode \tbox{\hbox to 2cm{\externalfigure[\rawstructurelistuservariable{resource}][height=1cm]\hss}}% \hbox to 2em{#1\hss}% #2\hfill \hbox to 2em{\hss#3}% \blank} \setuplist[figure][alternative=command,command=\FigureListEntry] \placelist[figure] \stoptext Of course, the 'command' is not that nice looking but that's for others to improve. (In a similar fashion one can associate a resource or whatever to a section head and use it in a toc.) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------