Graphics, Figures & TablesnTheorem \newshadedtheorem error

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
Turkurz
Posts: 31
Joined: Fri Jul 23, 2010 6:36 am

nTheorem \newshadedtheorem error

Post by Turkurz »

Hello,
this is my first post, so I hope I don't ask something really stupid, but here goes.

I was trying to use the package nTheorem to generate a shaded theorem, and the program returns an error (undefined control sequence). If I try to produce a framed theorem though, it works.

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage[slovene]{babel}

\usepackage{color}
\usepackage[framed, thmmarks]{ntheorem}
\usepackage{framed}
\usepackage{pstricks}

{\theoremheaderfont{\bf}
 \theoremseparator{:}
 \newframedtheorem{THM}{THEOREM}
}

\begin{document}
    \begin{THM}[Lovaszova lokalna lema, algoritmična verzija]
        lalalalala
    \end{THM}
\end{document}
Last edited by Turkurz on Mon Jul 26, 2010 7:11 pm, edited 1 time in total.

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

nTheorem \newshadedtheorem error

Post by Stefan Kottwitz »

Hi Turkurz,

welcome to the board!
I see you're using PSTricks. If you compile with pdfLaTeX you would get the error undefined control sequence, regarding the \c@lor@to@ps macro.
Compile with LaTeX to DVI instead, afterwards you could convert to PS and PDF.

Stefan
LaTeX.org admin
User avatar
Turkurz
Posts: 31
Joined: Fri Jul 23, 2010 6:36 am

Re: nTheorem \newshadedtheorem error

Post by Turkurz »

Hello again.

I'm impressed, you answer very quickly, and it's great that way :).
Hmm, isn't there a more conventional way. I don't wish to have a million exceptions and workarounds, and I'm sure there is a conventional way to do it, without having to resort to DVI etc. I would like to produce a PDF in the end.

Also, your suggestion still doesn't seem to work. Either that, or I don't know what I'm doing. I am a beginner in LaTeX. I use WinEdt, and I loaded the pstricks package only because I found people on the internet, who claimed it helps. I don't really know what it does, but I don't want to spend a whole day learning about pstricks, only to find out in the end, that it isn't the package I'm looking for.

I tried clicking on the DVI button, but I get 'the page could not be rendered'. Also, if I try clicking on any other button that produces a file, I get an error.


I just want a nice fancy looking theorem environment, shaded, and if possible framed as well. As much as I have read the documentation PDF of amsthm and ntheorem packages, ntheorem seems to be the best choice. If you have better suggestions (more options, more flexible), I am all ears :).
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

nTheorem \newshadedtheorem error

Post by Stefan Kottwitz »

Turkurz wrote: I'm sure there is a conventional way to do it, without having to resort to DVI etc. I would like to produce a PDF in the end.
The conventional way is producing dvi. ;) dvi was the former standard output format.
But today I guess most people use pdfLaTeX to directly create pdf output.
Turkurz wrote:I loaded the pstricks package only because I found people on the internet, who claimed it helps.
pstricks requires compilation to dvi and conversion to ps before you could generate pdf output.
I'm preferring TikZ instead. Have a look at the Tikz example gallery.
Turkurz wrote:I tried clicking on the DVI button, but I get 'the page could not be rendered'. Also, if I try clicking on any other button that produces a file, I get an error.
dvi viewer usually cannot show the ps images inside, you may have to convert it to ps before you're able to view it.
Turkurz wrote:I just want a nice fancy looking theorem environment, shaded, and if possible framed as well. As much as I have read the documentation PDF of amsthm and ntheorem packages, ntheorem seems to be the best choice.
Perhaps have a look at the empheq package, it supports ntheorem.

Stefan
LaTeX.org admin
User avatar
Turkurz
Posts: 31
Joined: Fri Jul 23, 2010 6:36 am

Re: nTheorem \newshadedtheorem error

Post by Turkurz »

Hmm, I haven't found anything useful for my problem with shaded theorem in TikZ examples, though such examples might come very handy in the future, so thanks for the link. If you know any other site, with a huge amount of latex examples, with the sourcecode, please let me know.

Similarly, I haven't found much regarding 'shade' or 'theorem' in the empheq package documentation PDF.

Please, if someone knows how to resolve this problem, let me know. Also, I would be happy, if the given solution would resort to using pdfLaTeX, and most importantly, if the solution was 'changing things in the preamble only'. In other words, I would like to create a good fancy Theorem environment, which is very automated, so I can use it in all of my other documents by merely copying the preamble and not by manually typing all those commands everytime I use the theorem environment. So that in 10 years, when I might even forget what all those commands do, I can still simply copy the preamble and it still works beautifully.

BTW, I need this for the current purpose of writing my diploma.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

nTheorem \newshadedtheorem error

Post by Stefan Kottwitz »

Here's an example using TikZ compilable with pdfLaTeX. It provides shaded theorems, configuration is made in the preamble.

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage[svgnames]{xcolor}
\usepackage[framed]{ntheorem}
\usepackage{framed}
\usepackage{tikz}
\usetikzlibrary{shadows}
\newtheorem{Theorem}{Theorem}
\theoremclass{Theorem}
\theoremstyle{break}

