3

I'm looking for a way to create a new theorem without numbering. I found Theorem without numbering and tried the accepted answer, but I get the error "Command * already defined".

This is the code I'm using:

\documentclass[11pt]{article}

\usepackage{mdframed}

\newtheorem*{hulprule}{Rule settings}
\newenvironment{drule}[3]
    {\begin{mdframed}[backgroundcolor=lightgray]\begin{hulprule}\begin{enumerate}[-]
                    \item \textbf{Events}:{#1}
                    \item \textbf{Conditions}:{#2}
                    \item \textbf{Actions}:{#3}}
    {\end{enumerate}\end{hulprule}\end{mdframed}}

\begin{document}

\begin{drule}
        {test}
        {test}
        {test}
    \end{drule}

\end{document}

Strangely enough, the drule environment works perfectly without the *.

How can I solve this?

4
  • 1
    You have to load amsthm for \newtheorem*
    – egreg
    Dec 2, 2013 at 22:01
  • @egreg: Outch, overlooked that. Stupid. That's the solution, it works now! Post it as an answer and I'll accept it at once! :)
    – Jeroen
    Dec 2, 2013 at 22:03
  • Why an environment? It should be a command with three arguments.
    – egreg
    Dec 2, 2013 at 22:04
  • @egreg: Well, I didn't have the 3 arguments first (that's why I'm working with an environment), but as every enumeration has to start with those 3 words, I had to work with arguments. Maybe there's a better way to achieve this, but I'm a bit of a newbie... :)
    – Jeroen
    Dec 2, 2013 at 22:09

1 Answer 1

5

You're missing \usepackage{amsthm}. I'd improve the definition, though, with enumitem instead of enumerate:

\documentclass[11pt]{article}
\usepackage{amsthm,enumitem,xcolor}
\usepackage{mdframed}

\definecolor{lightgray}{gray}{0.9}

\newtheorem*{hulprule}{Rule settings}
\newenvironment{drule}[3]
 {\begin{mdframed}[backgroundcolor=lightgray]%
  \begin{hulprule}\leavevmode
  \begin{itemize}[label=\textbf{--},itemindent=-1em]
    \item \textbf{Events}: #1
    \item \textbf{Conditions}: #2
    \item \textbf{Actions}: #3}
 {\end{itemize}%
  \end{hulprule}%
  \end{mdframed}}

\begin{document}

\begin{drule}
  {test}
  {test}
  {test}
  \item something else
  \item another
\end{drule}

\end{document}

A simple hyphen should never be used for marking an item; over a grey background a dash becomes barely noticeable, so it's better to boldface it. Adjust the itemindent to suit.

enter image description here

1
  • That's absolutely perfect. You're immediately countering my next question about how I can start the enumeration after the 'Rule settings' title!
    – Jeroen
    Dec 2, 2013 at 22:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .