gucci-on-fleek / lua-widow-control

(Lua)TeX package to automatically remove widows and orphans from any document
15 stars 1 forks source link

Footnote at the moved line is displayed twice #37

Closed Jinwen-XU closed 2 years ago

Jinwen-XU commented 2 years ago

Issue

The footnote is displayed twice instead of simply moving to the next page with the corresponding line. This behavior appears to be different from that described in the "Known issue" section of the documentation.

Expected Behavior

I expected that lua-widow-control would move the paragraph and the footnote entirely to the next page.

Reproduction

\documentclass{article}

\usepackage[debug=true]{lua-widow-control}
\usepackage{blindtext}

\begin{document}

\vspace*{30\baselineskip}

\blindtext

Some text\footnote{\blindtext}. \blindtext

\end{document}

Log File

This is LuaHBTeX, Version 1.15.0 (TeX Live 2022)  (format=lualatex 2022.8.7)  7 AUG 2022 21:54
 restricted system commands enabled.
 file:line:error style messages enabled.

LaTeX2e <2022-06-01> patch level 5
Lua module: luaotfload 2022-06-15 3.22 Lua based OpenType font support
Lua module: lualibs 2021-05-20 2.74 ConTeXt Lua standard libraries.
Lua module: lualibs-extended 2021-05-20 2.74 ConTeXt Lua libraries -- extended collection.
luaotfload | conf : Root cache directory is "/Users/xujinwen/Library/texlive/2022/texmf-var/luatex-cache/generic/names".
luaotfload | init : Loading fontloader "fontloader-2022-06-15.lua" from kpse-resolved path "/usr/local/texlive/2022/texmf-dist/tex/luatex/luaotfload/fontloader-2022-06-15.lua".
Lua-only attribute luaotfload@noligature = 1
luaotfload | init : Context OpenType loader version 3.120
Inserting `luaotfload.node_processor' at position 1 in `pre_linebreak_filter'.
Inserting `luaotfload.node_processor' at position 1 in `hpack_filter'.
Inserting `luaotfload.glyph_stream' at position 1 in `glyph_stream_provider'.
Inserting `luaotfload.define_font' at position 1 in `define_font'.
Lua-only attribute luaotfload_color_attribute = 2
luaotfload | conf : Root cache directory is "/Users/xujinwen/Library/texlive/2022/texmf-var/luatex-cache/generic/names".
Inserting `luaotfload.harf.strip_prefix' at position 1 in `find_opentype_file'.
Inserting `luaotfload.harf.strip_prefix' at position 1 in `find_truetype_file'.
Removing  `luaotfload.glyph_stream' from `glyph_stream_provider'.
Inserting `luaotfload.harf.glyphstream' at position 1 in `glyph_stream_provider'.
Inserting `luaotfload.harf.finalize_vlist' at position 1 in `post_linebreak_filter'.
Inserting `luaotfload.harf.finalize_hlist' at position 2 in `hpack_filter'.
Inserting `luaotfload.cleanup_files' at position 1 in `wrapup_run'.
Inserting `luaotfload.harf.finalize_unicode' at position 1 in `finish_pdffile'.
Inserting `luaotfload.glyphinfo' at position 1 in `glyph_info'.
Lua-only attribute luaotfload.letterspace_done = 3
Inserting `luaotfload.aux.set_sscale_dimens' at position 1 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.set_font_index' at position 2 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.patch_cambria_domh' at position 3 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.fixup_fontdata' at position 1 in `luaotfload.patch_font_unsafe'.
Inserting `luaotfload.aux.set_capheight' at position 4 in `luaotfload.patch_font'.
Inserting `luaotfload.aux.set_xheight' at position 5 in `luaotfload.patch_font'.
Inserting `luaotfload.rewrite_fontname' at position 6 in `luaotfload.patch_font'. L3 programming layer <2022-08-05>
Inserting `tracingstacklevels' at position 1 in `input_level_string'. (/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
luaotfload | db : Font names database loaded from /Users/xujinwen/Library/texlive/2022/texmf-var/luatex-cache/generic/names/luaotfload-names.luc.gz)
\c@part=\count183
\c@section=\count184
\c@subsection=\count185
\c@subsubsection=\count186
\c@paragraph=\count187
\c@subparagraph=\count188
\c@figure=\count189
\c@table=\count190
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen137
) (/usr/local/texlive/2022/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty
Package: lua-widow-control 2022/07/28 vv2.2.1 Use Lua to remove widows and orphans
 (/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2022-08-05 L3 programming layer (loader) 
 (/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-luatex.def
File: l3backend-luatex.def 2022-08-05 L3 backend support: PDF output (LuaTeX)
\l__color_backend_stack_int=\count191
\l__pdf_internal_box=\box51
))
Package: l3keys2e 2022-06-22 LaTeX2e option processing using LaTeX3 keys
)
\g__lwc_emergencystretch_dim=\dimen138
\g__lwc_maxcost_int=\count192
Lua module: lua-widow-control 2022/07/28 2.2.1 
This module provides a LuaTeX-based solution to prevent
widows and orphans from appearing in a document. It does
so by increasing or decreasing the lengths of previous
paragraphs.
Lua-only attribute lua-widow-control_paragraph = 4
Lua-only attribute lua-widow-control_insert = 5
Lua function __lwc_if_enabled: = 26
Lua function __lwc_enable: = 27
Lua function __lwc_disable: = 28
Lua function __lwc_nobreak:n = 29
Lua function __lwc_debug:n = 30
Lua function __lwc_draft:n = 31
\g__lwc_disable_int=\count193
) (/usr/local/texlive/2022/texmf-dist/tex/latex/blindtext/blindtext.sty
Package: blindtext 2012/01/06 V2.0 blindtext-Package
 (/usr/local/texlive/2022/texmf-dist/tex/latex/tools/xspace.sty
Package: xspace 2014/10/28 v1.13 Space after command names (DPC,MH)
)
\c@blindtext=\count194
\c@Blindtext=\count195
\c@blind@countparstart=\count196
\blind@countxx=\count197
\blindtext@numBlindtext=\count198
\blind@countyy=\count199
\c@blindlist=\count266
\c@blindlistlevel=\count267
\c@blindlist@level=\count268
\blind@listitem=\count269
\c@blind@listcount=\count270
\c@blind@levelcount=\count271
\blind@mathformula=\count272
\blind@Mathformula=\count273
\c@blind@randomcount=\count274
\c@blind@randommax=\count275
\c@blind@pangramcount=\count276
\c@blind@pangrammax=\count277
) (/usr/local/texlive/2022/texmf-dist/tex/latex/microtype/microtype.sty
Package: microtype 2022/06/23 v3.0f Micro-typographical refinements (RS)
 (/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks16
) (/usr/local/texlive/2022/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count278
)
\MT@toks=\toks17
\MT@tempbox=\box52
\MT@count=\count279
LaTeX Info: Redefining \noprotrusionifhmode on input line 1045.
LaTeX Info: Redefining \leftprotrusion on input line 1046.
LaTeX Info: Redefining \rightprotrusion on input line 1056.
LaTeX Info: Redefining \textls on input line 1234.
\MT@outer@kern=\dimen139
LaTeX Info: Redefining \textmicrotypecontext on input line 1858.
\MT@listname@count=\count280
 (/usr/local/texlive/2022/texmf-dist/tex/latex/microtype/microtype-luatex.def
File: microtype-luatex.def 2022/06/23 v3.0f Definitions specific to luatex (RS)
Lua module: microtype 2022/06/23 3.0f microtype module.
Module microtype Info: overwriting function `keepligature' on input line 63
LaTeX Info: Redefining \lsstyle on input line 686.
LaTeX Info: Redefining \lslig on input line 686.
\MT@outer@space=\skip49
)
Package microtype Info: Loading configuration file microtype.cfg.
 (/usr/local/texlive/2022/texmf-dist/tex/latex/microtype/microtype.cfg

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 7.
LaTeX Font Info:    Trying to load font information for TS1+cmr on input line 7.
 (/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd
File: ts1cmr.fd 2019/12/16 v2.5j Standard LaTeX font definitions
)
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for TU/lmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Info: Redefining \microtypecontext on input line 7.
Package microtype Info: Applying patch `item' on input line 7.
Package microtype Info: Applying patch `toc' on input line 7.
Package microtype Info: Applying patch `eqnum' on input line 7.
Package microtype Info: Applying patch `footnote' on input line 7.
Package microtype Info: Generating PDF output.
Package microtype Info: Character protrusion enabled (level 2).
Package microtype Info: Using default protrusion set `alltext'.
Package microtype Info: Automatic font expansion enabled (level 2),
(microtype)             stretch: 20, shrink: 20, step: 1, non-selected.
Package microtype Info: Using default expansion set `alltext-nott'.
LaTeX Info: Redefining \showhyphens on input line 7.
Package microtype Info: No adjustment of tracking.
Package microtype Info: No adjustment of spacing.
Package microtype Info: No adjustment of kerning.
 (/usr/local/texlive/2022/texmf-dist/tex/latex/microtype/mt-LatinModernRoman.cfg
File: mt-LatinModernRoman.cfg 2021/02/21 v1.1 microtype config. file: Latin Modern Roman (RS)
)
LWC (At 1/1         ): Lorem ipsum dolor sit amet
LWC (At 1/1         ): nat  lines    10
LWC (At 1/1         ): nat  cost 724.79403971059
LWC (At 1/1         ): long lines    11
LWC (At 1/1         ): long cost 8324.1252011029 (/usr/local/texlive/2022/texmf-dist/tex/latex/microtype/mt-cmr.cfg
File: mt-cmr.cfg 2013/05/19 v2.2 microtype config. file: Computer Modern Roman (RS)
)
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 13.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 13.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <8> on input line 13.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <6> on input line 13.
LWC (At 1/2         ): Some text. Lorem ipsum dol
LWC (At 1/2         ): nat  lines    11
LWC (At 1/2         ): nat  cost 865.33755893818
LWC (At 1/2         ): long lines    11
LWC (At 1/2         ): long cost 4031.2066770047
LWC (outputpenalty  ): 1 2
Module lua-widow-control Info: Widow/orphan/broken hyphen detected. Attempting to remove on input line 14
LWC (first/last     ): 1/2
LWC (selected para  ): 1/1 (8324.1252011029)
LWC (remove_widows  ): moving last line
Module lua-widow-control Info: Moving footnotes on page 1 on input line 14
LWC (remove_widows  ): found 101
LWC (remove_widows  ): replacement start
LWC (remove_widows  ): found -101
LWC (remove_widows  ): replacement end
Module lua-widow-control Info: Widow/orphan/broken hyphen successfully removed at paragraph 1 on page 1 on input line 14
 [1

{/usr/local/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
LWC (outputpenalty  ): -10000 0 [2]
LWC (outputpenalty  ): -1073741824 0)

Here is how much of LuaTeX's memory you used:
 3155 strings out of 477465
 125236,460012 words of node,token memory allocated
 417 words of node memory still in use:
   3 hlist, 1 vlist, 1 rule, 3 glue, 3 kern, 1 glyph, 5 attribute, 48 glue_spec, 5 attribute_list, 1 write nodes
   avail lists: 1:5,2:132,3:55,4:49,5:228,6:13,7:7508,8:2,9:122,10:8,11:611
 24138 multiletter control sequences out of 65536+600000
 34 fonts using 2113559 bytes
 72i,8n,73p,1065b,216s stack positions out of 10000i,1000n,20000p,200000b,200000s
</usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman6-regular.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman8-regular.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman7-regular.otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf>

PDF statistics: 39 PDF objects out of 1000 (max. 8388607)
 22 compressed objects within 1 object stream
 0 named destinations out of 1000 (max. 131072)
 1 words of extra memory for PDF output out of 10000 (max. 100000000)

Format

LaTeX

Distribution

TeX Live

Distribution Version

2022

Lua-widow-control Version

2.2.1

Other Relevant Packages and Versions

No response

Other

No response

gucci-on-fleek commented 2 years ago

Yeah, that definitely shouldn't happen.

Normally when moving a footnote, lua-widow-control deletes the footnote text from the initial page, and then re-adds the footnote text to the moved page. When a footnote is so long that LaTeX splits it into two pages, lua-widow-control still deletes the first half of the footnote text from the initial page, but it does nothing about the second half already on the next page. Then, when it re-adds the footnote text, it adds the entire footnote, leading to the weird duplicated text.

As a temporary workaround, you can place

\interfootnotelinepenalty=10000

somewhere in your document's preamble to prevent any footnotes from splitting. I should hopefully have a proper fix for this out some time in the next week or two.

gucci-on-fleek commented 2 years ago

This should be fixed now with the latest commits. I'll get this pushed out to CTAN/TeX Live in a couple of days.