3

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 Answers 2

3

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} 
4
  • Be careful, with this hack, you'll also have to "re-define" \begin{theorem*}. Commented May 21, 2014 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 Commented May 22, 2014 at 17:43
  • @Colas: Fixed to handle using it without the optional environment (as per your answer). Also defined theorem* variant. Commented May 23, 2014 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 Commented May 23, 2014 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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.