Skip to content
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

Extra text underlined when underlining the first word after title of \paragraph{} #24

Open
GekkaSaori opened this issue Dec 22, 2024 · 4 comments
Assignees
Labels
bug Something isn't working long-term

Comments

@GekkaSaori
Copy link

Platform: Windows 10 23H2, TeXLive 2024, LuaHBTeX 1.18.0, Lua-UL v0.2.1.

MWE:

% !TeX TS-program = lualatex

\documentclass{article}
\usepackage{lua-ul}
\begin{document}
	\paragraph{1} \underLine{The} quick brown fox jumps over a lazy dog.
	
	\paragraph{2} \underline{The} quick brown fox jumps over a lazy dog.
\end{document}

Problem description: The space between the title of \paragraph{} and the word should be underlined was underlined unexpectedly (See screenshot below).

image

Expected behavior: Text underlined properly.

This is LuaHBTeX, Version 1.18.0 (TeX Live 2024)  (format=lualatex 2024.12.19)  23 DEC 2024 01:10
 restricted system commands enabled.
**document
(./document.tex
LaTeX2e <2024-11-01> patch level 1
L3 programming layer <2024-11-02>
Lua module: luaotfload 2024-02-14 v3.28 Lua based OpenType font support
Lua module: lualibs 2023-07-13 v2.76 ConTeXt Lua standard libraries.
Lua module: lualibs-extended 2023-07-13 v2.76 ConTeXt Lua libraries -- extended 
collection.
luaotfload | conf : Root cache directory is "C:/Users/11217/.texlive2024/texmf-v
ar/luatex-cache/generic/names".
luaotfload | init : Loading fontloader "fontloader-2023-12-28.lua" from kpse-res
olved path "c:/texlive/2024/texmf-dist/tex/luatex/luaotfload/fontloader-2023-12-
28.lua".
Lua-only attribute luaotfload@noligature = 1
luaotfload | init : Context OpenType loader version 3.134
Inserting `luaotfload.node_processor' in `pre_linebreak_filter'.
Inserting `luaotfload.node_processor' in `hpack_filter'.
Inserting `luaotfload.glyph_stream' in `glyph_stream_provider'.
Inserting `luaotfload.define_font' in `define_font'.
Lua-only attribute luaotfload_color_attribute = 2
luaotfload | conf : Root cache directory is "C:/Users/11217/.texlive2024/texmf-v
ar/luatex-cache/generic/names".
Inserting `luaotfload.harf.strip_prefix' in `find_opentype_file'.
Inserting `luaotfload.harf.strip_prefix' in `find_truetype_file'.
Removing  `luaotfload.glyph_stream' from `glyph_stream_provider'.
Inserting `luaotfload.harf.glyphstream' in `glyph_stream_provider'.
Inserting `luaotfload.harf.finalize_vlist' in `post_linebreak_filter'.
Inserting `luaotfload.harf.finalize_hlist' in `hpack_filter'.
Inserting `luaotfload.cleanup_files' in `wrapup_run'.
Inserting `luaotfload.harf.finalize_unicode' in `finish_pdffile'.
Inserting `luaotfload.glyphinfo' in `glyph_info'.
Lua-only attribute luaotfload.letterspace_done = 3
Inserting `luaotfload.aux.set_sscale_dimens' in `luaotfload.patch_font'.
Inserting `luaotfload.aux.set_font_index' in `luaotfload.patch_font'.
Inserting `luaotfload.aux.patch_cambria_domh' in `luaotfload.patch_font'.
Inserting `luaotfload.aux.fixup_fontdata' in `luaotfload.patch_font_unsafe'.
Inserting `luaotfload.aux.set_capheight' in `luaotfload.patch_font'.
Inserting `luaotfload.aux.set_xheight' in `luaotfload.patch_font'.
Inserting `luaotfload.rewrite_fontname' in `luaotfload.patch_font'.
Inserting `tracingstacklevels' in `input_level_string'. (c:/texlive/2024/texmf-
dist/tex/latex/base/article.cls
Document Class: article 2024/06/29 v1.4n Standard LaTeX document class
(c:/texlive/2024/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2024/06/29 v1.4n Standard LaTeX file (size option)
luaotfload | db : Font names database loaded from C:/Users/11217/.texlive2024/te
xmf-var/luatex-cache/generic/names/luaotfload-names.luc.gz)
\c@part=\count194
\c@section=\count195
\c@subsection=\count196
\c@subsubsection=\count197
\c@paragraph=\count198
\c@subparagraph=\count199
\c@figure=\count266
\c@table=\count267
\abovecaptionskip=\skip49
\belowcaptionskip=\skip50
\bibindent=\dimen140
)
(c:/texlive/2024/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty
Package: lua-ul 2024-02-26 v0.2.1 Underlining and related functionality for Lua
TeX
Lua function luaul.restore_everyhbox = 29
Lua function luaul.new_underline_type = 30
Lua function luaul.set_underline_func = 31
Lua function luaul.reset_underline_func = 32
Module luatexbase Info: Uninstalling kernel luatexbase code on input line 36
Inserting `add underlines to list' in `pre_append_to_vlist_filter'.
Inserting `add underlines to list' in `hpack_filter'.
Inserting `add underlines to list' in `vpack_filter'.
Lua function sw@slant = 33
\l__luaul_top_dim=\dimen141
\l__luaul_bottom_dim=\dimen142
\l__luaul_height_dim=\dimen143
)
(c:/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-luatex.def
File: l3backend-luatex.def 2024-05-08 L3 backend support: PDF output (LuaTeX)
\l__color_backend_stack_int=\count268
Inserting `l3color' in `luaotfload.parse_color'.
\l__pdf_internal_box=\box52
)
(./document.aux)
\openout1 = document.aux

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for TU/lmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 6.
LaTeX Font Info:    ... okay on input line 6.
Lua-only attribute luaul1 = 4
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 9.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 9.


