缩进和标记段落

缩进和标记段落

我需要一个环境来缩进一个或多个段落,并在与段落高度匹配的正常缩进级别上绘制一条灰线。这就是我想到的:

\documentclass{minimal}

\usepackage{colortbl}

\newenvironment{note}{
  \begin{tabular}{>{\columncolor[gray]{0.8}}p{0.1cm}p{0.2cm}p{\dimexpr \textwidth - 1.1cm - 4\tabcolsep}}
    & &
}{
  \end{tabular}
}

\begin{document}
  Normal text

  \begin{note}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
    commodo consequat.
  \end{note}

  More normal text
\end{document}

渲染结果为:

虽然线条本身看起来不错,但垂直间距很糟糕。我当然可以\vspace在环境中插入一些,但我认为整个方法tabular似乎不是最好的方法。有没有更好的解决方案?

答案1

如果我理解得没错的话,你想要的环境的基础已经存在了:它leftbar来自framed包。以下是两种修补方法:

\documentclass{article}
\usepackage{framed} %
 \usepackage[table, svgnames]{xcolor}

\newenvironment{note}{
\leavevmode \begin{tabular}{>{\columncolor[gray]{0.8}}p{0.1cm}p{0.2cm}p{\dimexpr \textwidth - 1.1cm - 4\tabcolsep}}
    & &
}{
  \end{tabular}
\vskip\topsep}


        \renewenvironment{leftbar}{%
        \def\FrameCommand{{\color{Gainsboro}\vrule width 3pt} \hspace{\dimexpr\parindent-3pt-\fontdimen2\font\relax}}%
        \MakeFramed {\advance\hsize-\width \FrameRestore}\parindent=0pt}%
        {\endMakeFramed}

        \newenvironment{myleftbar}{%
        \def\FrameCommand{{\hskip1em\color{Gainsboro}\vrule width 3pt} \hspace{3pt}}%
        \MakeFramed {\advance\hsize-\width \FrameRestore}\parindent =0pt}%
        {\endMakeFramed}

\begin{document}

  Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text.
  \begin{leftbar}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
    commodo consequat.
  \end{leftbar}
 Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text.
  \begin{myleftbar}%
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
    commodo consequat.
  \end{myleftbar}

  More normal text. More normal text. More normal text. More normal text. More normal text. More normal text. More normal text. More normal text.

  \end{document} 

在此处输入图片描述

相关内容