For years I've used a LaTeX macro that allowed me to embed figures into my text with relatively little fuss. I could type something like:
A typological comparison (see Figure \Fig[Caption text]{file.png}) suggests that...
The output would render the figure number in situ and place the actual image somewhere nearby, depending on its size and available page space.
I have been trying to create something similar in ConTeXt, but so far no luck. I assume I should be able to do this with some combination of \placefigure and \in. This command...
\def\Fig[#1]#2{%
%\startpostponing[+0]%
\startplacefigure[reference=fig:#2,title=#1]%
%\dontleavehmode%
\externalfigure[#2]%
\stopplacefigure%
%\stoppostponing%
\in{Figure}[fig:#2]%
}
...is close, but it forces a linebreak that disrupts the paragraph.
I've tried using \dontleavehmode, as per the suggestion in the FAQ, but that doesn't fix the problem. I've also tried wrapping the placefigure command in postpoining[+0] tags, as advised in this question, but that causes the parser to abort and wait for input. ConTeXt doesn't tell me why it aborts, but I would guess that it's not able to resolve the \in command when the figure placement is postponed.
Any suggestions?
location=here
. (The parser aborting is due to catcodes, I'll post an answer later).