Closed T-F-S closed 1 year ago
@T-F-S Thanks for reporting this. I don't understand the lineno code well enough to know how to fix this, but I'd be happy to accept a complete patch if you have one.
Closing this issue as I believe this has been resolved by https://github.com/T-F-S/tcolorbox/issues/183; if that's not correct please let me know.
This is issue is reproducible without tcolorbox
. It's really about handling a special value of \prevdepth
(-1000pt
) set by \nointerlineskip
.
Default | Using \linenumbers |
My attempt https://github.com/T-F-S/tcolorbox/issues/183#issuecomment-1169406409 |
Frank's patch https://github.com/T-F-S/tcolorbox/issues/183#issuecomment-1169682868 |
---|---|---|---|
```tex \documentclass{article} \usepackage{lineno} \usepackage{multicol} \makeatletter \def\muzimuzhiPATCH{% \def\@LN@depthbox{% % \@tempdima is set to \prevdepth before \ifdim\@tempdima>-1000pt\relax \dp\@tempboxa=\@tempdima \fi \nointerlineskip \ifdim\@tempdima>-1000pt\relax \kern-\@tempdima % \else % is this needed? % \kern-\dp\@tempboxa \fi \box\@tempboxa}} \def\FrankPATCH{% \def\@LN@depthbox{% \ifdim\@tempdima = -1000pt % \nointerlineskip is already set so we don't need set it again (and we shouldn't back up) \else \dp\@tempboxa=\@tempdima \nointerlineskip \kern-\@tempdima \fi \box\@tempboxa}} \makeatother \begin{document} \def\testWithPrevdepth#1{{% \noindent\texttt{\UseName{str_if_empty:nTF}{#1}{default}{\detokenize{#1}}}\par before text\par #1% \noindent\vskip0pt % any vskip triggers the problem content\par after text\par}\medskip} \def\tests#1{{#1% \testWithPrevdepth{} \testWithPrevdepth{\prevdepth=10pt} \testWithPrevdepth{\prevdepth=-10pt} \testWithPrevdepth{\prevdepth=-100pt} \testWithPrevdepth{\prevdepth=-1000pt} \newpage }} \tests{} \tests{\linenumbers} \tests{\linenumbers\muzimuzhiPATCH} \tests{\linenumbers\FrankPATCH} \end{document} ```
Thanks @muzimuzhi for the examples. I've applied Frank's patch to lineno.sty
. Could you please confirm that this version of lineno.sty
fixes the issue and behaves as you expect?
Just one concern: the inter-line skip is actually altered by \linenumbers
. Is this OK?
If that's OK, then here's a similar patch for \internallinenumberpar
(used by user command \internallinenumbers
) and bframe
env:
diff --git a/lineno.sty b/lineno.sty
index 9fb0be8..1107b4c 100644
--- a/lineno.sty
+++ b/lineno.sty
@@ -2725,10 +2725,14 @@ Macro file lineno.sty for LaTeX: attach line numbers, refer to them.
\begingroup
\c@internallinenumbers\prevgraf
\setbox\@tempboxa\hbox{\vbox{\makeinternalLinenumbers}}%
- \dp\@tempboxa\prevdepth
\ht\@tempboxa\z@
- \nobreak\vskip-\prevdepth
- \nointerlineskip\box\@tempboxa
+ \ifdim\prevdepth=-1000pt
+ \else
+ \dp\@tempboxa\prevdepth
+ \nobreak\vskip-\prevdepth
+ \nointerlineskip
+ \fi
+ \box\@tempboxa
\endgroup
\fi\fi
}
@@ -2866,7 +2870,9 @@ Macro file lineno.sty for LaTeX: attach line numbers, refer to them.
\def\makeLineNumber{\copy\bframebox\hss}%
}
{\par
- \kern-\prevdepth
+ \ifdim\prevdepth=-1000pt \else
+ \kern-\prevdepth
+ \fi
\kern\bframesep
\nointerlineskip
\@tempdima\textwidth
Default | Using \linenumbers + Frank's patch extended |
---|---|
On next column/page On third column/page |
```tex \documentclass[twocolumn]{article} \usepackage{lineno} \makeatletter \def\FrankPATCH{% \def\@LN@depthbox{% \ifdim\@tempdima=-1000pt % \nointerlineskip is already set so we don't need set it again (and we shouldn't back up) \else \dp\@tempboxa=\@tempdima \nointerlineskip \kern-\@tempdima \fi \box\@tempboxa}% \renewcommand\internallinenumberpar{% \ifvmode\@@@par\else\ifinner\@@@par\else\@@@par \begingroup \c@internallinenumbers\prevgraf \setbox\@tempboxa\hbox{\vbox{\makeinternalLinenumbers}}% \ht\@tempboxa\z@ \ifdim\prevdepth=-1000pt \else \dp\@tempboxa\prevdepth \nobreak\vskip-\prevdepth \nointerlineskip \fi \box\@tempboxa \endgroup \fi\fi } \renewcommand\endbframe{% \par \ifdim\prevdepth=-1000pt \else \kern-\prevdepth \fi \kern\bframesep \nointerlineskip % \textwidth is proposed to be replaced with \columnwidth in % https://github.com/latex-lineno/lineno/pull/8 \@tempdima\textwidth \advance\@tempdima 2\bframesep \hbox{\hskip-\bframesep \vrule\@width\@tempdima\@height\bframerule\@depth\z@}% } } \makeatother % just tweak % see full fix in https://github.com/latex-lineno/lineno/pull/8 \AtBeginDocument{% \textwidth=\dimexpr\columnwidth-10pt } \raggedbottom \begin{document} \def\testWithPrevdepth#1{{% \noindent\texttt{\UseName{str_if_empty:nTF}{#1}{default}{\detokenize{#1}}}\par before text\par #1% \noindent\vskip0pt % any vskip triggers the problem content\par after text\par}} \def\tests#1{{#1% \testWithPrevdepth{} % \testWithPrevdepth{\prevdepth=10pt} \testWithPrevdepth{\prevdepth=-10pt} % \testWithPrevdepth{\prevdepth=-100pt} \testWithPrevdepth{\prevdepth=-1000pt} \begin{center} \UseName{tl_if_in:nnT}{#1}{\linenumbers}{\internallinenumbers}% \testWithPrevdepth{} \end{center} \begin{center} \UseName{tl_if_in:nnT}{#1}{\linenumbers}{\internallinenumbers}% \testWithPrevdepth{\prevdepth=-10pt} \end{center} \begin{center} \UseName{tl_if_in:nnT}{#1}{\linenumbers}{\internallinenumbers}% \testWithPrevdepth{\prevdepth=-1000pt} \end{center} \begin{bframe} foo\par \nointerlineskip \end{bframe} \begin{bframe} \testWithPrevdepth{\prevdepth=-1000pt} \end{bframe} \newpage }} \tests{\linenumbers\FrankPATCH} \tests{} \end{document} ```
Thanks again @muzimuzhi I've applied the additional patches. Can you please check the latest version of lineno.sty
is working correctly?
I couldn't work out how to remove the extra inter-line skip. It's probably fine as is, so I may leave it for now.
I've submitted a new release of linono
(v5.3) to CTAN with these changes.
Ignoring the restored inter-line skip, I can confirm lineno
v5.3 works correctly. Thank you for this update and sorry for my late response.
In https://github.com/T-F-S/tcolorbox/issues/183 a problem in interaction between
tcolorbox
andlineno
was reported.The problem is nailed down to a
\prevdepth
problem withlineno
in https://github.com/T-F-S/tcolorbox/issues/183#issuecomment-1169385556:Also, an incomplete patch for
lineno
is provided in https://github.com/T-F-S/tcolorbox/issues/183#issuecomment-1169406409