1

I adapt the solution in Set the width of a fcolorbox for a multiparagraph statement - there should be a uniform colour box encompassing multiple paragraphs:

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

The compilation fails:

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

How to fix?

3
  • 3
    \fcolorbox{blue}{green}{\parbox{5cm}{some text here}} Commented Oct 25, 2021 at 7:35
  • @DavidCarlisle, your solution works. Caveat - you need to break paragraph with `\` instead of double <kbd>Enter</kbd>.
    – Viesturs
    Commented Oct 26, 2021 at 6:18
  • \\ never ends a paragragh, just forces a newline, but you can use \endgraf Commented Oct 26, 2021 at 7:51

1 Answer 1

1

If you need just a colorbox with some paragraph along with auto pagebreak, then it's so easy to achieve with the use of framed.sty and the MWE is:

\usepackage{xcolor}
\usepackage{framed}

\colorlet{shadedcolor}{cyan!10}

\begin{document}

\begin{shaded}
....

...
\end{shaded}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .