多段文本的颜色框

多段文本的颜色框

我调整解决方案设置 fcolorbox 的宽度对于多段落声明 - 应该有一个包含多个段落的统一颜色框:

\documentclass{beamer}
\usepackage{xcolor}
\usepackage{xparse}
\NewDocumentCommand{\framecolorbox}{oommm}
 {% #1 = width (optional)                                                                                                                                                        
  % #2 = inner alignment (optional)                                                                                                                                              
  % #3 = frame color                                                                                                                                                             
  % #4 = background color                                                                                                                                                        
  % #5 = text                                                                                                                                                                    
  \IfValueTF{#1}
   {%                                                                                                                                                                            
    \IfValueTF{#2}
     {\fcolorbox{#3}{#4}{\makebox[#1][#2]{#5}}}
     {\fcolorbox{#3}{#4}{\makebox[#1]{#5}}}%                                                                                                                                     
   }
   {\fcolorbox{#3}{#4}{#5}}%                                                                                                                                                     
 }
 \begin{document}
     \framecolorbox[4cm]{blue}{blue!40}{%                                                                                                                                        
       what do I

       do here?
     }
\end{document}

编译失败:

Runaway argument?
{what do I 
! Paragraph ended before \framecolorbox  was complete.
<to be read again> 
                   \par 
l.21 
     
? 

怎么修?

答案1

如果您只需要colorbox带有自动分页符的某些段落,那么使用framed.sty和来实现就很容易了MWE

\usepackage{xcolor}
\usepackage{framed}

\colorlet{shadedcolor}{cyan!10}

\begin{document}

\begin{shaded}
....

...
\end{shaded}

相关内容