4

A big issue is how to control float placement. I don't want to stress this problem but I would like to get an automatic overview over problem. What I mean:

Is there the possibility to get a list with all floats, where the page of definition of float is written as well as the placement page of float. Then one can easily see, how many pages the float "floats".

An example:

Text text text %which is on page 3  
\begin{figure}  
Figure  
\end{figure}  
text text text %also on page 3

The figure was placed on page 8. Now it would like a list showing:

Figure 4.1: definition page 3, placement page 8

So the page floats 5 pages...

Is this easily possible?

Regards, Andreas

  • 2
    You only need a \label at the start of the float and one in its content. And then you can compare the \pageref. – Ulrike Fischer Nov 6 '13 at 10:08
  • Thanks for the fast reply. Ok, but I have a large document and would appreciate if I don't have to edit all entries. Isn't there an automatic solution? – Andreas Nov 6 '13 at 10:09
  • I would assume you already have a label in the figure, so you can refer to it in the text. The issue becomes one of how to insert the label at the \ref{fig_somefig}. This is reasonably easy in notepad++ or any text editor which supports regex in find/replace. Finding (\\ref\{([a-zA-Z:_]*)\}) and replacing it with $1\\label{refto:$2} should give you what you want. Now hopefully @UlrikeFischer can explain how to pair the pagerefs to the 2 labels - I haven't yet figured it out, but if I do I'll post an answer. – Chris H Nov 6 '13 at 12:06
  • Yes, but I still have to do it for every Figure. If one is added, I have to make changes at many different positions in the text. I hoped, there is an easier solution, because this is an interesting feature, I suppose. – Andreas Nov 7 '13 at 9:42
2

I finally solved the problem:

I used the comments of Ulrike and Chris, thanks, and the package smartref to save the page number in a variable. A new command calculates the difference and writes the text:

\newcount\totalfloatingpages
\newcommand{\floating}[1]{
\sgetpageval{\refp}{#1_ref}
\sgetpageval{\floatp}{#1}
\newcount\floatingpages
\advance\floatingpages by \floatp
\advance\floatingpages by -\refp
\advance\totalfloatingpages by \floatingpages
{Float \ref{#1} with label #1 on page \floatp : \ifthenelse{\floatingpages>1}  {\dotfill \the\floatingpages}{\the\floatingpages}\\}
}


\floating{fig:figure}

The command "floating" calls the function which calculates the difference of pages between the "figure" label and "figure_ref" label. Now it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.