1

I need an environment that indents one or more paragraphs and draws a gray line at the normal indentation level that matches the paragraph in height. This is what I came up with:

\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}

This renders:

While the line itself looks fine, the vertical spacing is awful. I can of course insert some \vspace in the environment, but I think the whole approach with the tabular does not seem the best way to do this. Is there a better solution?

1
3

The basis of the environment you want already exists, if I've well understood: it's leftbar from the framed package. Here are two ways of patching it:

\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} 

enter image description here

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.