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.

I have a buildin environment in a module theorems-ams-bytype.inc (in lyx) example, which i copied and created a duplicate with required changes for a environment called as pitfall.

Style Pitfall
        CopyStyle             Definition
        LatexName             pitfall
        LabelString           "Pitfall \thepitfall."
        Preamble
          \theoremstyle{definition}
          \newtheorem{pitfall}{\protect\pitfallname}[chapter]
          \renewcommand{\thepitfall}{\arabic{pitfall}} % this will number the pitfall number as normal 1,2, etc while if u remove this line then it would be chapterno.pitfall number. 
        EndPreamble
        Requires   amsthm
        LangPreamble
          \providecommand{\pitfallname}{_(Pitfall)}
        EndLangPreamble
        BabelPreamble
          \addto\captions$$lang{\renewcommand{\pitfallname}{_(Pitfall)}}
        EndBabelPreamble
        LabelCounter   pitfall
End

Now I add some nice decorations to this environment using the renewenvironment command. The code for this redefinition of the environment is as follows.

% for pitfall
    \mdfdefinestyle{pitfallstyle}{%
    linecolor=gray,middlelinewidth=7pt,%
    frametitlerule=false,%
    %tikzsetting={shading=axis,top color=gray!10},
    % apptotikzsetting={\tikzset{mdfframetitlebackground/.append style={%
    %shade,left color=white, right color=gray!20}}}, frametitlerulecolor=gray!60,
    roundcorner=1pt,
    splittopskip=1cm,
    splitbottomskip=1cm,
    bottomline=false,
    leftline=false,
    rightline=false,
    backgroundcolor=gray!10,
    frametitlerulewidth=0pt,
    innertopmargin=\topskip, }
    % changes in pitfall environment
    \let\origpitfall\pitfall
    \let\endorigpitfall\endpitfall
    \renewenvironment{pitfall}{%
    % here you can make changes in the original pitfall class
    \begin{mdframed}[style=pitfallstyle] \origpitfall }{
    \endorigpitfall
    \end{mdframed}
     }  

Now the trouble is if I don't use \begin{pitfall} ... \end{pitfall} in the entire document then there is an error. and the error is below.

enter image description here

Kindly help me understand.

share|improve this question
    
You should show a complete (but minimal) LaTeX document from \documentclass to \end{document} that shows the problem. –  egreg Oct 13 '12 at 8:51
add comment

1 Answer

I believe that this is a timing problem; in any case, doing \let\origpitfall=\pitfall may hide a, well, pitfall.

You should be able to solve the problem by giving another name to the inner environment, say

\theoremstyle{definition}
\newtheorem{pitfallx}{\protect\pitfallname}[chapter]
\renewcommand{\thepitfallx}{\arabic{pitfallx}}
\providecommand{\pitfallname}{_(Pitfall)}

and define the "real" pitfall environment in terms of pitfallx (that you won't be ever using directly):

\mdfdefinestyle{pitfallstyle}{%
linecolor=gray,middlelinewidth=7pt,%
frametitlerule=false,%
%tikzsetting={shading=axis,top color=gray!10},
% apptotikzsetting={\tikzset{mdfframetitlebackground/.append style={%
%shade,left color=white, right color=gray!20}}}, frametitlerulecolor=gray!60,
roundcorner=1pt,
splittopskip=1cm,
splitbottomskip=1cm,
bottomline=false,
leftline=false,
rightline=false,
backgroundcolor=gray!10,
frametitlerulewidth=0pt,
innertopmargin=\topskip, }
% changes in pitfall environment
\newenvironment{pitfall}
  {\begin{mdframed}[style=pitfallstyle]\pitfallx}
  {\endpitfallx\end{mdframed}}
share|improve this answer
add comment

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.