ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Strange behavior in somewhat complex layout
@ 2019-06-24  4:44 Andres Conrado Montoya
  2019-06-27 17:22 ` Strange behavior in somewhat complex layout (again) Andres Conrado Montoya
  0 siblings, 1 reply; 5+ messages in thread
From: Andres Conrado Montoya @ 2019-06-24  4:44 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 3615 bytes --]

Hello list, I'm trying to make something using bits and examples found here
and elsewhere, but I'm hitting a wall. I know there's a flawed logic in my
approach, but I can't figure it out. Any help is appreciated.

Expected behavior of the following MWE:
When starting a new chapter, check if the page is even (left page), if so,
fill it with color, and start the chapter in the next odd page (right
page), removing the header but leaving the footer in that start-chapter
page; and if this is a start-chapter page, use a specific graphic overlay
for the page, but if if not (if its a regular page), use another graphic.

Result:
The header still appears in the start-chapter page, if it comes after the
color filled page. But, if the start-chapter page comes after a regular
(even) page, everything works as expected (no color-filled page, no header
in the start-chapter page).

MWE:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% START MWE

\definecolor[rojo][h=ED553B]
\definehighlight[rojo][color=rojo]

\startMPinclusions
    numeric u ; u := 1.125pt ;
    numeric i ; i := 0.125in ;
    string prevChapterTitle, currentChapterTitle;
    prevChapterTitle := "";
    currentChapterTitle := "";
\stopMPinclusions

\startuseMPgraphic{page:background}
    StartPage;
        currentChapterTitle := "\namedstructurevariable{chapter}{title}";

        if currentChapterTitle <> prevChapterTitle :

            fill (topboundary Page -- cycle)
            enlarged(0,8i)
            shifted (0,-4i)
            withcolor transparent(4, 0.2, \MPcolor{rojo}) ;

            fill (bottomboundary Page -- cycle)
            enlarged(0,1u)
            shifted (0,6i)
            withcolor \MPcolor{rojo} ;

            prevChapterTitle := currentChapterTitle ;

        else:

            fill (topboundary Page -- cycle)
            enlarged(0,0.25u)
            shifted (0,-7i+3u)
            withcolor \MPcolor{rojo} ;

            fill (bottomboundary Page -- cycle)
            enlarged(0,0.25u)
            shifted (0,6i)
            withcolor \MPcolor{rojo} ;

        fi;
    StopPage;
\stopuseMPgraphic

\defineoverlay
  [chapter:background]
  [\useMPgraphic{page:background}]

\setupbackgrounds[page][background=chapter:background]

\definepagebreak[firstpagebreak][yes,header]

\startsetups [chapter:before]
   \doifoddpageelse
     {}
     {\pushbackground[page]
        \setupbackgrounds[page][background=color,backgroundcolor=rojo]
        \page[yes,right]
      \popbackground}
\stopsetups

\setuphead[chapter]
          [width=20em,
          before=\directsetup{chapter:before},
          align={flushleft,nothyphenated,verytolerant},
          style={\tfd\sansbold},
          header=empty,
          page=yes,
          commandbefore={\blank[1.75in]},
          after={\blackrule[color=rojo,height=4pt,width=6em]\blank[1.25in]}]


\setuppagenumbering[alternative=doublesided,location=]

\setupheadertexts
    []
    [{{\small\sans\getmarking[chapter]}}]
    [{{\small\sans\getmarking[chapter]}}]
    []

\setupfootertexts
    []
    [{\rojo{\small\sansbold\pagenumber}}]
    [{\rojo{\small\sansbold\pagenumber}}]
    []

\starttext

\dorecurse{4}{%
  \startchapter[title={A chapter with a really long, long title}]
  \dorecurse{9}{\input{tufte}}
  \stopchapter
  \startchapter[title={A different chapter with a really long, long title}]
  \dorecurse{6}{\input{tufte}}
  \stopchapter}

\stoptext

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% STOP MWE

Thank you for your time.

Andrés Conrado Montoya

[-- Attachment #1.2: Type: text/html, Size: 4532 bytes --]

[-- Attachment #2: 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

* Strange behavior in somewhat complex layout (again)
  2019-06-24  4:44 Strange behavior in somewhat complex layout Andres Conrado Montoya
@ 2019-06-27 17:22 ` Andres Conrado Montoya
  2019-06-27 18:17   ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Andres Conrado Montoya @ 2019-06-27 17:22 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 3723 bytes --]

Hi List, it seems my message went unnoticed, if you can help me out, please
do. I'm an struggling with this layout.

I'm trying to make something using bits and examples found here and
elsewhere, but I'm hitting a wall. I know there's a flawed logic in my
approach, but I can't figure it out. Any help is appreciated.

Expected behavior of the following MWE:
When starting a new chapter, check if the page is even (left page), if so,
fill it with color, and start the chapter in the next odd page (right
page), removing the header but leaving the footer in that start-chapter
page; and if this is a start-chapter page, use a specific graphic overlay
for the page, but if if not (if its a regular page), use another graphic.

