Math & ScienceCustomized theorems with ntheorem and tikZ

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
elfangor
Posts: 2
Joined: Thu Nov 04, 2010 1:21 pm

Customized theorems with ntheorem and tikZ

Post by elfangor »

Hello,


I'm trying to adjust ntheorem such that I get my theorems as in the attachment.
Screenshot-3.png
Screenshot-3.png (8.2 KiB) Viewed 5032 times
I haven't succeeded at this because \theoremframecommand only take one argument and not two. (In my code, Theorem 1 is below the statement of the theorem)

Here is my preamble

Code: Select all


\usepackage[utf8x]{inputenc}
\usepackage[dutch]{babel}

\usepackage{graphicx,textpos, a4wide}
\usepackage[svgnames]{xcolor}
\usepackage{helvet, amssymb}

\usepackage{tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations}



\usepackage{framed}
\usepackage[framed, amsthm]{ntheorem}


\theoremclass{Theorem}
\theoremstyle{empty}
 \newcommand{\thmbox}[1]{
  \tikzstyle{thmbox} = [rectangle, rounded corners, draw=black, fill=Gray!20, inner sep=15pt, drop shadow={fill=black, opacity=.5}]%
  \tikzstyle{fancytitle} =[fill=white, text=black, rectangle, rounded corners, draw= black]%
  \noindent%
  \begin{tikzpicture}%
    \node [thmbox] (box){%
      \begin{minipage}{.91\textwidth}%
        \textit{#1}%
      \end{minipage}%
    };%
  \node[fancytitle, right=10pt] at (box.north west) {\textbf{Theorem 1}%
    };%
    \end{tikzpicture}}
 
\def\theoremframecommand{\thmbox}
\newshadedtheorem{theorem}{Theorem}
Are there ways to put the Theorem \arabic{theorem} nicely where it belongs? (I also want to put the name of the theorem in that box, so just by replacing "Theorem 1" by "Theorem \arabic {theorem}" will not do the trick.


And also, why do I need to use a newshadedtheorem statement for my framedtheorem instead of newframedtheorem. It doesn't seem right...

Greetz,
Elfangor

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

Customized theorems with ntheorem and tikZ

Post by ignasi »

next code worked for me. I just replaced \textbf{Theorem 1} with \textbf{Theorem \thetheorem}.

Hope it helps.

Ignasi

Code: Select all

\documentclass{article}

%\usepackage[utf8x]{inputenc}
%\usepackage[dutch]{babel}

\usepackage{graphicx,textpos, a4wide}
\usepackage[svgnames]{xcolor}
\usepackage{helvet, amssymb}

\usepackage{tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations}

\usepackage{framed}
\usepackage[framed, amsthm]{ntheorem}

\theoremclass{Theorem}
\theoremstyle{empty}
\newcommand{\thmbox}[1]{
  \tikzstyle{thmbox} = [rectangle, rounded corners, draw=black, fill=Gray!20, inner sep=15pt, drop shadow={fill=black, opacity=.5}]%
  \tikzstyle{fancytitle} =[fill=white, text=black, rectangle, rounded corners, draw= black]%
  \noindent%
  \begin{tikzpicture}%
    \node [thmbox] (box){%
      \begin{minipage}{.91\textwidth}%
        \textit{#1}%
      \end{minipage}%
    };%
  \node[fancytitle, right=10pt] at (box.north west) {\textbf{Theorem \thetheorem}%
    };%
    \end{tikzpicture}}

\def\theoremframecommand{\thmbox}
\newshadedtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem}
Hello
\end{theorem}

\begin{theorem}
Hello
\end{theorem}
\end{document}
elfangor
Posts: 2
Joined: Thu Nov 04, 2010 1:21 pm

Customized theorems with ntheorem and tikZ

Post by elfangor »

This indeed an improvement, but my goal was to put the abc I added in the body, in the first theorem, to be next to Theorem \thetheorem. So, this is already quite nice, but perhaps it could get even nicer :D

Elfangor
ignasi wrote:next code worked for me. I just replaced \textbf{Theorem 1} with \textbf{Theorem \thetheorem}.

Hope it helps.

Ignasi

Code: Select all

\documentclass{article}

%\usepackage[utf8x]{inputenc}
%\usepackage[dutch]{babel}

\usepackage{graphicx,textpos, a4wide}
\usepackage[svgnames]{xcolor}
\usepackage{helvet, amssymb}

\usepackage{tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations}

\usepackage{framed}
\usepackage[framed, amsthm]{ntheorem}

\theoremclass{Theorem}
\theoremstyle{empty}
\newcommand{\thmbox}[1]{
  \tikzstyle{thmbox} = [rectangle, rounded corners, draw=black, fill=Gray!20, inner sep=15pt, drop shadow={fill=black, opacity=.5}]%
  \tikzstyle{fancytitle} =[fill=white, text=black, rectangle, rounded corners, draw= black]%
  \noindent%
  \begin{tikzpicture}%
    \node [thmbox] (box){%
      \begin{minipage}{.91\textwidth}%
        \textit{#1}%
      \end{minipage}%
    };%
  \node[fancytitle, right=10pt] at (box.north west) {\textbf{Theorem \thetheorem}%
    };%
    \end{tikzpicture}}

\def\theoremframecommand{\thmbox}
\newshadedtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem}[abc]
Hello
\end{theorem}

\begin{theorem}
Hello
\end{theorem}
\end{document}
Amatheux
Posts: 1
Joined: Thu Jul 21, 2011 9:44 pm

Re: Customized theorems with ntheorem and tikZ

Post by Amatheux »

Hello Everyboby,

I have tried yours codes and it is very nice. Thanks a lot.
I have an other question, how can I do if I want to have the same thing instead
for Proposition, Corollary,... etc..... instead of Theorem.

Thanks..
Jean
Post Reply