kvafa / bidi

Bidirectional typesetting in plain TeX and LaTeX, using XeTeX
https://ctan.org/pkg/bidi
6 stars 1 forks source link

Problem in footnote #17

Open bahman-mirzakhani opened 1 year ago

bahman-mirzakhani commented 1 year ago

Brief outline of the issue

When some footnotes place at last/first line of page, the footers goes next/previous page.

Check/indicate

Minimal example showing the issue

% !TEX TS-program = XeLaTeX
% !TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}            % or some other class

\newcount\footCounter
\newcommand{\mfootnote}[1]{%
    \loop
    \ifnum\footCounter<#1
        \footnote{تست}%
        \advance\footCounter by 1
    \repeat\footCounter0%
}
\usepackage{ptext}
\usepackage[%
    extrafootnotefeatures,%
    perpagefootnote%
]{xepersian}
\settextfont{IRXLotus}
\ParagraphFootnotes
\begin{document}

    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]

\end{document}

Expected behavior

See the pages: 2--6

Log and PDF files

test.pdf test.log

kvafa commented 1 year ago

My investigation so far shows that the issue also happens without using xepersian/bidi packages. Look particularly at pages 4, 6, 8, and 10.

\documentclass[12pt]{article}            % or some other class
\usepackage{zref-perpage} 
\zmakeperpage{footnote}
\newcount\footCounter
\newcommand{\mfootnote}[1]{%
    \loop
    \ifnum\footCounter<#1
        \footnote{Test}%
        \advance\footCounter by 1
    \repeat\footCounter0%
}
\usepackage{fontspec}
\setmainfont{IRXLotus}
\usepackage{ptext}
\begin{document}

    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]\mfootnote{5}
    \ptext[1-2]

\end{document}
kvafa commented 1 year ago

Could you please also post Vahid Damanafshan's example from Telegram? I do not have access to Telegram as I left my phone in home back in Australia.

bahman-mirzakhani commented 1 year ago

When I asked Mr. DamanAfshan, he said that I had the same problem.

kvafa commented 1 year ago

I think the two issues are slightly different although somehow related; from memory, I think his example had the old footnote cs \paragraphfootnotes or something similar while your example uses the new footnote cs \ParagraphFootnotes.

Anyway, it helps me a lot if I also can have access to Vahid's specific example.

bahman-mirzakhani commented 1 year ago

I asked this question about different methods of resetting footnote numbers for more details. Only one of the methods worked correctly (with footmisc package). Comment: The ones I mark not ok can not work as the footnotes have been allocated numbers before page breaking. That is why footmisc offers code to implement this.

kvafa commented 1 year ago

I asked this question about different methods of resetting footnote numbers for more details. Only one of the methods worked correctly (with footmisc package). Comment: The ones I mark not ok can not work as the footnotes have been allocated numbers before page breaking. That is why footmisc offers code to implement this.

I do not think that it is footmisc that implements it as it loads perpage package. That is, if you load perpage directly instead footmisc, you should also get the correct output.

bahman-mirzakhani commented 1 year ago

You are right. Is it possible the bidi package to use some codes like perpage package for solving this issue?

bahman-mirzakhani commented 1 year ago

You are right. Is it possible the bidi package to use some codes like perpage package for solving this issue?

Note: unfortunately the perpage package also transfers the last line of the previous page to the next page and its place remains empty. Even the \flushbottom command doesn't fill it.

kvafa commented 1 year ago

You are right. Is it possible the bidi package to use some codes like perpage package for solving this issue?

I have not investigated the issue thoroughly; I just made some observation without actually looking at what is going on exactly.

One way to go forward is to see what perpage does that 'bidi-perpagedoes not and extendbidi-perpage' to get the correct behavior.

Another possible solution is to avoid resetting footnotes by using a different algorithm.

I just need to find some free time to investigate this and fix it.

saeidm23 commented 1 year ago

Is there any solution for the bug?

bahman-mirzakhani commented 1 year ago

Is there any solution for the bug?

According to comments, you can use perpage package as follows:

\usepackage{perpage} 
\MakePerPage{footnote}
saeidm23 commented 1 year ago

Many thanks. But that does not resolve the issue.