[1

{c:/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./document.aux)
 ***********
LaTeX2e <2024-11-01> patch level 1
L3 programming layer <2024-11-02>
 ***********
)

Here is how much of LuaTeX's memory you used:
 552 strings out of 475630
 100000,552014 words of node,token memory allocated
 445 words of node memory still in use:
   3 hlist, 1 vlist, 2 rule, 3 glue, 3 kern, 1 glyph, 9 attribute, 49 glue_spec,
 8 attribute_list, 1 write nodes
   avail lists: 2:395,3:12,4:1,5:33,6:4,7:228,8:2,9:26
 23525 multiletter control sequences out of 65536+600000
 26 fonts using 1476743 bytes
 35i,5n,49p,145b,140s stack positions out of 10000i,1000n,20000p,200000b,200000s
<c:/texlive/2024/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf><c:/t
exlive/2024/texmf-dist/fonts/opentype/public/lm/lmroman10-bold.otf>
Output written on document.pdf (1 page, 7024 bytes).

PDF statistics: 22 PDF objects out of 1000 (max. 8388607)
 12 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)

@Udi-Fogiel
Copy link

The \paragrph command add the paragraph title using the \everypar primitive, a more minimal example would be

\documentclass{article}

\usepackage{lua-ul}
\begin{document}
\everypar{foo }

\underLine{The} quick brown fox jumps over a lazy dog.
\end{document}

image
What happens here is that the word foo is inserted when the paragraph starts, which happens to be
inside the group of \underLine command, so the nodes of foo has the undeline attribute.

A solution would be to start the paragraph before the group starts

\documentclass{article}
\usepackage{lua-ul}
\begin{document}
	\paragraph{1} \leavevmode\underLine{The} quick brown fox jumps over a lazy dog.
	
	\paragraph{2} \underline{The} quick brown fox jumps over a lazy dog.
\end{document}

image
If you want a less manual solution you can do the following

\documentclass{article}
\usepackage{lua-ul}
\AddToHook{cmd/underLine/before}{\leavevmode}
\begin{document}
	\paragraph{1} \underLine{The} quick brown fox jumps over a lazy dog.
	
	\paragraph{2} \underline{The} quick brown fox jumps over a lazy dog.
\end{document}

@zauguin zauguin self-assigned this Jan 22, 2025
@zauguin
Copy link
Owner

zauguin commented Jan 22, 2025

Sorry for the slow response. Sadly this will probably be a longer term issue since it's tricky to resolve. As Udi-Fogiel wrote the problem is that the paragraph heading gets added at \everypar and at that point having underlines active is expected. The cleanest solution is to use \leavevmode as suggested in the lua-ul commands, but this would break use-cases where a lua-ul command is applied outside of paragraphs (e.g. because it should be active for whole parts of documents). Also most solutions would break the usecase where someone actually wants to affect the paragraph number too.

@zauguin zauguin added bug Something isn't working long-term labels Jan 22, 2025
@Udi-Fogiel
Copy link

Udi-Fogiel commented Jan 22, 2025

@zauguin Isn't creating separate commands similar to \color vs \textcolor would solve that? i.e. if someone would want to affect whole parts of a document he can use \@underLine (if it was exposed).

@Udi-Fogiel
Copy link

The same happens with colors:

\documentclass{article}
\usepackage{color}% or luacolor
\begin{document}
	\paragraph{1} {\color{red} The} quick brown fox jumps over a lazy dog.
	
	\paragraph{2} \textcolor{red}{The} quick brown fox jumps over a lazy dog.
\end{document}

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working long-term
Projects
None yet
Development

No branches or pull requests

3 participants