ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Vertically centered text in each page
@ 2016-02-19 10:54 Nicola
  2016-02-19 11:23 ` Marco Patzer
  0 siblings, 1 reply; 7+ messages in thread
From: Nicola @ 2016-02-19 10:54 UTC (permalink / raw)
  To: ntg-context

Inspired by Aditya's "make a presentation in 40 commits" example,
I have defined my own environment for slides. A part of it looks
like this:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\startreusableMPgraphic{header:background}
  fill OverlayBox
    leftenlarged BackSpace
    rightenlarged CutSpace
    topenlarged TopSpace
    withcolor OverlayColor ;
  setbounds currentpicture to OverlayBox
    enlarged max(BackSpace,CutSpace) ;
\stopreusableMPgraphic

\defineoverlay[header:background][\reuseMPgraphic{header:background}]

\define[2]\MySlide{\framed[
  frame=off,
  background=header:background,
  backgroundcolor=orange,
  width=\textwidth,
  align=flushleft
]{#2}}

\definehead[slide][subject]
\setuphead[slide][
  style=\ssb,
  command=\MySlide,
  color=white,
  page=yes,
]

\starttext
\startslide[title={Slide One}]
\vfill
text
\vfill
\stopslide

\startslide[title={Slide Two}]
\vfill
text
\vfill
\stopslide
\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

As you see, I am using \vfill to have the text vertically centered.
How do I setup the slide command to do that by default? I have tried
putting {before,after,beforesection,aftersection}=\vfill in various
combinations in \setuphead, but I cannot obtain the desired effect.

Related to the code above, I have another question: if I remove the
comma after page=yes, slides are not split into different pages. Is
it normal that a comma is required at the end of an argument list?

Nicola


___________________________________________________________________________________
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] 7+ messages in thread

* Re: Vertically centered text in each page
  2016-02-19 10:54 Vertically centered text in each page Nicola
@ 2016-02-19 11:23 ` Marco Patzer
  2016-02-19 11:51   ` Nicola
  2016-03-02  9:04   ` Andreas Schneider
  0 siblings, 2 replies; 7+ messages in thread
From: Marco Patzer @ 2016-02-19 11:23 UTC (permalink / raw)
  To: ntg-context

On Fri, 19 Feb 2016 11:54:12 +0100
Nicola <nvitacolonna@gmail.com> wrote:

> How do I setup the slide command to do that by default? I have tried
> putting {before,after,beforesection,aftersection}=\vfill in various
> combinations in \setuphead, but I cannot obtain the desired effect.

\setuphead[slide][
  style=\ssb,
  command=\MySlide,
  color=white,
  insidesection=\vfill,
  aftersection=\vfill,
  page=yes]

> if I remove the comma after page=yes, slides are not split into
> different pages. Is it normal that a comma is required at the end
> of an argument list?

The missing comma is not the issue, it's the space. Works:

\setuphead[slide]
  [page=yes,
  ]

\setuphead[slide]
  [page=yes%%
  ]

\setuphead[slide]
  [page=yes%%
  ]

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] 7+ messages in thread

* Re: Vertically centered text in each page
  2016-02-19 11:23 ` Marco Patzer
@ 2016-02-19 11:51   ` Nicola
  2016-02-19 12:36     ` Marco Patzer
  2016-03-02  9:04   ` Andreas Schneider
  1 sibling, 1 reply; 7+ messages in thread
From: Nicola @ 2016-02-19 11:51 UTC (permalink / raw)
  To: ntg-context

On 2016-02-19 11:23:18 +0000, Marco Patzer said:

> On Fri, 19 Feb 2016 11:54:12 +0100
> Nicola <nvitacolonna@gmail.com> wrote:
> 
>> How do I setup the slide command to do that by default? I have tried
>> putting {before,after,beforesection,aftersection}=\vfill in various
>> combinations in \setuphead, but I cannot obtain the desired effect.
> 
> \setuphead[slide][
>   style=\ssb,
>   command=\MySlide,
>   color=white,
>   insidesection=\vfill,
>   aftersection=\vfill,
>   page=yes]

insidesection, of course! Thanks, that does it.

I have noticed that in a few circumstances vertical alignment is not
desired. How do I override the default settings on a per-slide basis?
Something like:

\startslide[title={...},insidesection=,aftersection=]

(which does not work).


>> if I remove the comma after page=yes, slides are not split into
>> different pages. Is it normal that a comma is required at the end
>> of an argument list?
> 
> The missing comma is not the issue, it's the space.

Ah, right. For other commands space is not a problem. Go figure.

Nicola


___________________________________________________________________________________
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] 7+ messages in thread

