
Hello, How can I clip long markings in the header? See this MNWE, where the two copies of section title collide on page 3. --------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------ How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles? Is it possible to provide an alternative shorter section title within \section? Thanks, Mohammad

Untested but this should work:
\section{This title is long \nomarking{enough to cause problems in the
headers and footers}}
Everything inside \nomarking{} will not be shown in the headers or footers.
See https://wiki.contextgarden.net/Command/nomarking
Duncan
On Fri, 14 Mar 2025 at 14:33, Mohammad Hossein Bateni
Hello,
How can I clip long markings in the header?
See this MNWE, where the two copies of section title collide on page 3.
--------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------
How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles?
Is it possible to provide an alternative shorter section title within \section?
Thanks, Mohammad
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

I get an undefined command error. Does it work on your machine?
On Fri, Mar 14, 2025 at 10:43 AM Duncan Hothersall
Untested but this should work:
\section{This title is long \nomarking{enough to cause problems in the headers and footers}}
Everything inside \nomarking{} will not be shown in the headers or footers.
See https://wiki.contextgarden.net/Command/nomarking
Duncan
On Fri, 14 Mar 2025 at 14:33, Mohammad Hossein Bateni
wrote: Hello,
How can I clip long markings in the header?
See this MNWE, where the two copies of section title collide on page 3.
--------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------
How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles?
Is it possible to provide an alternative shorter section title within \section?
Thanks, Mohammad
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

On 2025-03-14 11:05, Mohammad Hossein Bateni wrote:
I get an undefined command error. Does it work on your machine?
On Fri, Mar 14, 2025 at 10:43 AM Duncan Hothersall
wrote: Untested but this should work:
\section{This title is long \nomarking{enough to cause problems in the headers and footers}}
Everything inside \nomarking{} will not be shown in the headers or footers.
See https://wiki.contextgarden.net/Command/nomarking
Duncan
On Fri, 14 Mar 2025 at 14:33, Mohammad Hossein Bateni
wrote: Hello,
How can I clip long markings in the header?
See this MNWE, where the two copies of section title collide on page 3.
--------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------
How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles?
Is it possible to provide an alternative shorter section title within \section?
Use \startsection https://wiki.contextgarden.net/Command/_startsection instead of \section. That allows you to specify different values for title, bookmark, heading, references, and more. \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \startsection[title=Long Title for Section Four,marking=Long Title] \stopsection \page \section{Five} \stoptext \starttext -- Rik

Sorry, as I said it was untested, but it certainly used to work on older
versions of ConTeXt. I guess \nomarking has been deprecated and this should
be noted on the wiki? Or is there still an equivalent command (as opposed
to requiring the shift to \startsection / \stopsection)?
On Fri, 14 Mar 2025 at 15:09, Mohammad Hossein Bateni
I get an undefined command error. Does it work on your machine?
On Fri, Mar 14, 2025 at 10:43 AM Duncan Hothersall
wrote: Untested but this should work:
\section{This title is long \nomarking{enough to cause problems in the headers and footers}}
Everything inside \nomarking{} will not be shown in the headers or footers.
See https://wiki.contextgarden.net/Command/nomarking
Duncan
On Fri, 14 Mar 2025 at 14:33, Mohammad Hossein Bateni
wrote: Hello,
How can I clip long markings in the header?
See this MNWE, where the two copies of section title collide on page 3.
--------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------
How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles?
Is it possible to provide an alternative shorter section title within \section?
Thanks, Mohammad
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

The \start/\stop section alternative works nicely. Thanks!
I was trying to work on an automated solution consisting of three parts:
1) Define a new marking which processed normal section title marking
2) Check width to see if we need to apply clipping and add "..."
3) Performing clipping
Here are my unsuccessful attempts for 3:
% clips width correctly but descenders are also removed
\clip[width=3cm]{Long Title for Section Four}
% does not work with \dimexpr (expansion issue?)
\setbox0\hbox{Long Title for Section Four}
\clip[width=3cm,height=\the\dimexpr\ht0+\dp0\relax]{\box0}
% but this one works
\setbox0\hbox{Long Title for Section Four}
\clip[width=3cm,height=18pt}{\box0}
On Fri, Mar 14, 2025 at 11:42 AM Duncan Hothersall
Sorry, as I said it was untested, but it certainly used to work on older versions of ConTeXt. I guess \nomarking has been deprecated and this should be noted on the wiki? Or is there still an equivalent command (as opposed to requiring the shift to \startsection / \stopsection)?
On Fri, 14 Mar 2025 at 15:09, Mohammad Hossein Bateni
wrote: I get an undefined command error. Does it work on your machine?
On Fri, Mar 14, 2025 at 10:43 AM Duncan Hothersall
wrote: Untested but this should work:
\section{This title is long \nomarking{enough to cause problems in the headers and footers}}
Everything inside \nomarking{} will not be shown in the headers or footers.
See https://wiki.contextgarden.net/Command/nomarking
Duncan
On Fri, 14 Mar 2025 at 14:33, Mohammad Hossein Bateni
wrote: Hello,
How can I clip long markings in the header?
See this MNWE, where the two copies of section title collide on page 3.
--------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------
How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles?
Is it possible to provide an alternative shorter section title within \section?
Thanks, Mohammad
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

On 2025-03-14 11:58, Mohammad Hossein Bateni wrote:
The \start/\stop section alternative works nicely. Thanks!
I was trying to work on an automated solution consisting of three parts: 1) Define a new marking which processed normal section title marking 2) Check width to see if we need to apply clipping and add "..." 3) Performing clipping
Here are my unsuccessful attempts for 3:
% clips width correctly but descenders are also removed \clip[width=3cm]{Long Title for Section Four} % does not work with \dimexpr (expansion issue?) \setbox0\hbox{Long Title for Section Four} \clip[width=3cm,height=\the\dimexpr\ht0+\dp0\relax]{\box0} % but this one works \setbox0\hbox{Long Title for Section Four} \clip[width=3cm,height=18pt}{\box0}

Very nice! Thanks Rik!
On Fri, Mar 14, 2025 at 1:46 PM Rik Kabel
On 2025-03-14 11:58, Mohammad Hossein Bateni wrote:
The \start/\stop section alternative works nicely. Thanks!
I was trying to work on an automated solution consisting of three parts: 1) Define a new marking which processed normal section title marking 2) Check width to see if we need to apply clipping and add "..." 3) Performing clipping
Here are my unsuccessful attempts for 3:
% clips width correctly but descenders are also removed \clip[width=3cm]{Long Title for Section Four} % does not work with \dimexpr (expansion issue?) \setbox0\hbox{Long Title for Section Four} \clip[width=3cm,height=\the\dimexpr\ht0+\dp0\relax]{\box0} % but this one works \setbox0\hbox{Long Title for Section Four} \clip[width=3cm,height=18pt}{\box0}
https://wiki.contextgarden.net/Command/limitatetext
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

Am 14.03.2025 um 15:28 schrieb Mohammad Hossein Bateni:
Hello,
How can I clip long markings in the header?
See this MNWE, where the two copies of section title collide on page 3.
--------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------
How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles?
\setupheader[width=5cm] Wolfgang

This is amazing! Thanks Wolfgang! --Mohammad On Fri, Mar 14, 2025 at 12:14 PM Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote:
Am 14.03.2025 um 15:28 schrieb Mohammad Hossein Bateni:
Hello,
How can I clip long markings in the header?
See this MNWE, where the two copies of section title collide on page 3.
--------------- \starttext \setupbodyfont[20pt] \setupheadertexts[section][section] \section{One} \section{Two} \page \section{Three} \page \section{Long Title for Section Four} \page \section{Five} \stoptext ------------
How can I clip the title to a fixed length (5cm?) and perhaps add "..." at the end for longer titles?
\setupheader[width=5cm]
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________

On 2025-03-14 12:54, Mohammad Hossein Bateni wrote:
This is amazing! Thanks Wolfgang! --Mohammad
On Fri, Mar 14, 2025 at 12:14 PM Wolfgang Schuster
wrote: Am 14.03.2025 um 15:28 schrieb Mohammad Hossein Bateni: > Hello, > > How can I clip long markings in the header? > > See this MNWE, where the two copies of section title collide on page 3. > > --------------- > \starttext > \setupbodyfont[20pt] > \setupheadertexts[section][section] > \section{One} > \section{Two} > \page > \section{Three} > \page > \section{Long Title for Section Four} > \page > \section{Five} > \stoptext > ------------ > > How can I clip the title to a fixed length (5cm?) and perhaps add "..." > at the end for longer titles?
\setupheader[width=5cm]
Wolfgang
The width option of setupheader and the limitatetext command are both Procrustean solutions, chopping off without regard to the meaning of the result. Explicitly setting the text via the marking option of startsection is generally a better approach (in my opinion, of course). Even in an automated flow, it should be possible to specify a shorter alternative whenever a title is specified. -- Rik
participants (4)
-
Duncan Hothersall
-
Mohammad Hossein Bateni
-
Rik Kabel
-
Wolfgang Schuster