1

I am using mdframed box, my problem is, when I use the value "roundcorner=5pt", the round corner is applied on all sides, I need it in the only the top ().

\documentclass{article}

\usepackage[framemethod=TikZ]{mdframed}
\newenvironment{Frame}[1][]{%
    \begin{mdframed}[%
        frametitle={#1},
        skipabove=\baselineskip plus 2pt minus 1pt,
        skipbelow=\baselineskip plus 2pt minus 1pt,
        linewidth=0.5pt,
        frametitlerule=true,
    backgroundcolor=yellow,
        roundcorner=5pt,
        frametitlebackgroundcolor=green
        
    ]%
}{%
    \end{mdframed}
}

\begin{document}
Text
\begin{Frame}[with Title]
    Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
\end{Frame}
\end{document}
5
  • 1
    Would you mind switching to tcolorbox instead of mdframed? With the former, you could use the approach shown here: tex.stackexchange.com/a/334704/134144
    – leandriis
    Feb 5 at 7:02
  • @leandriis tcolorbox have breaking issue
    – Shalu
    Feb 5 at 7:04
  • What kind of breaking issues?
    – leandriis
    Feb 5 at 7:05
  • @leandriis page overfull
    – Shalu
    Feb 5 at 7:06
  • 1
    Tcolorbox also offers means to allow a colored box to break across pages. Take a look at the breakable option.
    – leandriis
    Feb 5 at 7:07
3

I don't know what you want because your code didn't work for me, but something like this (and much more) can be done with tcolorbox:

enter image description here

\documentclass{article}

\usepackage[most]{tcolorbox}

\newtcolorbox{Frame}[2][]{%
    enhanced, breakable,
    title={#2},
    colback=yellow,
    colbacktitle=green,
    sharp corners=south,
    arc=5pt,
    #1
}

\begin{document}
Text
    \begin{Frame}{with title}
    Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
    \newline Text
\end{Frame}
\end{document}
0

With mdframed itself you can set rounded corners, set bottomline=false and draw the bottom line yourself without rounded corners using the secondextra key. With this key you can specify extra (e.g., TikZ) instructions for the final part of the frame.

Drawing a line at the bottom can be done with \path[draw=black,line width=0.5pt] (O)--(O-|P);, which I adapted from the file md-frame1.mdf that contains TikZ code for mdframed.

MWE:

\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\newenvironment{Frame}[1][]{%
    \begin{mdframed}[%
        frametitle={#1},
        skipabove=\baselineskip plus 2pt minus 1pt,
        skipbelow=\baselineskip plus 2pt minus 1pt,
        linewidth=0.5pt,
        frametitlerule=true,
        backgroundcolor=yellow,
        roundcorner=5pt,
        frametitlebackgroundcolor=green,
        bottomline=false,
        secondextra={\path[draw=black,line width=0.5pt] (O)--(O-|P);}
    ]%
}{%
    \end{mdframed}
}
\begin{document}
Text
\begin{Frame}[with Title]
\lipsum[1-5]
\end{Frame}
\end{document}

Result:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.