4

The two theorem styles below which differ at bodyfont style, give the same font style. Can someone help on this?

\documentclass[12pt,a4paper]{report}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{amsfonts,color,graphicx,xcolor}
\usepackage[english]{babel}
\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\scshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{red}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=cyan!20,
            linecolor=red!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep,
            skipbelow=\parsep }
]{myexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=myexamplestyle,
    name=EEEEE,
    numberwithin=section
    %qed=$\Box$
]{EE}

\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\itshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{cyan}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=green!20,
            linecolor=magenta!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep,
            skipbelow=\parsep }
]{myexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=myexamplestyle,
    name=DDDDDD,
    numberwithin=chapter
]{DD}
\begin{document}
\begin{EE}
Some text.
\end{EE}

\begin{DD}
The other text
\end{DD}
\end{document} 
  • What's the question? Avoiding the repetition of the style specification? – egreg Apr 29 '13 at 12:56
  • @Ahmad Omar I have shortened your title and moved the question in to the body of the question to better fit the style of this site. Please edit if the wording is not to your liking. – Andrew Swann Apr 29 '13 at 13:31
2

You need to give the two styles different names:

Sample output

\documentclass[12pt,a4paper]{report}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{amsfonts,color,graphicx,xcolor}
\usepackage[english]{babel}
\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\scshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{red}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=cyan!20,
            linecolor=red!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep }
]{myexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=myexamplestyle,
    name=EEEEE,
    numberwithin=section
    %qed=$\Box$
]{EE}

\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\itshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{cyan}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=green!20,
            linecolor=magenta!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep }
]{mysecondexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=mysecondexamplestyle,
    name=DDDDDD,
    numberwithin=chapter
]{DD}
\begin{document}
\begin{EE}
Some text.
\end{EE}

\begin{DD}
The other text
\end{DD}
\end{document}

In the above the first theoremstyle is labelled myexamplestyle as in your code, the second I have changed to mysecondexamplesytle to avoid overlap. Such renaming is not always necessary, but it is good practice. Testing examples shows that repeated declaration of the same style name behaves rather unpredictably.

Your example code fails to load the mdframed package. Adding this to the code removes some warnings. To get the round effect on the corners of the boxes you also need to specify tikz as a framemethod. Adding the line

\usepackage[framemethod=tikz]{mdframed}

then produces

Sample output rounded

which may be is more what you intended.

I have removed a repeated skipbelow in your mdframed specification. It is possible you meant one of these to be skipabove.

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.