2

The classical case

With the classical \newtheorem command of amsthm, one gets the following result for optional arguments: enter image description here from this code

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}

\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem}

\end{document}

The mdframed case

I would like to get a similar result with mdframed:the optional argument between brackets, but no change of font and no dot at the end. But by default, here is what I get:

enter image description here

from the code

\documentclass{article}
\usepackage{mdframed}

\mdfdefinestyle{myFramedTheoremStyle}{%
frametitlealignment=\raggedright,
linecolor=red,
linewidth=4pt,
innertopmargin=0pt,
innerbottommargin=10pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
frametitleaboveskip=5pt,
skipbelow=0pt,
font=\itshape
}

\mdtheorem[style=myFramedTheoremStyle]{theorem}{Theorem}

\begin{document}

\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem}

\end{document}

What I have found so far

In the documentation, I have found the following options (of the \mdfdefinestyle command):

theoremseparator, theoremtitlefont and theoremspace

but there seems to be to attribute for defining what comes after the optional argument. I am looking for an option of the \mdfdefinestyle command which could be called theoremtextafter.

My question

I hope something like that exists. Do you know if it is the case? If not, is it possible to find an easy solution?

Thank you.

2

I don't know the official way of doing it, but here is a hack that does the job which:

  • applies theoremtitlefont=\normalfont to get the correct font in the title
  • renames the mdframed theorem to be MDtheorem, and
  • creates a \newenvironment called theorem which inserts the desired ( and ) to the theorem name before passing it on to the MDtheorem.
  • creates a \newenvironment called theorem* to provide the same functionality without the numbering.

enter image description here

Notes:

  • For the starred variant theorem* the mdframe style theoremtitlefont=\normalfont, did not seem sufficient so had to add a manual \normalfont.

Code:

\documentclass{article}
\usepackage{mdframed}

\mdfdefinestyle{myFramedTheoremStyle}{%
    frametitlealignment=\raggedright,
    linecolor=red,
    linewidth=4pt,
    innertopmargin=0pt,
    innerbottommargin=10pt,
    innerleftmargin=10pt,
    innerrightmargin=10pt,
    frametitleaboveskip=5pt,
    skipbelow=0pt,
    theoremtitlefont=\normalfont,
    font=\itshape
}

\mdtheorem[style=myFramedTheoremStyle]{MDtheorem}{Theorem}
\newcommand*{\Title}{}
\newenvironment{theorem}[1][]{%
    \ifstrempty{#1}{\begin{MDtheorem}}{\begin{MDtheorem}[(#1)]}%
}{%
    \end{MDtheorem}%
}%

\newenvironment{theorem*}[1][]{%
    % Required `\normalfont` in `MDtheorem*`, but not in the `MDtheorem` environment
    \ifstrempty{#1}{\begin{MDtheorem*}}{\begin{MDtheorem*}[\normalfont(#1)]}%
}{%
    \end{MDtheorem*}%
}%


\begin{document}

\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem}

\begin{theorem}
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem}

\begin{theorem*}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem*}

\begin{theorem*}
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem*}

\end{document}
  • Be careful, with this hack, you'll also have to "re-define" \begin{theorem*}. – Colas May 21 '14 at 12:05
  • Your hack does not work, unfortunately... If you type \begin{theorem} Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. \end{theorem} you will still have the : after Theorem – Colas May 22 '14 at 17:43
  • @Colas: Fixed to handle using it without the optional environment (as per your answer). Also defined theorem* variant. – Peter Grill May 23 '14 at 21:41
  • I found a bug in mdframed, related to this issue of optional arguments. You might be interested, tex.stackexchange.com/q/179790/8323 – Colas May 23 '14 at 22:43
0

Based on Peter's answer,

\documentclass{article}
\usepackage{mdframed}

\mdfdefinestyle{myFramedTheoremStyle}{%
frametitlealignment=\raggedright,
linecolor=red,
linewidth=4pt,
innertopmargin=0pt,
innerbottommargin=10pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
frametitleaboveskip=5pt,
skipbelow=0pt,
theoremtitlefont=\normalfont,
font=\itshape
}

\mdtheorem[style=myFramedTheoremStyle]{MDtheorem}{Theorem}
\newcommand*{\Title}{}
\newenvironment{theorem}[1][]{%
    \ifstrempty{#1}{\begin{MDtheorem}}%
    {\begin{MDtheorem}[(#1)]}
}{%
    \end{MDtheorem}%
}%

\begin{document}

\begin{theorem}[Riemann]
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem}

\begin{theorem}
Let $X$... Nulla egestas congue ullamcorper. Suspendisse id dictum est. Quisque ut urna lorem. Sed non aliquet sem, quis sollicitudin ante. 
\end{theorem}

\end{document}

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.