LaTeX 错误:命令 \openbox 已定义

LaTeX 错误:命令 \openbox 已定义

请帮我摆脱以下错误:

    ("C:\Program Files\MiKTeX 2.9\tex\latex\mytheorem\demonstration.sty"
Package: demonstration 


! LaTeX Error: Command \openbox already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.13   \vrule\hfil}}

此代码源提供:

\documentclass[12pt,a4paper]{book}
    \usepackage{geometry}
    \usepackage{lipsum} 
    \usepackage[calcwidth,raggedright,bf,sf]{titlesec}
    \usepackage{blindtext}
    \usepackage{slashbox}
    \usepackage{tabularx}
    \usepackage{fancyhdr}
    \usepackage{fancybox}
    \usepackage{turnstile}
    \usepackage{bbding}
    \usepackage{shadethm}
    \usepackage{framed}
    \usepackage[Lenny]{fncychap}
    \geometry{left=-1cm, right=1cm, top=1.5cm, bottom=1.5cm}  
    \setlength{\shadeboxrule}{.4pt}
    \setcounter{tocdepth}{3}
    \def\mathbi#1{\textbf{\em #1}}
    \newlength{\shadowbaseline}
    \newcommand{\shadowbaselinebox}[1]{%
      \leavevmode
      \setlength{\shadowbaseline}
                        {\fboxsep+\fboxrule+\heightof{#1}}%
      \hbox{\vbox to \shadowbaseline{%
                  \hbox{\protect\shadowbox{#1}}}}%
    }
    \setlength{\paperwidth}{21cm}
    \setlength{\paperheight}{29.7cm}
    \setlength{\evensidemargin}{0cm}
    \setlength{\oddsidemargin}{0cm}
    \setlength{\topmargin}{-2.5cm}
    \setlength{\headsep}{0.7cm}
    \setlength{\headheight}{1cm}
    \setlength{\textheight}{25cm}
    \setlength{\textwidth}{17cm}
    \renewcommand{\theenumi}{\textbf{\arabic{enumi}}}
    \renewcommand{\labelenumi}{\textbf{\theenumi.}}
    \renewcommand{\theenumii}{\textbf{\alph{enumii}}}
    \renewcommand{\labelenumii}{\textbf{\theenumii.}}
    \everymath{\displaystyle\everymath{}}
    \pagestyle{fancy}
    \makeatletter
    \renewcommand{\chaptermark}[1]{%
       \markboth{%
         \ifnum \c@secnumdepth >\m@ne
           \if@mainmatter
             \@chapapp\nobreakspace
             \shadowbaselinebox{\thechapter}\nobreakspace
           \fi
         \fi
       #1}{}}
    \makeatother
    \fancyhead{}
    \fancyhead[RE]{ \scshape \leftmark}
    \fancyhead[LO]{\scshape  \nouppercase \rightmark }
    \fancyfoot{}
    \fancyfoot[RE]{ \scshape  \textsc{ My institut}} 
    \fancyfoot[LO]{ \scshape \textsc{Title} }
    \fancyfoot[LE,RO]{\shadowbaselinebox{\thepage}}
    \renewcommand{\headrulewidth}{0.5pt}
    \renewcommand{\footrulewidth}{0.5pt}
    \begin{document}
    \chapter{one}
    \limpsum
    \chapter{Two}
    \lipsum
    \end{document}

答案1

尝试

\let\openbox\relax
\usepackage{demonstration}

答案2

代码尝试定义\openbox已定义的命令。这会导致出现该错误消息。请检查您的文件C:\Program Files\MiKTeX 2.9\tex\latex\mytheorem\demonstration.sty是否存在此问题。

很可能您已经加载了一个定义 的包\openbox。例如,amsthmntheorem都以相同的方式定义了它和:

\newcommand{\openbox}{\leavevmode
  \hbox to.77778em{%
  \hfil\vrule
  \vbox to.675em{\hrule width.6em\vfil\hrule}%
  \vrule\hfil}}

您可以看到命令

\vrule\hfil}}

从您的错误信息中。

从序言中删除您不需要的包。如果您需要它并且想要保留它,请不要再次定义相同的命令,或者如果您打算更改宏定义,请使用\renewcommand而不是。\newcommand

相关内容