我想调整答案这里在左侧(框内)插入行号——就像tcolorbox
包裹中的清单一样。
我也尝试在命令中添加可选的行数参数newtcolorbox
,但是没有起到作用,最后只能使用粗制滥造的手册vspace
。
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}
\usepackage{blindtext}
\usepackage{calc}
\newtcolorbox{notebook}{
enhanced,
breakable,
colback=green!10,
colframe=green!65!black,
left=.7in,
underlay={%
\begin{tcbclipinterior}
%\shade[inner color=green!80!yellow,outer color=yellow!10!white]
%(interior.north west) circle (2cm);
\draw[help lines, ystep=\baselineskip, xstep=\linewidth,
shift={(interior.north west)}](interior.south west) grid (interior.north east);
\draw[help lines] ([xshift=.5in]interior.north west)--
([xshift=.5in]interior.south west);
\end{tcbclipinterior}}
}
\usepackage{lineno}
\begin{document}
\blindtext[1]
\begin{notebook}
\blindtext[3]
\end{notebook}
\begin{notebook}
\vspace{20\baselineskip}
\linenumbers
\end{notebook}
\end{document}
答案1
可能我误解了你的问题,但你可以添加一个可选参数,使用插入空行before upper
。
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}
\usepackage{blindtext}
\usepackage{calc}
\newtcolorbox{notebook}[1][0]{
enhanced,
breakable,
colback=green!10,
colframe=green!65!black,
left=.7in,
underlay={%
\begin{tcbclipinterior}
%\shade[inner color=green!80!yellow,outer color=yellow!10!white]
%(interior.north west) circle (2cm);
\draw[help lines, ystep=\baselineskip, xstep=\linewidth,
shift={(interior.north west)}](interior.south west) grid (interior.north east);
\draw[help lines] ([xshift=.5in]interior.north west)--
([xshift=.5in]interior.south west);
\end{tcbclipinterior}},
before upper=\vspace{#1\baselineskip}
}
\usepackage{lineno}
\begin{document}
\blindtext[1]
\begin{notebook}
\blindtext[3]
\end{notebook}
\begin{notebook}[20]
\end{notebook}
\end{document}
附录:至于你的额外要求:以下是类似这样的内容(部分灵感来自这个问题)。
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}
\usepackage{blindtext}
\usepackage{calc}
\newtcolorbox{notebook}[1][0]{
enhanced,
breakable,
colback=green!10,
colframe=green!65!black,
left=.7in,
underlay={%
\begin{tcbclipinterior}
%\shade[inner color=green!80!yellow,outer color=yellow!10!white]
%(interior.north west) circle (2cm);
\draw[help lines, ystep=\baselineskip, xstep=\linewidth,
shift={(interior.north west)}](interior.south west) grid (interior.north east);
\draw[help lines] ([xshift=.5in]interior.north west)--
([xshift=.5in]interior.south west);
\end{tcbclipinterior}},
before upper={\ifnum#1>0
\begin{internallinenumbers}\setcounter{linenumber}{1}
\foreach \X in {1,...,#1}
{~\par}
\end{internallinenumbers}
\fi
}}
\usepackage{lineno}
\begin{document}
\blindtext[1]
\begin{notebook}
\blindtext[3]
\end{notebook}
\begin{notebook}[20]
\end{notebook}
\begin{notebook}[20]
\end{notebook}
\end{document}