-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lineno
makes lua-widow-control
think there are many nonexistent pages in the output
#41
Comments
This is definitely a bug. What's happening is that This issue is much more complicated than it looks, so I don't have a solution quite yet. Hopefully I'll figure something a proper solution in the next few days; if not, I'll patch lua-widow-control to print a single warning and then disable itself if it detects |
I've done some more testing and this looks really hard to fix. The two problems here are that (1)
I'll leave this issue open since I don't want to say that it's impossible to solve, but I also wouldn't expect a solution to be released any time soon. |
@d125q I'm currently working on a package for line numbering in LuaTeX. Since it does not change any typesetting parameters, nor mess with the output routine it should have less problems. If you want to test it, you can find it here https://github.com/Udi-Fogiel/lua-lineno, but be ware that it is still in very early stage. Here is a minimal test code \documentclass[a4paper,11pt]{article}
\usepackage[american]{babel}
\usepackage{lualineno}
\newcounter{lineno}
\deflineno
{
name = default
preamble = {\stepcounter{lineno}}
left = {\tiny\thelineno\kern.8em}
}
\setlineno{default}
\usepackage[debug=true]{lua-widow-control}
\usepackage{lipsum}
\begin{document}
\lipsum
\end{document} @gucci-on-fleek I've noticed that you use the |
Ah neat, that looks quite nice.
Yes, but only to typeset the paragraph costs in draft mode, so it's fairly unimportant if that doesn't work. But I've tested it and it seems to be fine, regardless of which package is loaded first: %% Setup
\documentclass{article}
\usepackage[textwidth=345pt, textheight=550pt, showframe]{geometry}
%% lualineno
\usepackage{lualineno}
\newcounter{lineno}
\deflineno{
name = default
preamble = {\stepcounter{lineno}}
left = {\tiny\thelineno\kern.8em}
}
\setlineno{default}
%% lua-widow-control
\usepackage[draftoffset=\oddsidemargin + 1in]{lua-widow-control}
%% Filler content
\newcount\recurselevel
\long\def\dorecurse#1#2{%
\recurselevel=0%
\loop\ifnum\recurselevel<#1%
\advance\recurselevel by 1\relax%
#2%
\repeat%
}
\def\test{
\dorecurse{19}{Filler line filler line filler line. }
\dorecurse{4}{\input{knuth}\par}
\clearpage
}
%% Demonstration
\begin{document}
\lwcsetup{disable} \test
\lwcsetup{enable} \test
\lwcsetup{draft} \test
\end{document} But why are you using \documentclass[twocolumn]{article}
\setlength{\columnsep}{1cm}
\newcounter{lineno}
\def\printlinenumber{\llap{
\stepcounter{lineno}%
\tiny\thelineno%
\quad%
}}
\usepackage{luacode}
\begin{luacode*}
local hlist_id = node.id("hlist")
local line_subid = table.swapped(node.subtypes("hlist"))["line"]
local typeset_tok = token.create("printlinenumber")
luatexbase.add_to_callback("contribute_filter", function(info)
-- Only process boxes in the main vertical list
if info ~= "box" or tex.nest.ptr ~= 0 then
return
end
-- Only process lines
local line = tex.nest[0].tail or {}
if line.id ~= hlist_id or line.subtype ~= line_subid then
return
end
-- Process the line
tex.runtoks(function()
-- Get a box holding the line number
token.put_next(typeset_tok)
local number_box = token.scan_list()
-- Insert the box at the beginning of the line
line.head = node.insert_before(line.head, line.head, number_box)
end)
end, "line_numbers")
\end{luacode*}
\usepackage{babel, lipsum}
\begin{document}
\lipsum
\end{document} This isn't compatible with lua-widow-control as-is, but that's probably fixable. |
Thanks!
Good.
The whole idea started only several days ago when I encountered this post, so the main thing I wanted to tackle is balanced columns. Since balancing is done just before shipout, you can't tell in which column the line will end up until shipout, so I did not even think about other callbacks (but i'm more than open to suggestions). In the long run I'll probably want to add several options, for different algorithms. After thinking about it for several days I don't every will agree on what should be considered a line. |
There are also people who wants to number footnotes lines |
Ahhh, that makes sense then. In that case, I agree that lua-widow-control/source/lua-widow-control.lua Lines 1200 to 1201 in 96523a2
Actually, the more “fun” solution would be rewriting multicol in Lua. This would then let you have columns of uneven widths, even in the middle of the paragraph. Something like https://tex.stackexchange.com/a/695271/270600 would get you the changing column widths, and balancing the column heights from Lua shouldn't be that hard either. Although I can think of a hundred different edge cases with this, so probably easiest to just use multicol :)
Yeah, you'll probably need to make the package very configurable for this. At least it should be fairly easy to do this from Lua, where with TeX macros it would be borderline impossible. |
Hmmm, this code looks rather familiar :)
Just thinking about dealing with inserts in multiple columns gives me headache...
Yes, probably checking node's (sub)type covers several possible configurationwith few lines of code. What bothers me more now are "nested" lines. Especially in LaTeX, where tabular, minipage, array are all nested inside a vertical box inside a line or an equation. I thought about using similar approach to your column detecting code and analyze the the content of the lines while recording the horizontal shift, then if the first thing in the line is, say, tabulr, consider the original line as "fake line" and do the numbering according to the tabular rows while shifting the boxed numbers according to the shift recorded. There are also "fake" alignment which contains only rules, maybe they should not be numbered. |
Issue
lineno
seems to tricklua-widow-control
into thinking there are (many) nonexistent pages in the output. In the MWE below,lua-widow-control
complains about stuff on page 65 whereas the output has only 2 pages.Expected Behavior
I expected that
lua-widow-control
wouldn’t have this weird interaction withlineno
. Unfortunately, I can’t say if this is just a false alarm or if it actually preventslua-widow-control
from doing its job. (It definitely seems to be doing some job still.)Reproduction
Log File
Format
LaTeX
Distribution
TeX Live
Distribution Version
2023
Lua-widow-control Version
v3.0.0
Other Relevant Packages and Versions
No response
Other
No response
The text was updated successfully, but these errors were encountered: