Dear Peter, Thank you for your eloborate answer. I will look into it and give a heads up when I got it working.
Regards! Hans Peter Schaffter <pe...@schaffter.ca> wrote: > Hans -- > > > What would be the best approach to create a macro which inserts a > > image inline? > > I field this question a lot from mom users. Here's the solution I > suggest. It's mom-specific but should help. Basically, you > create a diversion to hold the graphic, map the diversion to a > character with .char, then create a string that outputs the graphic > "character" with vertical and horizontal adjustments derived from > the depth and width of the graphic. > > .\" Begin inline-graphic template > . > .TITLE "Inline graphic example > .PRINTSTYLE TYPESET > .\" PDFIMAGEs are collected for inclusion in the List of Figures, > .\" which we don't want for inline graphics. The internal macro > .\" that handles collection is PDF_TARGET. > . > .\" Rename PDF_TARGET to something else. > .rn PDF_TARGET PDF_TARGET_OLD > . > .\" Re-define PDF_TARGET to execute the original only if the > .\" no-target flag hasn't been set. > .de PDF_TARGET > . if !\\n[no-target] .PDF_TARGET_OLD > .. > . > .\" Step 1: Create a diversion to hold the graphic. > .di graphic:1 > . nr width:1 20p \" image width, needed for string 'graphic:1' > . nr depth:1 24p \" image depth, needed for string 'graphic:1' > . nr no-target 1 > . PDF_IMAGE -L penguin-small.pdf \n[width:1]u \n[depth:1]u > . rr no-target > .di > . > .\" Step 2: Map the diversion to a character. > .char \[graphic:1] \*[graphic:1] > . > .\" Step 3: Define a string incorporating the vertical > .\" raise amount and width of the graphic. > .ds graphic:1 \v'-\n[depth:1]u'\[graphic:1]\h'\n[width:1]u' > . > .START > .PP > Lorem ipsum \*[graphic:1] dolor sit amet. > . > .\" End inline-graphic template > > I'm attaching a pdf of the template. > > -- > Peter Schaffter > https://www.schaffter.ca