Result:
The header still appears in the start-chapter page, if it comes after the
color filled page. But, if the start-chapter page comes after a regular
(even) page, everything works as expected (no color-filled page, no header
in the start-chapter page).

MWE:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% START MWE

\definecolor[rojo][h=ED553B]
\definehighlight[rojo][color=rojo]

\startMPinclusions
    numeric u ; u := 1.125pt ;
    numeric i ; i := 0.125in ;
    string prevChapterTitle, currentChapterTitle;
    prevChapterTitle := "";
    currentChapterTitle := "";
\stopMPinclusions

\startuseMPgraphic{page:background}
    StartPage;
        currentChapterTitle := "\namedstructurevariable{chapter}{title}";

        if currentChapterTitle <> prevChapterTitle :

            fill (topboundary Page -- cycle)
            enlarged(0,8i)
            shifted (0,-4i)
            withcolor transparent(4, 0.2, \MPcolor{rojo}) ;

            fill (bottomboundary Page -- cycle)
            enlarged(0,1u)
            shifted (0,6i)
            withcolor \MPcolor{rojo} ;

            prevChapterTitle := currentChapterTitle ;

        else:

            fill (topboundary Page -- cycle)
            enlarged(0,0.25u)
            shifted (0,-7i+3u)
            withcolor \MPcolor{rojo} ;

            fill (bottomboundary Page -- cycle)
            enlarged(0,0.25u)
            shifted (0,6i)
            withcolor \MPcolor{rojo} ;

        fi;
    StopPage;
\stopuseMPgraphic

\defineoverlay
  [chapter:background]
  [\useMPgraphic{page:background}]

\setupbackgrounds[page][background=chapter:background]

\definepagebreak[firstpagebreak][yes,header]

\startsetups [chapter:before]
   \doifoddpageelse
     {}
     {\pushbackground[page]
        \setupbackgrounds[page][background=color,backgroundcolor=rojo]
        \page[yes,right]
      \popbackground}
\stopsetups

\setuphead[chapter]
          [width=20em,
          before=\directsetup{chapter:before},
          align={flushleft,nothyphenated,verytolerant},
          style={\tfd\sansbold},
          header=empty,
          page=yes,
          commandbefore={\blank[1.75in]},
          after={\blackrule[color=rojo,height=4pt,width=6em]\blank[1.25in]}]


\setuppagenumbering[alternative=doublesided,location=]

\setupheadertexts
    []
    [{{\small\sans\getmarking[chapter]}}]
    [{{\small\sans\getmarking[chapter]}}]
    []

\setupfootertexts
    []
    [{\rojo{\small\sansbold\pagenumber}}]
    [{\rojo{\small\sansbold\pagenumber}}]
    []

\starttext

\dorecurse{4}{%
  \startchapter[title={A chapter with a really long, long title}]
  \dorecurse{9}{\input{tufte}}
  \stopchapter
  \startchapter[title={A different chapter with a really long, long title}]
  \dorecurse{6}{\input{tufte}}
  \stopchapter}

\stoptext

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% STOP MWE

Thank you for your time.

Andrés Conrado Montoya

