ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Moving horizontally a whole ensemble of layers in the same run?
@ 2019-12-18 14:13 Rudolf Bahr
  2019-12-18 17:13 ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Rudolf Bahr @ 2019-12-18 14:13 UTC (permalink / raw)
  To: ntg-context

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


On Tue, Dec 17, 2019 at 07:30:49PM +0100, Hans Hagen wrote:

> you need to make a MWE to show what you mean
> 
> normally
> 
> \hbox to <somewidth>{\hss<come content>\hss}
> 
> is good enough for centering

Here is my MWE. Think of a photo album. To make it interesting the pages should
all be different. To this purpose layers are a good means. I'd like to centre
the layers on their page without doing so manually and without changig the distances
between them. Using luacode one can calculate the distance d between the leftmost
and the rightmost edge. Half the difference (\textwidth - d) is the amount to move
the whole layer ensemble.

My question is now: Does in context exist a possibility to move all layers jointly
without correcting all their x-values subsequently?
I append the pdf-file of my MWE.

Rudolf

---------------------------------------------------------- MWE ---------------------

\setuppapersize[A4,landscape]
\setupexternalfigures[location={default}]

\starttext

\definelayer[LAY]%

\setlayer[LAY][x=0pt,y=-8pt]%
   {%
   \vbox
	{%
	\hsize=.35\textwidth
	\externalfigure[cow][width=\hsize]%

        \vskip\lineheight

	\input tufte
	}
   }

\setlayer[LAY][x=210pt,y=0pt]%
   {%
   \definedfont[Serif at 82pt]
   \rotate[rotation=90,frame=on,offset=2pt]{\hbox{JOURNEY}}
   }

\setlayer[LAY][x=360pt,y=50pt]%
   {%
   \vbox
	{%
        \hsize=200pt
        \input ward
        \vskip\lineheight
	\externalfigure[hacker][height=.4\textheight]%
	}
   }

\flushlayer[LAY]
\page

\definelayer[LAY]%

\setlayer[LAY][x=0pt,y=0pt]%
   {\externalfigure[mill][height=.4\textheight]}

\setlayer[LAY][x=150pt,y=0pt]%
   {\externalfigure[hacker][height=.4\textheight]}

\setlayer[LAY][x=0pt,y=200pt]%
   {\externalfigure[cow][width=.5\textwidth]}

\setlayer[LAY][x=\dimexpr.65\textwidth+40pt\relax,y=0pt]%
   {%
   \vbox
	{%
        \hsize=.2\textwidth
        \startalignment[flushleft]
        \input ward
        \vskip\lineheight
        \input ward
        \stopalignment
	}
   }

\flushlayer[LAY]

\stoptext

------------------------------------------------------------------------------------

