1

The following code fails with the error

! LaTeX Error: Command \mybox already defined. Or name \end... illegal, see p.192 of the manual. \usepackage[most]{tcolorbox} \newtcolorbox{mybox}[2][]{% colback=bg, colframe=blue!75!black, fonttitle=\bfseries, coltitle=blue!75!black, colbacktitle=bg, enhanced, attach boxed title to top left={yshift=-1.2mm, xshift=2mm}, title=#2, #1} %-------------------- \usepackage{fancybox} %pour faire l'encadrement \newcommand{\mybox}[1]{ \setlength{\fboxsep}{7pt} \begin{center} \shadowbox{#1} \end{center}} %-------------------- 

Could you please help me

6
  • 1
    You can have both a tcolorbox mybox and a command \mybox. Choose another name. Commented Dec 15, 2017 at 11:41
  • Please help me because I'm beginer Commented Dec 15, 2017 at 11:43
  • 6
    you just need to call it something else so change \newcommand{\mybox}[1]{ to \newcommand{\anythingbutnotmybox}[1]{ Commented Dec 15, 2017 at 11:46
  • 1
    Sorry I meant "you can't" not "you can". Commented Dec 15, 2017 at 11:55
  • 2
    In case you weren't aware, and you are confused why \mybox is already defined: When you write \begin{mybox} LaTeX translates that into \mybox with some checking around it. Therefore, when you created the environment mybox as a new tcolorbox, internally, that defined the command \mybox :) Commented Dec 15, 2017 at 12:42

1 Answer 1

3

You just replace \mybox by for example \cadre us follows:

 \usepackage[most]{tcolorbox} \newtcolorbox{mybox}[2][]{% colback=bg, colframe=blue!75!black, fonttitle=\bfseries, coltitle=blue!75!black, colbacktitle=bg, enhanced, attach boxed title to top left={yshift=-1.2mm, xshift=2mm}, title=#2, #1} %-------------------- \usepackage{fancybox} %pour faire l'encadrement \newcommand{\cadre}[1]{ \setlength{\fboxsep}{7pt} \begin{center} \shadowbox{#1} \end{center}} %-------------------- 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.