Difference between revisions of "Talk:Using Graphics"

From Wiki
Jump to navigation Jump to search
m
Line 19: Line 19:
  
 
The output of the above shows that both are similar with placefigure having extra White space, but is it semantically different?
 
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 <tt>\externalfigure[cow]</tt>. If you want to align it not to the baseline, but lower you can try whether <tt>\bbox{\externalfigure[cow]}</tt> does the right thing, otherwise you have to tweek <tt>\smash{\lower24pt\hbox{\externalfigure[cow]}}</tt>
 +
 +
== Flowing Text ==
 +
 +
<context source=yes mode=mkiv>
 +
\setuppapersize[A5]
 +
\setupexternalfigures[location={local,default}]
 +
\starthanging{\externalfigure[cow][width=4cm]}
 +
\input tufte
 +
\stophanging
 +
</context>
 +
 +
{{cmd|starthanging}} is influenced by {{cmd|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:
 +
 +
<texcode>
 +
\setuppapersize[A5]
 +
\setupexternalfigures[location={local,default}]
 +
\setuphanging[location=right]
 +
\starthanging{\externalfigure[cow][width=4cm]}
 +
    \input tufte
 +
\stophanging
 +
</texcode>
 +
 +
There are more options (distance can even be negative):
 +
 +
<texcode>
 +
\setuppapersize[A5]
 +
\setupexternalfigures[location={local,default}]
 +
\setuphanging[location=right,n=2,distance=1cm]
 +
\starthanging{\externalfigure[cow][width=4cm]}
 +
    \input tufte
 +
\stophanging
 +
</texcode>
 +
 +
Parameter <tt>n</tt> defines how many lines should flow around, useful for pictures with whitespace below.
 +
 +
This replaces undocumented {{cmd|starthangaround}} command that might exist [http://source.contextgarden.net/tex/context/base/cont-new.mkiv?search=hangaround 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:
 +
 +
<texcode>
 +
\setupinteraction[state=start]
 +
 +
\starttext
 +
This is a cow: \goto{\externalfigure[cow][height=2ex]}[url(http://en.wikipedia.org/wiki/Cow)]
 +
\stoptext
 +
</texcode>
 +
 +
== Full Page ==
 +
 +
* See [[Simple Cover 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):
 +
 +
<texcode>
 +
\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
 +
</texcode>

Revision as of 21:36, 14 May 2015

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