以下 MWE 的结果:
\documentclass{book}
\usepackage{lipsum}
\usepackage[left, pagewise]{lineno}
\usepackage[most]{tcolorbox}
\newtcolorbox{foo}[1][]{
blanker,
breakable,
left=3mm, right=3mm, top=1mm, bottom=1mm,
borderline vertical={5pt}{0pt}{green},
before upper=\indent,
parbox=false,
#1
}
\begin{document}
%\linenumbers
\chapter{Foo bar}
\lipsum[1-4]
\begin{center}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\end{center}
\begin{foo}[oversize]
\lipsum[1-5]
\end{foo}
\lipsum[1-4]
\end{document}
这是
但仅仅添加\linenumbers
会破坏结果
我能做些什么?
答案1
没有 parbox 选项,并且有来自的修复https://github.com/TFS/tcolorbox/issues/183它似乎有效(或多或少,这些框算作一行)。
\documentclass{book}
\usepackage{lipsum}
\usepackage[left, pagewise]{lineno}
\usepackage[most]{tcolorbox}
\newtcolorbox{foo}[1][]{
blanker,
breakable,
left=3mm, right=3mm, top=1mm, bottom=1mm,
borderline vertical={5pt}{0pt}{green},
before upper=\indent,
%parbox=false,
#1
}
\makeatletter
\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}
\linenumbers
\chapter{Foo bar}
\lipsum[1-4]
\begin{center}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\end{center}
\begin{foo}[oversize]
\lipsum[1-5]
\end{foo}
\lipsum[1-4]
\end{document}