[NTG-context] How to place a page reference multiple times?

2023-03-01 Thread Joel via ntg-context
I need to report every chapter that a particular macro appeared. I would do 
this by placing `\pagereference[sample]` inside the macro definition, so 
whenever it is called, it marks the reference info. But I can't seem to get 
references to work with multiple reference locations marked, example:
\starttext

    You can find it at \at{page}[sample] in \at{chapter}[sample].

\chapter{Fish}

\pagereference[sample]

\input knuth

\input knuth

\pagebreak
\chapter{Whales}

\input knuth

\pagereference[sample]

\stoptext
(you can see in this example, it only finds `\pagereference[sample]` on page 1 
and ignores the second appearance.



Ideally, I need to be able to output something like, "See examples in Chapter 
3, 8, 19" (because those chapters contain a particular macro that I marked with 
\pagereference. Or, if even possible, see chapters 3 (p. 22), 8 (p. 40), and 20 
(though the first example is fine.
Is there a way to place a page reference multiple times, so multiple pages or 
chapter details will appear?
--Joel
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Float control

2023-03-01 Thread Alan Braslau via ntg-context
On Thu, 2 Mar 2023 00:12:53 +0100
Hans Hagen via ntg-context  wrote:

> On 2/28/2023 11:45 AM, Denis Maier via ntg-context wrote:
> > Hi everyone,
> > 
> > I’ve recently had to typeset a document that gave me some headaches
> > with the floats. The floats where jumping around, appearing in a
> > different order than in the source file, tables ended up split up
> > at weird points, some positioning keys had not the intended effect
> > (e.g. top), «page» moved the float more than seemed necessary for
> > me... I know, TeX’s float positioning algorithm should be rather
> > reliable and stable, and it’s quite possible that I’m messing
> > things up in my setups–especially since my source files are XML.
> > 
> > Anyway, I’d like to learn more about the whole float issue. Is
> > there anything particular I could read to learn more about the
> > whole thing? Maybe I’m missing out on something fundamental...
> Basically floats are output in order when they fit. You can use force
> to really do that. When there is no room they will migrate. Some
> options like top and bottom might also change the order. Normally you
> start with just placing ('here') and see how that works out. Side
> floats are special and anchored to the text.
> 
> The more complex and confliuctign the demands, the harder it gets for 
> ConTeXt to fulfill all requirements. In that case shifting around the 
> text or places where you ask for a float helps. It's one of the areas 
> where 'fully automated and perfect' are complex as everything can 
> interfere.
> 
> Btw, Mikael S is working on a tutorial that explains some neat
> trickery with specific placements (which also triggered some
> additional features).

A few (important) observations on floats:

\startplacefloat
\stopplacefloat
triggers a paragraph break.

I therefore locate them always at the beginning or at the end of a
paragraph of text.
(A trick is to enclose them in a named buffer within a
paragraph, typically where a figure call -
\in{figure}[figureReference] - is to be located. Then to place
the \getbuffer at the beginning or end of a paragraph. See
example below.)

The keys location=top/bottom will place the float at the top or bottom
of the page IF IT FITS, otherwise it is pushed to the following page.
Thus, a bottom can become a top.

The key location=force will place the figure there, perhaps generating
a page break if it does not fit.

The key location=page will put the figure on a following page. This
situation can sometimes push figures to appear "out of order", if
another figure can somehow fit before the figure pushed to the
following page. This happens if another floating figure "comes too
soon".

The keys location=left and location=right will also generate a page
break if the figure does not fit.

In the end, one needs to tweak a document in final form especially if
it contains many figures, unfortunately. This is done by moving the 
\startfigure...\stopfigure. Here, the use of buffers:

Paragraph text ...
(see \in{figure}[myfigure]).
\startbuffer[myfigure]
  \startfigure[reference=myfigure,
   location=top,
   title=Title]
\externalfigure[myfigure][width=\textwidth]
  \stopfigure
\stopbuffer
More text ...\par
\getbuffer[myfigure]

can make life easier, moving the \getbuffer[myfigure] to an optimal
paragraph beginning or end.

Alan

P.S. It might be nice to be able to anchor a figure not to text but to
a page location, like location=nexttop or location=nextbottom, or even
location={nexttop,right} etc. This gets really complicated (but
anything is do-able).

P.P.S. I'm certain to learn some neat trickery from Mikael's tutorial!
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Float control

2023-03-01 Thread Max Chernoff via ntg-context

Hi Denis,

> The floats where jumping around, appearing in a different order than
> in the source file

Tables and figures can appear in different orders than each other, and a
top float could appear at the top of the page that it is mentioned, but
if you ever see Figure 2 before Figure 1 or a float appearing before it
is placed in the source (with the exception of the top issue), then
you've probably found a bug.

> some positioning keys had not the intended effect (e.g. top)

I've had mixed results with some of the positioning keys too, but "top"
should generally work okay. If you're using columns, weird stuff can
sometimes happen with top/bottom floats, but you should still be able to
make them work. You can also try adding

   \setupfloat[ntop=100]
   
at the start of you're document. I've had that fix an otherwise-
unexplainable bug once.

> I know, TeX's float positioning algorithm should be rather reliable
> and stable

Not as much as you would expect. The TeX page breaking algorithm is
greedy, single-pass, and dependant on every page prior, so you can get
some pretty chaotic results in pathological situations. "Typical"
documents don't usually have any issues, but you can (even accidentally)
make a document that gives some really weird results.

> Anyway, I'd like to learn more about the whole float issue. Is there anything 
> particular I could read to learn more about the whole thing?

The only float documentation for ConTeXt that I'm aware of is a short
section in It's in the Details

   
https://www.pragma-ade.nl/general/manuals/details.pdf#%5B%7B%22num%22%3A39%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22Fit%22%7D%5D
   
and another short section in the old Reference Manual

   http://pmrb.free.fr/contextref.pdf#aut%3A957
   
There's also the Wiki page

   https://wiki.contextgarden.net/Floating_Objects
   
and the source code

   https://source.contextgarden.net/tex/context/base/mkxl/strc-flt.mklx
   
I haven't been able to find anything that really goes into the details
though. (If there's something that I'm missing here, please let me know!
I've been looking for awhile now)

> Maybe I'm missing out on something fundamental...

At the TeX level, floats are known as \insert's/insertions. The end of
Chapter 15 in The TeXbook goes into detail here. TeX By Topic also has a
good description in Chapter 29

   https://texdoc.org/serve/texbytopic/0#chapter.29
   
Then there's also Low Level TeX which documents the changes in LMTX

   https://www.pragma-ade.com/general/manuals/lowlevel-inserts.pdf
   
Inserts are (in my opinion) the most complicated part of TeX. Even at an
engine level, they aren't that well documented. When writing the
footnote code for lua-widow-control, I had to read through "TeX the
program" since some of the details weren't documented anywhere else.

And as Peter mentioned, if you post a specific example someone will
probably come along and help.

-- Max
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Float control

2023-03-01 Thread Hans Hagen via ntg-context

On 2/28/2023 11:45 AM, Denis Maier via ntg-context wrote:

Hi everyone,

I’ve recently had to typeset a document that gave me some headaches with 
the floats. The floats where jumping around, appearing in a different 
order than in the source file, tables ended up split up at weird points, 
some positioning keys had not the intended effect (e.g. top), «page» 
moved the float more than seemed necessary for me... I know, TeX’s float 
positioning algorithm should be rather reliable and stable, and it’s 
quite possible that I’m messing things up in my setups–especially since 
my source files are XML.


Anyway, I’d like to learn more about the whole float issue. Is there 
anything particular I could read to learn more about the whole thing? 
Maybe I’m missing out on something fundamental...
Basically floats are output in order when they fit. You can use force to 
really do that. When there is no room they will migrate. Some options 
like top and bottom might also change the order. Normally you start with 
just placing ('here') and see how that works out. Side floats are 
special and anchored to the text.


The more complex and confliuctign the demands, the harder it gets for 
ConTeXt to fulfill all requirements. In that case shifting around the 
text or places where you ask for a float helps. It's one of the areas 
where 'fully automated and perfect' are complex as everything can 
interfere.


Btw, Mikael S is working on a tutorial that explains some neat trickery 
with specific placements (which also triggered some additional features).


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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Float control

2023-03-01 Thread Peter Hopcroft via ntg-context
Yes, me too. I found the best thing is to post on LaTeX stack exchange a short 
piece of context that shows one problem you are having. Tag it #context. 
Someone will kindly help. Repeat for your other problems.

I use layers a lot to avoid floats.

Good luck,
Peter

> On 28/02/2023, at 11:47 PM, Denis Maier via ntg-context  
> wrote:
> 
> 
> Hi everyone,
>  
> I’ve recently had to typeset a document that gave me some headaches with the 
> floats. The floats where jumping around, appearing in a different order than 
> in the source file, tables ended up split up at weird points, some 
> positioning keys had not the intended effect (e.g. top), «page» moved the 
> float more than seemed necessary for me... I know, TeX’s float positioning 
> algorithm should be rather reliable and stable, and it’s quite possible that 
> I’m messing things up in my setups–especially since my source files are XML.
>  
> Anyway, I’d like to learn more about the whole float issue. Is there anything 
> particular I could read to learn more about the whole thing? Maybe I’m 
> missing out on something fundamental...
>  
> Best,
> Denis
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / 
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] /CropBox overflows /MediaBox

2023-03-01 Thread Pablo Rodriguez via ntg-context
On 2/28/23 21:18, Hans Hagen via ntg-context wrote:
> On 2/28/2023 6:23 PM, Pablo Rodriguez via ntg-context wrote:
>> [...]
>> Could anyone be so kind to confirm the issue or to explain the
>> rationale behind the oversized /CropBox?
> different code path (dates from mkiv but i can adapt it for lmtx)
>
> anyway, overflow is in the 7th decimal so quite harmless i guess

Many thanks for your reply, Hans.

Sorry, I’m afraid my explanation was poor.

/MediaBox for both pages is [ 0 0 595.275590072 841.88975789 ].

/CropBox for page 1 is [ 0 0 595.27559 841.889758 ] (which is fine, no
problem here).

/CropBox for page 2 is [ 0 0 968.199847 841.889758 ] (which is a much
wider box, converting it from portrait to landscape).

I hope it is clearer now.

Many thanks for your help,

Pablo
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___