[-- Attachment #1.2: Type: text/html, Size: 4724 bytes --]

[-- Attachment #2: 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: Strange behavior in somewhat complex layout (again)
  2019-06-27 17:22 ` Strange behavior in somewhat complex layout (again) Andres Conrado Montoya
@ 2019-06-27 18:17   ` Wolfgang Schuster
  2019-06-27 18:53     ` Andres Conrado Montoya
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2019-06-27 18:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Andres Conrado Montoya


[-- Attachment #1.1: Type: text/plain, Size: 1814 bytes --]

Andres Conrado Montoya schrieb am 27.06.2019 um 19:22:
> Hi List, it seems my message went unnoticed, if you can help me out, 
> please do. I'm an struggling with this layout.
>
> I'm trying to make something using bits and examples found here and 
> elsewhere, but I'm hitting a wall. I know there's a flawed logic in my 
> approach, but I can't figure it out. Any help is appreciated.
>
> Expected behavior of the following MWE:
> When starting a new chapter, check if the page is even (left page), if 
> so, fill it with color, and start the chapter in the next odd page 
> (right page), removing the header but leaving the footer in that 
> start-chapter page; and if this is a start-chapter page, use a 
> specific graphic overlay for the page, but if if not (if its a regular 
> page), use another graphic.
>
> Result:
> The header still appears in the start-chapter page, if it comes after 
> the color filled page. But, if the start-chapter page comes after a 
> regular (even) page, everything works as expected (no color-filled 
> page, no header in the start-chapter page).
>
> MWE:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% START MWE
>
> [...]
>
> \startsetups [chapter:before]
>    \doifoddpageelse
>      {}
>  {\pushbackground[page]
> \setupbackgrounds[page][background=color,backgroundcolor=rojo]
> \page[yes,right]
>       \popbackground}
> \stopsetups
\startsetups [chapter:before]
   \page
   \doifoddpageelse
     {}
     {\pushbackground[page]
        \setupbackgrounds[page][background=color,backgroundcolor=rojo]
        \page[yes,header,footer,right]
      \popbackground}
\stopsetups

> \setuphead[chapter]
>           [width=20em,
> before=\directsetup{chapter:before},
Apply the above setup with

beforesection=\directsetup{chapter:before},

Wolfgang


[-- Attachment #1.2: Type: text/html, Size: 2752 bytes --]

[-- Attachment #2: 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: Strange behavior in somewhat complex layout (again)
  2019-06-27 18:17   ` Wolfgang Schuster
@ 2019-06-27 18:53     ` Andres Conrado Montoya
  2019-06-27 19:17       ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Andres Conrado Montoya @ 2019-06-27 18:53 UTC (permalink / raw)
  To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3264 bytes --]

Wolfgang... Thank you, man. Thank you so very much. This works perfectly.

As I understand it from your correction, my mistake was that I was not
doing the page break before everything else, as I should, because in any
case there will always be a page break in my layout. Then, let the rest of
the algorithm decide if there will be a left or right page, headers and
footers, etc. Am I correct?

Thank you again for your work.

Andrés Conrado Montoya
Andi Kú
andresconrado@gmail.com
http://sesentaycuatro.com
http://messier87.com
http://chiquitico.org
----------------------------------------
Los fines no justifican los medios, porque la medida verdadera de nuestro
carácter está dada por los medios que estamos dispuestos a utilizar, no por
los fines que proclamamos.
----------------------------------------

“You develop an instant global consciousness, a people orientation, an
intense dissatisfaction with the state of the world, and a compulsion to do
something about it. From out there on the moon, international politics look
so petty. You want to grab a politician by the scruff of the neck and drag
him a quarter of a million miles out and say, ‘Look at that, you son of a
bitch.’” — Apollo 14 astronaut Edgar Mitchell


El jue., 27 jun. 2019 a las 13:17, Wolfgang Schuster (<
wolfgang.schuster.lists@gmail.com>) escribió:

> Andres Conrado Montoya schrieb am 27.06.2019 um 19:22:
>
> Hi List, it seems my message went unnoticed, if you can help me out,
> please do. I'm an struggling with this layout.
>
> I'm trying to make something using bits and examples found here and
> elsewhere, but I'm hitting a wall. I know there's a flawed logic in my
> approach, but I can't figure it out. Any help is appreciated.
>
> Expected behavior of the following MWE:
> When starting a new chapter, check if the page is even (left page), if so,
> fill it with color, and start the chapter in the next odd page (right
> page), removing the header but leaving the footer in that start-chapter
> page; and if this is a start-chapter page, use a specific graphic overlay
> for the page, but if if not (if its a regular page), use another graphic.
>
> Result:
> The header still appears in the start-chapter page, if it comes after the
> color filled page. But, if the start-chapter page comes after a regular
> (even) page, everything works as expected (no color-filled page, no header
> in the start-chapter page).
>
> MWE:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% START MWE
>
> [...]
>
> \startsetups [chapter:before]
>    \doifoddpageelse
>      {}
>      {\pushbackground[page]
>         \setupbackgrounds[page][background=color,backgroundcolor=rojo]
>         \page[yes,right]
>       \popbackground}
> \stopsetups
>
> \startsetups [chapter:before]
>   \page
>   \doifoddpageelse
>     {}
>     {\pushbackground[page]
>        \setupbackgrounds[page][background=color,backgroundcolor=rojo]
>        \page[yes,header,footer,right]
>      \popbackground}
> \stopsetups
>
> \setuphead[chapter]
>           [width=20em,
>           before=\directsetup{chapter:before},
>
> Apply the above setup with
>
> beforesection=\directsetup{chapter:before},
>
> Wolfgang
>
>

[-- Attachment #1.2: Type: text/html, Size: 4688 bytes --]

[-- Attachment #2: 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: Strange behavior in somewhat complex layout (again)
  2019-06-27 18:53     ` Andres Conrado Montoya
@ 2019-06-27 19:17       ` Wolfgang Schuster
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2019-06-27 19:17 UTC (permalink / raw)
  To: Andres Conrado Montoya; +Cc: mailing list for ConTeXt users

Andres Conrado Montoya schrieb am 27.06.2019 um 20:53:
> Wolfgang... Thank you, man. Thank you so very much. This works perfectly.
>
> As I understand it from your correction, my mistake was that I was not 
> doing the page break before everything else, as I should, because in 
> any case there will always be a page break in my layout. Then, let the 
> rest of the algorithm decide if there will be a left or right page, 
> headers and footers, etc. Am I correct?
Yes, it's important to do the page check before the section is inserted.

When you use the before key you perform the check after \startchapter 
finished the previous page and removed the header line, when you insert 
now the colored page the header setting is used for this page and one 
the following page with the section title you get the unwanted header text.

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

end of thread, other threads:[~2019-06-27 19:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24  4:44 Strange behavior in somewhat complex layout Andres Conrado Montoya
2019-06-27 17:22 ` Strange behavior in somewhat complex layout (again) Andres Conrado Montoya
2019-06-27 18:17   ` Wolfgang Schuster
2019-06-27 18:53     ` Andres Conrado Montoya
2019-06-27 19:17       ` Wolfgang Schuster

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