컬러프레임 패키지는 다른 환경 내부에 있을 때 끝에 추가 수직 공간을 추가합니다.

컬러프레임 패키지는 다른 환경 내부에 있을 때 끝에 추가 수직 공간을 추가합니다.

패키지 colorframed(및 이전 버전 framed)는 다른 환경 내부에 수직 공간을 추가합니다.

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

이 문제를 해결할 수 있는 방법이 있나요?

답변1

들여쓰기 양을 제어하기 위해 선택적 매개변수를 허용하는 환경을 만들기 위해 환경 colorframed에 대한 코드를 살펴보고 snugshade*해킹했습니다 .quotedsnugshade*

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

이것은 음영 처리된 내용 자체가 목록인 경우 테스트되지 않았습니다.

음영처리된 환경

답변2

패키지를 사용하면 tcolorbox배경색 지정, 페이지 나누기 및 여백 조정을 한 번에 수행할 수 있습니다(필요한 경우 위와 아래 공간을 조정할 수 있음).

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

여기에 이미지 설명을 입력하세요

관련 정보