* Re: Vertically centered text in each page
  2016-02-19 11:51   ` Nicola
@ 2016-02-19 12:36     ` Marco Patzer
  2016-02-19 14:17       ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Patzer @ 2016-02-19 12:36 UTC (permalink / raw)
  To: ntg-context

On Fri, 19 Feb 2016 12:51:14 +0100
Nicola <nvitacolonna@gmail.com> wrote:

> On 2016-02-19 11:23:18 +0000, Marco Patzer said:
> 
> > On Fri, 19 Feb 2016 11:54:12 +0100
> > Nicola <nvitacolonna@gmail.com> wrote:
> >   
> >> How do I setup the slide command to do that by default? I have
> >> tried putting {before,after,beforesection,aftersection}=\vfill in
> >> various combinations in \setuphead, but I cannot obtain the
> >> desired effect.  
> > 
> > \setuphead[slide][
> >   style=\ssb,
> >   command=\MySlide,
> >   color=white,
> >   insidesection=\vfill,
> >   aftersection=\vfill,
> >   page=yes]  
> 
> insidesection, of course! Thanks, that does it.
> 
> I have noticed that in a few circumstances vertical alignment is not
> desired. How do I override the default settings on a per-slide basis?
> Something like:
> 
> \startslide[title={...},insidesection=,aftersection=]
> 
> (which does not work).

No clue why that doesn't work. Wait for others to chime in.

Here's a workaround, though:

\unprotect
\setuphead [slide]
  [insidesection=\doifnot{\structureuservariable\c!align}\c!top\vfill,
   aftersection=\doifnot{\structureuservariable\c!align}\c!top\vfill]
\protect

Then you can use:

\startslide [title={Slide Two}] [align=top]
  text
\stopslide

But probably there's a better way.

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] 7+ messages in thread

* Re: Vertically centered text in each page
  2016-02-19 12:36     ` Marco Patzer
@ 2016-02-19 14:17       ` Hans Hagen
  2016-02-19 17:55         ` Nicola
  0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2016-02-19 14:17 UTC (permalink / raw)
  To: ntg-context

On 2/19/2016 1:36 PM, Marco Patzer wrote:
> On Fri, 19 Feb 2016 12:51:14 +0100
> Nicola <nvitacolonna@gmail.com> wrote:
>
>> On 2016-02-19 11:23:18 +0000, Marco Patzer said:
>>
>>> On Fri, 19 Feb 2016 11:54:12 +0100
>>> Nicola <nvitacolonna@gmail.com> wrote:
>>>
>>>> How do I setup the slide command to do that by default? I have
>>>> tried putting {before,after,beforesection,aftersection}=\vfill in
>>>> various combinations in \setuphead, but I cannot obtain the
>>>> desired effect.
>>>
>>> \setuphead[slide][
>>>    style=\ssb,
>>>    command=\MySlide,
>>>    color=white,
>>>    insidesection=\vfill,
>>>    aftersection=\vfill,
>>>    page=yes]
>>
>> insidesection, of course! Thanks, that does it.
>>
>> I have noticed that in a few circumstances vertical alignment is not
>> desired. How do I override the default settings on a per-slide basis?
>> Something like:
>>
>> \startslide[title={...},insidesection=,aftersection=]
>>
>> (which does not work).
>
> No clue why that doesn't work. Wait for others to chime in.
>
> Here's a workaround, though:
>
> \unprotect
> \setuphead [slide]
>    [insidesection=\doifnot{\structureuservariable\c!align}\c!top\vfill,
>     aftersection=\doifnot{\structureuservariable\c!align}\c!top\vfill]
> \protect

no need for unprotect is you use

\doifnot{\structureuservariable{align}}{top}\vfill

> Then you can use:
>
> \startslide [title={Slide Two}] [align=top]
>    text
> \stopslide
>
> But probably there's a better way.
>
> 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
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | 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] 7+ messages in thread

* Re: Vertically centered text in each page
  2016-02-19 14:17       ` Hans Hagen
