El paquete con marco de color agrega espacio vertical adicional al final cuando se encuentra dentro de otro entorno.

El paquete con marco de color agrega espacio vertical adicional al final cuando se encuentra dentro de otro entorno.

El colorframedpaquete (y su predecesor framed) agrega espacio vertical adicional cuando se encuentra dentro de otro ambiente.

 \documentclass{article}
 \usepackage[dvipsnames]{xcolor}
 \usepackage{colorframed}
 \colorlet{shadecolor}{lightgray}

\begin{document}

This is text before quotation, but it must be longer than one line for comparison purposes.
\begin{snugshade*}
Purely fictional thinking leads to testing text inside shaded text environments.
\end{snugshade*}
This is text between quotation, but it must be longer than one line for comparison purposes.
\begin{quotation}\begin{snugshade*}
Purely fictional thinking leads to testing text inside shaded text environments.
\end{snugshade*}\end{quotation}
This is text after quotations, but it must be longer than one line for comparison purposes.

\end{document}

Cualquier forma de arreglar esto?

Respuesta1

Busqué colorframedel código del snugshade*entorno y lo pirateé para crear un quotedsnugshade*entorno que admitiera un parámetro opcional para controlar la cantidad de sangría.

\documentclass{article}
 \usepackage[dvipsnames]{xcolor}
 \usepackage{colorframed}
 \colorlet{shadecolor}{lightgray}

\makeatletter
\newenvironment{quotedsnugshade*}[1][2em]{%
  \def\FrameCommand##1{\hskip\@totalleftmargin 
  \colorframedcolorbox{shadecolor}{##1}%
      \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
  \MakeFramed {\advance\hsize-\width
\advance\hsize-2\dimexpr#1\relax    %%% ADDED 
\@totalleftmargin\dimexpr#1\relax   %%% ADDED
\linewidth\hsize
    \advance\labelsep\fboxsep
    \@setminipage}%
 }{\par\unskip\@minipagefalse\endMakeFramed}
\makeatother
\begin{document}


This is text before quotations, but it must be longer than one line for comparison purposes.
\begin{quotedsnugshade*}
Purely fictional thinking leads to testing text inside shaded text environments.
\end{quotedsnugshade*}
This is text after quotations, but it must be longer than one line for comparison purposes.
\begin{quotation}
  Purely fictional thinking leads to testing text inside quotation environment.
\end{quotation}
This is text after quotations, but it must be longer than one line for comparison purposes.
\begin{quotedsnugshade*}[2cm]
Purely fictional thinking leads to testing text inside shaded text environments.
\end{quotedsnugshade*}
\noindent\rule{2cm}{1pt}\dotfill margins are 2cm each\dotfill\rule{2cm}{1pt}

\end{document}

Tenga en cuenta que esto no se prueba con el contenido del elemento sombreado siendo en sí mismo una lista.

ambientes sombreados

Respuesta2

Con el tcolorboxpaquete puedes tener un fondo de color, saltos de página y márgenes ajustados, todo a la vez (el espacio arriba y abajo se puede ajustar si es necesario):

\documentclass{article}

\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\newtcolorbox{quack}[1][]{enhanced,breakable,frame hidden,colback=lightgray,sharp corners,size=small,left skip=1cm,right skip=1cm,#1}

\begin{document}

This is text between quotation, but it must be longer than one line for comparison purposes.
\begin{quack}
Purely fictional thinking leads to testing text inside shaded text environments.
\end{quack}
This is text after quotations, but it must be longer than one line for comparison purposes.

\end{document}

ingrese la descripción de la imagen aquí

información relacionada