ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Automatic margin floats using the criterium parameter
@ 2012-09-05  7:43 Marco Patzer
  2012-09-05  9:22 ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Patzer @ 2012-09-05  7:43 UTC (permalink / raw)
  To: context

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]

Hi,

I am working on some float placement code for a project. To
not reinvent the wheel I like to know what is currently possible in
ConTeXt.

Small floats should be placed in the margin and bigger ones centred
in the text. Captions always go into the margin. That is the idea.
The key to automate this seems to be the \setupfloat[criterium=…]
parameter. Details:

1) Captions always in the margin
2) Captions left aligned
3) Figures smaller or equal \marginwidth go into the outer margin
4) Margin figures are aligned to the inner side of the margin
5) Margin figure captions underneath the figure
6) Figures wider than the margin go centred into the text
7) Text figure captions top aligned

I got almost everything working. A minimal example is attached.

Problems:

Mf 1-2 are placed correctly. Problematic are Mf 3-4. The caption is
not placed in the margin because of the

\setupcaptions
  [mf]
  [location=bottom]

setting for margin figures. Another thing is the weird alignment of
Mf 3-4, I expect the figures to be centred. The reason is the
following setting.

\setupfloat
  [mf]
  [location=inner]

If uncommented, the alignment of the margin figures is wrong. Figure
1-2 are examples of how it should look like.

I could come up with a hackish solution on my own but maybe someone
has an idea how to achieve this with built-in support.


Marco

[-- Attachment #2: floatmargin.pdf --]
[-- Type: application/pdf, Size: 13134 bytes --]

[-- Attachment #3: floatmargin.tex --]
[-- Type: text/x-tex, Size: 903 bytes --]

\setupexternalfigures
  [height=2cm]

\setupblackrules
  [height=2cm]

\def\graph
  {\blackrule}

\setuplayout
  [width=9cm,
   margin=4cm]

\setupcaptions
  [location={outermargin, high},
   width=\marginwidth]

\setupcaptions
  [mf]
  [location=bottom,
   width=\marginwidth]

\definefloat
  [mf]
  [mfs]

\setupfloat
  [mf]
  [criterium=\rightmarginwidth,
   location=inner,
   default=margin]

\starttext
\showframe

\input knuth

\startplacefigure [title=Figure description] \graph[width=3cm] \stopplacefigure
\startplacefigure [title=Figure description] \graph[width=5cm] \stopplacefigure

\startplacemf [title=Short]              \graph[width=2cm]   \stopplacemf
\startplacemf [title=Figure description] \graph[width=4cm]   \stopplacemf
\startplacemf [title=Figure description] \graph[width=4.2cm] \stopplacemf
\startplacemf [title=Figure description] \graph[width=8cm]   \stopplacemf

\stoptext

[-- Attachment #4: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Automatic margin floats using the criterium parameter
  2012-09-05  7:43 Automatic margin floats using the criterium parameter Marco Patzer
@ 2012-09-05  9:22 ` Hans Hagen
  2012-09-05 10:02   ` Marco Patzer
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2012-09-05  9:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 5-9-2012 09:43, Marco Patzer wrote:
> Hi,
>
> I am working on some float placement code for a project. To
> not reinvent the wheel I like to know what is currently possible in
> ConTeXt.

fyi: As I often need conditional placement in projects (mostly width 
related), it's likely that there will be a pluggable system some day 
(some snippets are in place but not a coherent framework). It's somewhat 
complicated by the fact that one has to decide what to do with delayed 
placement.  No time now, so it will happen next year or so.

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Automatic margin floats using the criterium parameter
  2012-09-05  9:22 ` Hans Hagen
@ 2012-09-05 10:02   ` Marco Patzer
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Patzer @ 2012-09-05 10:02 UTC (permalink / raw)
  To: context

On 2012-09-05 Hans Hagen <pragma@wxs.nl> wrote:

Hi Hans,

> > I am working on some float placement code for a project. To
> > not reinvent the wheel I like to know what is currently possible in
> > ConTeXt.
> 
> fyi: As I often need conditional placement in projects (mostly width 
> related), it's likely that there will be a pluggable system some day 

I already consider the entire float mechanism very flexible and
feature rich.

> It's somewhat complicated by the fact that one has to decide what
> to do with delayed placement.

I'm quite happy with the placement in general. The exact problem
here is that if the \setupfloat[criterium=…] value is exceeded, it
seems that ConTeXt adjusts the values “location” and “default” to
place the float in the text. A solution would be to be able to state
a fallback float class in case criterium is exceeded. Idea:

\definefloat
  [marginfigure]
  [marginfigures]

\definefloat
  [marginfigurefallback]
  [marginfiguresfallbacks]
  [marginfigure]

\setupfloat
  [marginfigure]
  [criterium=\marginwidth,
   criteriumfallback=marginfigurefallback]

This way full control is being maintained, since the float and
caption style of the fallback class can be individually adjusted.


Marco

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-05 10:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-05  7:43 Automatic margin floats using the criterium parameter Marco Patzer
2012-09-05  9:22 ` Hans Hagen
2012-09-05 10:02   ` Marco Patzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).