在段落两边添加垂直线

在段落两边添加垂直线

如何在段落的每一侧添加垂直线?

为了说明起见,我需要的是:

 some paragraphs...

|My paragraph begins|
|here and goes like |
|this... ~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
--------------------- <- Here is a page break
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~|
|The paragraph ends |
|here.              |

Some other paragraphs...

我无法使用任何表格或装箱命令,因为它们不允许在里面分页。

提前致谢...

答案1

您可以使用mdframed包;一个小例子:

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\newmdenv[
  topline=false,
  bottomline=false,
  skipabove=\topsep,
  skipbelow=\topsep
]{siderules}

\begin{document}

\lipsum[4]
\begin{siderules}
\lipsum[1-5]
\end{siderules}
\lipsum[4]

\end{document}

在此处输入图片描述

以下是将规则放在边距中的简单修改(现在环境内的文本宽度等于默认的 \textwidth):

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\newmdenv[
  topline=false,
  bottomline=false,
  skipabove=\topsep,
  skipbelow=\topsep,
  leftmargin=-10pt,
  rightmargin=-10pt,
  innertopmargin=0pt,
  innerbottommargin=0pt
]{siderules}

\begin{document}

\lipsum[4]
\begin{siderules}
\lipsum[1-5]
\end{siderules}
\lipsum[4]

\end{document}

在此处输入图片描述

答案2

结果与 Gonzalo 的答案类似,但tcolorbox

\documentclass{article}
\usepackage{lipsum}% just to generate text for the example

\usepackage[most]{tcolorbox}

\newtcolorbox{tcbsiderules}[1][]{blanker, breakable, 
     left=3mm, right=3mm, top=1mm, bottom=1mm,
     borderline vertical={1pt}{0pt}{black},
     before upper=\indent, parbox=false, #1}


\begin{document}

\lipsum[1]
\begin{tcbsiderules}[oversize]
\lipsum[2-4]
\end{tcbsiderules}
\begin{tcbsiderules}
\lipsum[5-7]
\end{tcbsiderules}
\lipsum[8]

\end{document}

在此处输入图片描述

相关内容