Talk:Using Graphics

From ConTeXt wiki
Jump to navigationJump to search

What exactly is the difference with \placefigure[left,none]{}{\externalfigure[cow]} and \starthangaround{\externalfigure[cow]} ... \stophangaround

\starttext
\subject{Flowing text}

Now text with a few figures.  The first figure goes on the right, with
the paragraph flowing around it.

\placefigure[left,none]{}{\externalfigure[cow]}
\input tufte

\starthangaround{\externalfigure[cow]}
\input tufte
\stophangaround

\stoptext

The output of the above shows that both are similar with placefigure having extra White space, but is it semantically different?

Old text

Pictures

This section describes various ways to embed pictures in documents.

In Text

You can directly place a figure in a text using \externalfigure[cow]. If you want to align it not to the baseline, but lower you can try whether \bbox{\externalfigure[cow]} does the right thing, otherwise you have to tweek \smash{\lower24pt\hbox{\externalfigure[cow]}}

Flowing Text

\setuppapersize[A5]
\setupexternalfigures[location={local,default}]
\starthanging{\externalfigure[cow][width=4cm]}
\input tufte
\stophanging

\starthanging is influenced by \setuphanging, but doesn’t take parameters itself. It’s currently broken in MkII (here in the garden), but works with MkIV.

To right-align the image:

\setuppapersize[A5]
\setupexternalfigures[location={local,default}]
\setuphanging[location=right]
\starthanging{\externalfigure[cow][width=4cm]}
    \input tufte
\stophanging

There are more options (distance can even be negative):

\setuppapersize[A5]
\setupexternalfigures[location={local,default}]
\setuphanging[location=right,n=2,distance=1cm]
\starthanging{\externalfigure[cow][width=4cm]}
    \input tufte
\stophanging

Parameter n defines how many lines should flow around, useful for pictures with whitespace below.

This replaces undocumented \starthangaround command that might exist in the source, if the wiki isn’t updated yet.

Also read about Combinations.

Hyperlinks

This example makes a picture interactive; when clicked, it opens a browser to the given URL:

\setupinteraction[state=start]

\starttext
This is a cow: \goto{\externalfigure[cow][height=2ex]}[url(http://en.wikipedia.org/wiki/Cow)]
\stoptext 

Full Page


Enlarged, Shaded Background

To place a figure in the right margin with a shaded background that is slightly larger than the figure (to give a bit of space):

\setupcolors[state=start]
\placefigure[right,high,none]{}{\framed[frame=on, offset=10pt, framecolor=lightgray,
    background=color, backgroundcolor=lightgray]%
  {\externalfigure[sample/cow.pdf][scale=500]}}
\input knuth