2

I'm using the mdframed package to draw a theorem command.

However, the option subtitleabovelinecolor of the subtitle frame is not taken into account, while the command subtitleabovelinewidth is.

Here is a MWE with the problem :

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage[framemethod=TikZ,xcolor]{mdframed}
\begin{document}
    \newmdenv[
        roundcorner=5pt,
        outerlinewidth=1.5pt,
        linecolor=red,
        subtitleabovelinecolor=red,
        subtitleabovelinewidth=1.5pt,
        subtitleaboveline=true,
        frametitle={Theorem},]{subtitleenv}
    \begin{subtitleenv}
        Some Text\ldots
        \mdfsubtitle{Notes}
            Some Text\ldots
    \end{subtitleenv}
\end{document}

Which produces this :

MWE output

I'm following the guidelines explained in the manual at page 11.

Any ideas where I'd be wrong ? I've tried modifying the order of the options, without success.

1
  • 2
    use tcolorbox instead of mdframed - it is much better. Dec 23 '19 at 9:51
2

This seems like a bug in the file md-frame-1.mdf.

The following MWE contains a locally usable fix that corrects the incorrect definitions for both the framesubtitleabove and the framesubtitlebelow lines of the framemethod=tikz. I have added annotations to the code showing what I replaced.

enter image description here

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage[framemethod=TikZ,xcolor]{mdframed}

\makeatletter

\def\mdf@drawsubtitleaboveline{%
 \rlap{%
  \hspace*{-\mdf@innerleftmargin@length}%
  \tikz\draw[mdfsubtitleaboverule](0,0) rectangle         %<----- replaced mdfsubsubtitleaboverule with mdfsubtitleaboverule 
     (\mdf@templength,\mdf@subtitleabovelinewidth@length);%
 }%
}
\def\mdf@drawsubtitlebelowline{%
 \rlap{%
  \hspace*{-\mdf@innerleftmargin@length}%
  \tikz\draw[mdfsubtitlebelowrule](0,0) rectangle      %<------ replaced mdfsubsubtitleaboverule with mdfsubtitlebelowrule
     (\mdf@templength,\mdf@subtitlebelowlinewidth@length);%
 }%
}

\makeatother

    \newmdenv[
        roundcorner=5pt,
        outerlinewidth=1.5pt,
        linecolor=red,
        subtitleaboveline=true,
        subtitleabovelinecolor=red,
        subtitleabovelinewidth=1.5pt,
        subtitlebelowlinecolor=blue,
        subtitlebelowlinewidth=1.5pt,
        subtitlebelowline=true,
        frametitle={Theorem},]{subtitleenv}

\begin{document}




    \begin{subtitleenv}
        Some Text\ldots
        \mdfsubtitle{Notes}
            Some Text\ldots
    \end{subtitleenv}
\end{document}
2
0

As suggested by @ulrike-fischer, a solution can be achieved by using the tcolorbox package.

Here is a MWE :

\documentclass[]{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage[breakable,skins,xparse]{tcolorbox}

\begin{document}

\tcbset{colback=white,
    colframe=red!75!black,
    fonttitle=\bfseries,
}
\begin{tcolorbox}[title=Theorem,enhanced,breakable] 
    Some Text \dots
    \tcbsubtitle[before skip=\baselineskip]{Notes}
    Some Text\dots          
\end{tcolorbox}


\end{document}

And the output is this :

MWE output

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.