groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Inline Images


From: Ted Harding
Subject: Re: [Groff] Inline Images
Date: Mon, 18 Oct 2010 13:20:39 +0100 (BST)

On 18-Oct-10 11:12:48, Patrik Schindler wrote:
> 
> Am 16.10.2010 um 18:45 schrieb Paul O'Leary McCann:
> 
>> Is there any standard way of putting images inline? Sparklines
>> aren't what I had in mind, but they're an example of the sort
>> of thing I'd like to be able to do.
> 
> Did you take a look at the PIC-Documentation? It's rather versatile!
>:wq! PoC

I think PIC is overkill! (Also, getting it to work for in-line
graphics would take some study).

Below is the macro I referred to previously in connection with
"sparkline" images. It will work just as well for non-sparklines
(also see further comment at end). It is short and sweet!

Fpr more detail, and explanation, se the URL I gave previously:

  http://www.zen89632.zen.co.uk/Misc/do_spark_howto.pdf

Expression deswid and/or deht in "m" units makes the graphic
scale according to the point size of the ambient text.

###############################################################
.de dospark
.psbb \\$1
.nr ht0 \\n[ury]-\\n[lly]
.nr wd0 \\n[urx]-\\n[llx]
.nr deswd (\\n[.ps]/\\n[ht0])*\\n[wd0]
.if \\$2&(\\$2>0) .nr deswd (u; \\$2p)
.nr desht \\n[.ps]
.if \\$3 .nr desht (u; \\$3p)
.nr xht 0
.if (\\n[desht]>\\n[.ps])  .nr xht \\n[desht]-\\n[.ps]
\X'ps: import \\$1 \
\\n[llx] \\n[lly] \\n[urx] \\n[ury] \\n[deswd] \\n[desht]'\
\h'\\n[deswd]u'\x'-\\n[xht]u'
..
###############################################################

Usage:

.dospark EPSfilename [deswid [desht]]

with two optional arguments:

deswid is the desired width of the graphic in points (default)

desht is the desired height of the graphic in points (default)

If given simply as numbers, the size-units are taken to be points.

A groff scaling factor (e.g. "m") can be appended to either.

If desht is missing, then the height of the graphic will be the
current point size (1m in groff units).

If deswid is also missing, then the width of the graphic will be
such as to preserve the aspect-ratio of the original.

If desht is present (to set a custom height), and it is desired
to preserve the aspect ratio, then use 0 for deswid (if desht is
present then deswid must also be present; otherwise desht will
be interpreted as deswid).

When desht is present, and greater than the current point size,
extra vertical space is automatically added above the current line
to make room for the graphic. The graphic's baseline (bottom of
the Bounding Box) will always be aligned with the baseline of
the current text line.

###############################################################

The above was written for the case where an EPS graphic is to
be placed at a particular position in running text (wherever
this may occur on the page. Example:

This is some text into which I will insert the
.dospark myinlinepic.eps 3m 2m
graphic inline, using the .dospark macro.

It would be different if an EPS graphic has to be placed at a
particular position (eg horizontally and vertically centred)
on the page, and the text is to be wrapped round it.

That is not my interpretation of Paul's original query.
However, if that is what you want to so, then the correct
approach is on the lines of

\Z'\h'mmmu'\v'nnnu'\X'ps: import mypic.eps llx lly urx ury deswd desht''

which will place the graphic with its bottom left-hand corner
mmm units ("u"0 to the right of, and nnn units below, the
position on the page at which it is called, with width deswd
units and desht units. The current-point for text insertion
is then returned to the position where it was before the above
is called.

Then you have to work out how you want to get the text to wrap.
You might use traps, or (more likely) simply do it by hand-and-eye!

Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 18-Oct-10                                       Time: 13:20:35
------------------------------ XFMail ------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]