[-- Attachment #2: mwe-komprimiert.pdf --]
[-- Type: application/pdf, Size: 65668 bytes --]

[-- Attachment #3: Type: text/plain, Size: 493 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Moving horizontally a whole ensemble of layers in the same run?
  2019-12-18 14:13 Moving horizontally a whole ensemble of layers in the same run? Rudolf Bahr
@ 2019-12-18 17:13 ` Wolfgang Schuster
  2019-12-18 18:46   ` Rudolf Bahr
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2019-12-18 17:13 UTC (permalink / raw)
  To: ntg-context, Rudolf Bahr

Rudolf Bahr schrieb am 18.12.2019 um 15:13:
> On Tue, Dec 17, 2019 at 07:30:49PM +0100, Hans Hagen wrote:
>
>> you need to make a MWE to show what you mean
>>
>> normally
>>
>> \hbox to <somewidth>{\hss<come content>\hss}
>>
>> is good enough for centering
> Here is my MWE. Think of a photo album. To make it interesting the pages should
> all be different. To this purpose layers are a good means. I'd like to centre
> the layers on their page without doing so manually and without changig the distances
> between them. Using luacode one can calculate the distance d between the leftmost
> and the rightmost edge. Half the difference (\textwidth - d) is the amount to move
> the whole layer ensemble.
>
> My question is now: Does in context exist a possibility to move all layers jointly
> without correcting all their x-values subsequently?

1. You can use hoffset and voffset to shift all layers.

2. You can use \setlayerframed to put paragraphs in a layer.


\setuppapersize[A4,landscape]

\setupexternalfigures[location=default]

\definelayer[LAY]

\starttext

\startbuffer

\setlayerframed
   [LAY]
   [x=0pt,
    y=-8pt]
   [frame=off,
    width=.35\textwidth,
    align={normal,tolerant}]
   {\externalfigure[cow][width=\hsize]
    \blank[line]
    \input tufte\par}

\setlayerframed
   [LAY]
   [x=225pt,
    y=0pt]
   [orientation=90,
    foregroundstyle={\definedfont[Serif at 82pt]}]
   {JOURNEY}

\setlayerframed
   [LAY]
   [x=360pt,
    y=50pt]
   [frame=off,
    width=200pt,
    align={normal,tolerant}]
   {\input ward
    \blank[line]
    \externalfigure[hacker][height=.4\textheight]}

\flushlayer[LAY]

\stopbuffer

\getbuffer

\page

\setuplayer[LAY][hoffset=4cm,voffset=-2cm]

\getbuffer

\stoptext

Wolfgang

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Moving horizontally a whole ensemble of layers in the same run?
  2019-12-18 17:13 ` Wolfgang Schuster
@ 2019-12-18 18:46   ` Rudolf Bahr
  0 siblings, 0 replies; 5+ messages in thread
From: Rudolf Bahr @ 2019-12-18 18:46 UTC (permalink / raw)
  To: ntg-context

On Wed, Dec 18, 2019 at 06:13:51PM +0100, Wolfgang Schuster wrote:
> Rudolf Bahr schrieb am 18.12.2019 um 15:13:
> > On Tue, Dec 17, 2019 at 07:30:49PM +0100, Hans Hagen wrote:
> > 
> > > you need to make a MWE to show what you mean
> > > 
> > > normally
> > > 
> > > \hbox to <somewidth>{\hss<come content>\hss}
> > > 
> > > is good enough for centering
> > Here is my MWE. Think of a photo album. To make it interesting the pages should
> > all be different. To this purpose layers are a good means. I'd like to centre
> > the layers on their page without doing so manually and without changig the distances
> > between them. Using luacode one can calculate the distance d between the leftmost
> > and the rightmost edge. Half the difference (\textwidth - d) is the amount to move
> > the whole layer ensemble.
> > 
> > My question is now: Does in context exist a possibility to move all layers jointly
> > without correcting all their x-values subsequently?
> 
> 1. You can use hoffset and voffset to shift all layers.
> 
> 2. You can use \setlayerframed to put paragraphs in a layer.
> 
> 
> \setuppapersize[A4,landscape]
> 
> \setupexternalfigures[location=default]
> 
> \definelayer[LAY]
> 
> \starttext
> 
> \startbuffer
> 
> \setlayerframed
>   [LAY]
>   [x=0pt,
>    y=-8pt]
>   [frame=off,
>    width=.35\textwidth,
>    align={normal,tolerant}]
>   {\externalfigure[cow][width=\hsize]
>    \blank[line]
>    \input tufte\par}
> 
> \setlayerframed
>   [LAY]
>   [x=225pt,
>    y=0pt]
>   [orientation=90,
>    foregroundstyle={\definedfont[Serif at 82pt]}]
>   {JOURNEY}
> 
> \setlayerframed
>   [LAY]
>   [x=360pt,
>    y=50pt]
>   [frame=off,
>    width=200pt,
>    align={normal,tolerant}]
>   {\input ward
>    \blank[line]
>    \externalfigure[hacker][height=.4\textheight]}
> 
> \flushlayer[LAY]
> 
> \stopbuffer
> 
> \getbuffer
> 
> \page
> 
> \setuplayer[LAY][hoffset=4cm,voffset=-2cm]
> 
> \getbuffer
> 
> \stoptext
> 
> Wolfgang
> 

Thank you very much, Wolfgang! That is exactly what I need
and what I was looking for! Very nice coding indeed!

Rudolf
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Moving horizontally a whole ensemble of layers in the same run?
  2019-12-17 18:18 Rudolf Bahr
@ 2019-12-17 18:30 ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2019-12-17 18:30 UTC (permalink / raw)
  To: ntg-context, Rudolf Bahr

On 12/17/2019 7:18 PM, Rudolf Bahr wrote:
> 
> Hi Hans,
> 
> assume we fixed between "\definelayer" and "\flushlayer" a whole ensemble
> of layers on a page. And by calculating per luacode we determined the leftmost
> and the rightmost edge of the ensemble and would now like to horizontally centre
> the ensemble. We don't know the rightmost edge before we placed the last layer.
> By luacode we can calculate how much the centring movement should be, because we
> know "\textwidth", but we cannot save the calculated centring value in the context
> program for another run. Saving the luacode values of hundred of pages in flattened
> lua tables would be possible, but rather awkward; the problem of relating pages to
> tables would arise, especially when pages are taken out or additional pages are
> inserted.
> 
> Do you know a way to settle the centring in the same context run in which the layers
> are placed? Could "\flushlayer" perform it somehow?
you need to make a MWE to show what you mean

normally

\hbox to <somewidth>{\hss<come content>\hss}

is good enough for centering

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Moving horizontally a whole ensemble of layers in the same run?
@ 2019-12-17 18:18 Rudolf Bahr
  2019-12-17 18:30 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Rudolf Bahr @ 2019-12-17 18:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Hi Hans,

assume we fixed between "\definelayer" and "\flushlayer" a whole ensemble
of layers on a page. And by calculating per luacode we determined the leftmost
and the rightmost edge of the ensemble and would now like to horizontally centre
the ensemble. We don't know the rightmost edge before we placed the last layer.
By luacode we can calculate how much the centring movement should be, because we
know "\textwidth", but we cannot save the calculated centring value in the context
program for another run. Saving the luacode values of hundred of pages in flattened
lua tables would be possible, but rather awkward; the problem of relating pages to
tables would arise, especially when pages are taken out or additional pages are
inserted.

Do you know a way to settle the centring in the same context run in which the layers
are placed? Could "\flushlayer" perform it somehow?

Rudolf
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2019-12-18 18:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 14:13 Moving horizontally a whole ensemble of layers in the same run? Rudolf Bahr
2019-12-18 17:13 ` Wolfgang Schuster
2019-12-18 18:46   ` Rudolf Bahr
  -- strict thread matches above, loose matches on Subject: below --
2019-12-17 18:18 Rudolf Bahr
2019-12-17 18:30 ` Hans Hagen

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).