Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Using the ntheorem package, the definition of \newshadedtheorem overwrites the \theoremprework, which I wanted to use to redefine \emph inside a custom shaded theorem. The definition of \newshadedtheorem is:

\def\newshadedtheorem#1{%
\expandafter\global\expandafter\xdef\csname#1@shadecolor\endcsname{%
\the\shadecolor}%
\ifx\theoremframecommand\relax
\expandafter\global\expandafter\xdef\csname#1@framecommand\endcsname{%
\noexpand\psframebox[fillstyle=solid,
fillcolor=\csname#1@shadecolor\endcsname,
linecolor=\csname#1@shadecolor\endcsname]}%
\else
\expandafter\global\expandafter\let\csname#1@framecommand\endcsname%
\theoremframecommand%
\fi
\theoremprework{%
\def\FrameCommand{\csname#1@framecommand\endcsname}%
\vskip\theoremframepreskipamount\framed}%
\theorempostwork{\endframed\vskip\theoremframepostskipamount}%
\newtheorem@i{#1}%
}

Minimal example of what I want to do:

\documentclass[a4paper]{scrartcl}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{framed}
\usepackage[amsmath,hyperref,noconfig,framed]{ntheorem}
\usepackage{hyperref}

% bakup old emph
\let\oldEmph=\emph

\theoremstyle{plain}
\theorembodyfont{\upshape}
\theoremprework{\renewcommand{\emph}[1]{\oldEmph{{\color{blue}##1}}}}
\theorempostwork{\renewcommand{\emph}[1]{\oldEmph{##1}}}
\def\theoremframecommand{\colorbox{blue!10}}
\newshadedtheorem{definition}{\color{blue}Definition}[section]

\begin{document}
\begin{definition}
  Test of \emph{emph} inside Definiton.
\end{definition}
\end{document}

Does anybody know how to achieve this?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Define an auxiliary environment:

\newshadedtheorem{definition*}{\color{blue}Definition}[section]
\newenvironment{definition}
  {\renewcommand{\emph}[1]{\oldEmph{{\color{blue}##1}}}%
   \begin{definition*}}
  {\end{definition*}}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.