1

Consider the code

\documentclass{article}
 \usepackage[framemethod=tikz]{mdframed}
 \usepackage{lipsum}
 \parindent 10pt
 
\begin{document}
\thispagestyle{empty}
\lipsum[3]
\begin{mdframed}[hidealllines=true,backgroundcolor=red!20,innerleftmargin=1.5pt,innerrightmargin=1.5pt,leftmargin=-1.5pt,rightmargin=-1.5pt]
\lipsum[13]
\end{mdframed}
\end{document}

which produces the output

enter image description here

Though I have specified \parindent 10pt, the colorized (margin adjusted) paragraph is not indented. I suppose that this should not come as a surprise; however, I have not been able to figure out an efficient way to have such paragraphs indented. Placing \hskip 10pt immediately prior to \lipsum[13] works---but I don't want to have to do this multiple times throughout an actual document.

QUESTION: How may I specify in the code that a paragraph which immediately follows \begin{mdframed}[hidealllines=true,backgroundcolor=red!20,innerleftmargin=1.5pt,innerrightmargin=1.5pt,leftmargin=-1.5pt,rightmargin=-1.5pt] should be indented, say 10pt?

Thank you.

1 Answer 1

1

If you accept to change to tcolorbox, this could be a solution:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\parindent 10pt
 
 \usepackage[most]{tcolorbox}
\newtcolorbox{mybox}[1][]{
enhanced, sharp corners, boxrule=0pt, boxsep=0pt, left=0pt, right=0pt, top=1.5pt, bottom=1.5pt, before upper=\hspace{10pt}, colback=red!20, #1
}

\begin{document}
\thispagestyle{empty}
\lipsum[3]
\begin{mdframed}[hidealllines=true,backgroundcolor=red!20,innerleftmargin=1.5pt,innerrightmargin=1.5pt,leftmargin=-1.5pt,rightmargin=-1.5pt]
\lipsum[13]
\end{mdframed}

\begin{mybox}
\lipsum[13]
\end{mybox}

\begin{mybox}[colback=green!20, boxsep=2mm]
\lipsum[13]
\end{mybox}
\end{document}

enter image description here

1
  • Many thanks for your helpful answer.
    – DDS
    Commented Jul 12, 2022 at 14:28

You must log in to answer this question.

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