ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Two bugs with descriptions in ConTeXt.
@ 2024-02-13 21:04 SirColeman via ntg-context
  2024-02-13 21:50 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: SirColeman via ntg-context @ 2024-02-13 21:04 UTC (permalink / raw)
  To: Ntg Context; +Cc: SirColeman


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

The first bug is that descriptions interfere with the counters, resulting in the peculiar behavior demonstrated in the resulting PDF.

Unless I'm mistaken, I think it happens because the head of the description is evaluated twice, thus incrementing the counter twice---at least, that's the only explanation for how the number is incremented by 2 each time. Further, this issue seems to persist whether we're using macros or writing \incrementcounter directly.

The solution is to either make sure that the head of descriptions is evaluated only once, or document that text placed as the head of descriptions is meant to be evaluated twice, if there's a good reason for doing so. Of course, this silly example of incrementing counters can be subdued by placing the \incrementcounter directly in the after option when customizing descriptions. But it demonstrates the issue.

I've tried to make the examples given be as varied as possible, demonstrating the different ways in which descriptions interact with the counter. 

The second bug is that descriptions, or at least that's my intuitive expectation, shouldn't interfere with the bullets of items. I expect that the bullet stays where it is, and the description is placed next to it. But what happens is that the bullet is shifted to the right, making it overlap with the description's head, which isn't pretty.

ConTeXt version 2024.1.24

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

[-- Attachment #2: descriptions.lmtx --]
[-- Type: application/octet-stream, Size: 1347 bytes --]

\definedescription
  [latexdesc]
  [headstyle=bold, style=normal, alternative=hanging,
    width=broad,  before=, distance=1cm, indenting={big, yes}]

\definecounter[counter]
\setcounter[counter][1]

\def\counterpart{Part \convertedcounter[counter]: \incrementcounter[counter]}

\starttext
\startlatexdesc{\counterpart\ Short}
  The bug is here.
\stoplatexdesc
\startlatexdesc{\counterpart\ Rather longer label}
  The bug is here.
\stoplatexdesc

\startlatexdesc{Part \convertednumber[counter]: Rather longer label}
  Hello there.
\stoplatexdesc

\counterpart

\startlatexdesc{\counterpart\ Rather longer label}
  The bug is here.
\stoplatexdesc

% There's no \incrementcounter!
\def\othercounterpart{Part \convertedcounter[counter]:}
\startlatexdesc{\othercounterpart\ Rather longer label}
  Seems okay.
\stoplatexdesc
\startlatexdesc{\othercounterpart\ Rather longer label}
  Definitely okay!
\stoplatexdesc

% Issue persists despite not using macros.
\startlatexdesc{Part \convertedcounter[counter]: \incrementcounter[counter]
  Rather longer label}
  The bug is here.
\stoplatexdesc
\startlatexdesc{Part \convertedcounter[counter]: \incrementcounter[counter]
  Rather longer label}
  The bug is here.
\stoplatexdesc

\blank[1cm]

\startitemize
\item \startlatexdesc {Hello, \ConTeXt!} \samplefile {knuth} \stoplatexdesc
\stopitemize

\stoptext

[-- Attachment #3: descriptions.pdf --]
[-- Type: application/pdf, Size: 15568 bytes --]

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* [NTG-context] Re: Two bugs with descriptions in ConTeXt.
  2024-02-13 21:04 [NTG-context] Two bugs with descriptions in ConTeXt SirColeman via ntg-context
@ 2024-02-13 21:50 ` Wolfgang Schuster
  2024-02-13 22:06   ` Sir Coleman via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2024-02-13 21:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users, SirColeman via ntg-context; +Cc: SirColeman


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

SirColeman via ntg-context schrieb am 13.02.2024 um 22:04:
> The first bug is that descriptions interfere with the counters, 
> resulting in the peculiar behavior demonstrated in the resulting PDF.

Still no bug and there is no need to create your own counter because 
enumerations exist which are descriptions with a counter.

> Unless I'm mistaken, I think it happens because the head of the 
> description is evaluated twice, thus incrementing the counter 
> twice---at least, that's the only explanation for how the number is 
> incremented by 2 each time. Further, this issue seems to persist 
> whether we're using macros or writing \incrementcounter directly.
>
> The solution is to either make sure that the head of descriptions is 
> evaluated only once, or document that text placed as the head of 
> descriptions is meant to be evaluated twice, if there's a good reason 
> for doing so. Of course, this silly example of incrementing counters 
> can be subdued by placing the \incrementcounter directly in the after 
> option when customizing descriptions. But it demonstrates the issue.

What you're supposed to do here is to increment the counter *before* you 
use the counter value.

As you guessed the content of the title is evaluated multiple times to 
get the width of the description title, in cases where a counter is 
incremented in such a case (very common when you have counters in a 
table cell) you use the trialtypesetting mode to increment only once.

> I've tried to make the examples given be as varied as possible, 
> demonstrating the different ways in which descriptions interact with 
> the counter.
>
> The second bug is that descriptions, or at least that's my intuitive 
> expectation, shouldn't interfere with the bullets of items. I expect 
> that the bullet stays where it is, and the description is placed next 
> to it. But what happens is that the bullet is shifted to the right, 
> making it overlap with the description's head, which isn't pretty.

Is this even a real world example?

The reason why the bullet points are at the wrong position is that 
descriptions and items use the same mechanism to set the text offset on 
the left and right sides and when you combine both mechanism the values 
are added. In case you you have a document where a descriptions appear 
as part of an item I suggest to use a different alternative (e.g. 
serried) for the description layout.

Wolfgang


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

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* [NTG-context] Re: Two bugs with descriptions in ConTeXt.
  2024-02-13 21:50 ` [NTG-context] " Wolfgang Schuster
@ 2024-02-13 22:06   ` Sir Coleman via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: Sir Coleman via ntg-context @ 2024-02-13 22:06 UTC (permalink / raw)
  To: ntg-context; +Cc: Sir Coleman

Oh dear...

The serried alternative does indeed solve the second "bug". And to answer your question, I literally encountered this problem in one of my own documents, so yes, it's a real world problem...

And also good to know the explanation of why the counter acts weird. I'll also check out enumerations, thanks.

Also, I'll be more careful about what I call bugs, because apparently it's very possible that it's not a bug that I have to complain about.

Thanks for your time.
___________________________________________________________________________________
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
___________________________________________________________________________________

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

end of thread, other threads:[~2024-02-13 22:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 21:04 [NTG-context] Two bugs with descriptions in ConTeXt SirColeman via ntg-context
2024-02-13 21:50 ` [NTG-context] " Wolfgang Schuster
2024-02-13 22:06   ` Sir Coleman via ntg-context

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