@ 2016-02-19 17:55         ` Nicola
  0 siblings, 0 replies; 7+ messages in thread
From: Nicola @ 2016-02-19 17:55 UTC (permalink / raw)
  To: ntg-context

On 2016-02-19 14:17:02 +0000, Hans Hagen said:

> On 2/19/2016 1:36 PM, Marco Patzer wrote:
>> On Fri, 19 Feb 2016 12:51:14 +0100
>> Nicola <nvitacolonna@gmail.com> wrote:
>> 
>>> On 2016-02-19 11:23:18 +0000, Marco Patzer said:
>>> 
>>>> On Fri, 19 Feb 2016 11:54:12 +0100
>>>> Nicola <nvitacolonna@gmail.com> wrote:
>>>> 
>>>>> How do I setup the slide command to do that by default? I have
>>>>> tried putting {before,after,beforesection,aftersection}=\vfill in
>>>>> various combinations in \setuphead, but I cannot obtain the
>>>>> desired effect.
>>>> 
>>>> \setuphead[slide][
>>>> style=\ssb,
>>>> command=\MySlide,
>>>> color=white,
>>>> insidesection=\vfill,
>>>> aftersection=\vfill,
>>>> page=yes]
>>> 
>>> insidesection, of course! Thanks, that does it.
>>> 
>>> I have noticed that in a few circumstances vertical alignment is not
>>> desired. How do I override the default settings on a per-slide basis?
>>> Something like:
>>> 
>>> \startslide[title={...},insidesection=,aftersection=]
>>> 
>>> (which does not work).
>> 
>> No clue why that doesn't work. Wait for others to chime in.
>> 
>> Here's a workaround, though:
>> 
>> \unprotect
>> \setuphead [slide]
>> [insidesection=\doifnot{\structureuservariable\c!align}\c!top\vfill,
>> aftersection=\doifnot{\structureuservariable\c!align}\c!top\vfill]
>> \protect
> 
> no need for unprotect is you use
> 
> \doifnot{\structureuservariable{align}}{top}\vfill

Marco, Hans,
thanks! It works like a charm.

Nicola


___________________________________________________________________________________
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] 7+ messages in thread

* Re: Vertically centered text in each page
  2016-02-19 11:23 ` Marco Patzer
  2016-02-19 11:51   ` Nicola
@ 2016-03-02  9:04   ` Andreas Schneider
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Schneider @ 2016-03-02  9:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

Am 2016-02-19 12:23, schrieb Marco Patzer:
> On Fri, 19 Feb 2016 11:54:12 +0100
> Nicola <nvitacolonna@gmail.com> wrote:
> 
>> How do I setup the slide command to do that by default? I have tried
>> putting {before,after,beforesection,aftersection}=\vfill in various
>> combinations in \setuphead, but I cannot obtain the desired effect.
> 
> \setuphead[slide][
>   style=\ssb,
>   command=\MySlide,
>   color=white,
>   insidesection=\vfill,
>   aftersection=\vfill,
>   page=yes]

I'm in a similar situation currently, but can't quite get it to work 
with the mentioned solution.
The attached example shows several problems.

Test 1 and Test 3 show, that the \vfill at the beginning apparently adds 
a forced space (which is worse in Test 3 than in Test 1).

Another problem is, that when the page needs to break (which is fine), 
the last page will not be centered. This is a logic consequence of the 
\vfill being after the section.

Is there any other mechanism to center text on _all_ pages, no matter 
how often the sections or paragraphs need to get broken?

Best regards
Andreas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: chapterlayer.tex --]
[-- Type: text/x-tex; name=chapterlayer.tex, Size: 1066 bytes --]

\setuppapersize[S8]

\setupbodyfont[24pt]
\setupinterlinespace[height=0.8]

\setuppagenumbering[location=]

\definelayer
  [header]
  [width=\paperwidth, height=\paperheight]

\define[2]\setheader{%
  \resetlayer[header]%
  \setlayer[header]%
    [preset=lefttop, x=10mm, y=5mm, width=15cm, heigth=40pt]%
    {#2}%
}
\define[2]\setsubtitle{%
  \setlayer[header]%
    [preset=lefttop, x=10mm, y=\dimexpr(5mm+40pt), width=15cm, heigth=22pt]%
    {#2}%
}

\setuphead[chapter][command=\setheader, page=yes, before={\setupbackgrounds[page][background={header}, state=repeat]}, after={\strut\blank[-2*line,samepage,disable]}, insidesection=\vfill, aftersection=\vfill]
\setuphead[section][command=\setsubtitle, after={\strut\blank[-2*line,samepage,disable]}, before=]

%\showboxes
\showframe

\starttext

\startchapter[title={Test 1}]

\input knuth
\input knuth

\stopchapter

\startchapter[title={Test 2}]

No page-breaks here.

\stopchapter

\startchapter[title={Test 3}]

\startsection[title={Subtitle}]

\input knuth
\input knuth

\stopsection

\stopchapter

\stoptext

[-- Attachment #3: 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] 7+ messages in thread

end of thread, other threads:[~2016-03-02  9:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19 10:54 Vertically centered text in each page Nicola
2016-02-19 11:23 ` Marco Patzer
2016-02-19 11:51   ` Nicola
2016-02-19 12:36     ` Marco Patzer
2016-02-19 14:17       ` Hans Hagen
2016-02-19 17:55         ` Nicola
2016-03-02  9:04   ` Andreas Schneider

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