\tikzstyle{thmbox} = [rectangle, rounded corners, draw=black,
  fill=Cyan!20, inner sep=10pt, drop shadow={fill=black, opacity=1}]
\newcommand\thmbox[1]{%
  \noindent\begin{tikzpicture}%
  \node [thmbox] (box){%
    \begin{minipage}{.94\textwidth}%
      #1%
    \end{minipage}%
  };%
  \end{tikzpicture}}

\let\theoremframecommand\thmbox
\newshadedtheorem{ImportantTheorem}[Theorem]{Theorem}
\begin{document}
\section*{Theorems}
Text
\begin{ImportantTheorem}[Euler's identity]
The equality
\[ e^{\pi i} +1 = 0 \]
where $e$ is Euler's number, $\pi$ is the ratio of any circle's circumference
to its diameter and $i$ is the imaginary unit, is called \emph{Euler's identity}.
\end{ImportantTheorem}
\end{document}
Output:
theorem.png
theorem.png (7 KiB) Viewed 7507 times
Stefan
LaTeX.org admin
User avatar
Turkurz
Posts: 31
Joined: Fri Jul 23, 2010 6:36 am

nTheorem \newshadedtheorem error

Post by Turkurz »

Eeeeeeeexcellent :) :D.
Thank you so much, I am really grateful for this.

It seems TikZ is the answer. Your method seems to be working excellent. Now I only need to figure out what is really going on here, so I can add a few options, such as a thicker line around the theorem, etc.

Thank you again for your time and effort, this will be most useful in my diploma.

Here I have minimalised the code, so that only the necessary stuff is written.

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage[framed]{ntheorem}
\usepackage{framed}
\usepackage{tikz}
    \usetikzlibrary{shadows}

\tikzstyle{thmbox} = [rectangle, rounded corners, draw=red, fill=blue!20, inner sep=10pt, drop shadow={fill=black, opacity=1}]
\newcommand\thmbox[1]
    {\noindent
     \begin{tikzpicture}
     \node[thmbox](box){\begin{minipage}{.94\textwidth} #1 \end{minipage}};
     \end{tikzpicture}
    }
\let\theoremframecommand\thmbox
\newshadedtheorem{ImportantTheorem}{Theorem}

\begin{document}
    \begin{ImportantTheorem}[Euler's identity]
        The equality
        \[ e^{\pi i} +1 = 0 \]
        where $e$ is Euler's number, $\pi$ is the ratio of any circle's circumference
        to its diameter and $i$ is the imaginary unit, is called \emph{Euler's identity}.
    \end{ImportantTheorem}
\end{document}
How do I mark this topic as 'resolved'?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

nTheorem \newshadedtheorem error

Post by localghost »

Turkurz wrote:[...] How do I mark this topic as 'resolved'?
Edit the initial post as described in Section 3 of the Board Rules.


Best regards
Thorsten
User avatar
Turkurz
Posts: 31
Joined: Fri Jul 23, 2010 6:36 am

nTheorem \newshadedtheorem error

Post by Turkurz »

Just two additional questions/intricacies:

1. how to make a double line around the theorem?
2. how to make the box in such a way that if the theorem is very long and it breaks across two pages, the box of the theorem is such that it doesn't have it's bottom (1st page)/top (2nd page) line, so that one immediately sees it is a continuation of the same theorem.

currently I have

Code: Select all

\tikzstyle{IZRbox}=[rectangle,                                                                              %%
                    ultra thick, %ultra thin, very thin, thin, thick, very thick, ultra thick               %%
                    %rounded corners=25pt,                                                                  %%
                    draw=black,                                                                             %%
                    fill=gray!20,                                                                           %%
                    inner sep=10pt,                                                                         %%
                    %general shadow      ={fill=red,shadow scale=1.1},                                      %%
                    %copy shadow         ={fill=red,shadow scale=1.1}                                       %%
                    %circular drop shadow={fill=red,shadow scale=1.1}                                       %%
                    %drop shadow=                                                                           %%
                    %    {fill=black,                                                                       %%
                    %     opacity=1, %0.25, 0.5                                                             %%
                    %     shadow xshift= 2mm,                                                               %%
                    %     shadow yshift=-2mm                                                                %%
                    %    }                                                                                  %%
                   ]                                                                                        %%
\newcommand\IZRbox[1]                                                                                       %%
    {\noindent                                                                                              %%
     \begin{tikzpicture}                                                                                    %%
        \node[IZRbox](box){\begin{minipage}{.94\textwidth} #1 \end{minipage}};                              %%
     \end{tikzpicture}                                                                                      %%
    }                                                                                                       %%
\let\theoremframecommand\IZRbox                                                                             %%
                                                                                                            %%
\theoremheaderfont{\bf \large}                                                                              %%
\theoremseparator{:}                                                                                        %%
\theorembodyfont{\normalfont}                                                                               %%
\theoremstyle{plain}                                                                                        %%
\newshadedtheorem{IZR}{IZREK}                                                                               %%
I would be very grateful for an answer, as this would create the ultimate theorem environment.
Post Reply