1

I am trying to a fancy theorem type for my notes. I like tcolorbox examples. But the one that I like most is giving me an error.

    Missing \endcsname inserted.

This one is on page 360 of the tcolorbox manual. I do not understand why I am getting this error and how to fix. There was a similar question

https://tex.stackexchange.com/questions/174017/compile-error-missing-endcsname-inserted-with-code-and-tcolorbox

But it did not solve my problem. The result should be like this enter image description here

I have added the code below. Please help me.

    \documentclass[11pt]{article}
    \usepackage{varioref}
    \usepackage{cleveref}
    \tcbuselibrary{skins}

    \newtcbtheorem[use counter from=Definition]{YetAnotherTheorem}{Theorem}%
      {theorem style=change apart,enhanced,arc=0mm,outer arc=0mm,
      boxrule=0mm,toprule=1mm,bottomrule=1mm,left=1mm,right=1mm,
      titlerule=0mm,toptitle=0mm,bottomtitle=1mm,top=0mm,
      colframe=red!50!black,colback=red!5!white,coltitle=red!50!black,
      title style={top color=yellow!50!white,bottom color=red!5!white,
        middle color=yellow!50!white},
      fonttitle=\bfseries\sffamily\normalsize,fontupper=\normalsize\itshape,
      }{theo}


    \begin{document}
    \begin{YetAnotherTheorem}{Mittelwertsatz f\"{u}r $n$ Variable}{mittelwertsatz_n2}% Es sei $n\in\mathbb{N}$, $D\subseteq\mathbb{R}^n$ eine offene Menge und
    $f\in C^{1}(D,\mathbb{R})$. Dann gibt es auf jeder Strecke
    $[x_0,x]\subset D$ einen Punkt $\xi\in[x_0,x]$, so dass gilt
      \begin{equation*}
      f(x)-f(x_0) = \operatorname{grad} f(\xi)^{\top}(x-x_0)
      \end{equation*}
    \end{YetAnotherTheorem}

    \end{document}
2
  • One obvious point: you're not even loading tcolorbox. – user121799 Nov 27 '18 at 2:52
  • @marmot I am actually loading tcolorbox package I just forgot to put it here – Kumarm Nov 27 '18 at 3:03
1

This is too long for a comment. You have several issues:

  • you are not loading tcolorbox package
  • you need to add \tcbuselibrary{theorems}
  • you have not defined \mathbb
  • the use counter from=Definition does not work because you have not defined a definition environment. As per the comments, I have replaced this with no counter to remove the numbering.

The following code compiles and perhaps does what you want:

\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{varioref}
\usepackage{tcolorbox}
\tcbuselibrary{skins,theorems}
\usepackage{cleveref}

\newtcbtheorem[no number]{YetAnotherTheorem}{Theorem}%
  {theorem style=change apart,enhanced,arc=0mm,outer arc=0mm,
  boxrule=0mm,toprule=1mm,bottomrule=1mm,left=1mm,right=1mm,
  titlerule=0mm,toptitle=0mm,bottomtitle=1mm,top=0mm,
  colframe=red!50!black,colback=red!5!white,coltitle=red!50!black,
  title style={top color=yellow!50!white,bottom color=red!5!white,
    middle color=yellow!50!white},
  fonttitle=\bfseries\sffamily\normalsize,fontupper=\normalsize\itshape,
  }{theo}

\begin{document}

  \begin{YetAnotherTheorem}{Mittelwertsatz f\"{u}r $n$ Variable}{mittelwertsatz_n2}% Es sei $n\in\mathbb{N}$, $D\subseteq\mathbb{R}^n$ eine offene Menge und
  $f\in C^{1}(D,\mathbb{R})$. Dann gibt es auf jeder Strecke
  $[x_0,x]\subset D$ einen Punkt $\xi\in[x_0,x]$, so dass gilt
    \begin{equation*}
    f(x)-f(x_0) = \operatorname{grad} f(\xi)^{\top}(x-x_0)
    \end{equation*}
  \end{YetAnotherTheorem}

\end{document}

The output is:

enter image description here

Edit To remove both the theorem name and number and just have the box itself, it is better to use newtcolorbox, to give:

enter image description here

Here is the updated code:

\documentclass[11pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{varioref}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{cleveref}

\newtcolorbox{YetAnotherTheorem}[1]%
  {enhanced,arc=0mm,outer arc=0mm,
  boxrule=0mm,toprule=1mm,bottomrule=1mm,left=1mm,right=1mm,
  titlerule=0mm,toptitle=0mm,bottomtitle=0mm,top=0mm,
  colframe=red!50!black,colback=red!5!white,coltitle=red!50!black,
  colbacktitle=yellow!50!white,colback=red!5!white,
  title=#1,
  fonttitle=\bfseries\sffamily\normalsize,fontupper=\normalsize\itshape,
  }

\begin{document}

\begin{YetAnotherTheorem}{Mittelwertsatz f\"{u}r $\mathbf{n}$ Variable}
  $f\in C^{1}(D,\mathbb{R})$. Dann gibt es auf jeder Strecke
  $[x_0,x]\subset D$ einen Punkt $\xi\in[x_0,x]$, so dass gilt
    \begin{equation*}
    f(x)-f(x_0) = \operatorname{grad} f(\xi)^{\top}(x-x_0)
    \end{equation*}
  \end{YetAnotherTheorem}

\end{document}
8
  • In my full document I have tcolorbox loded, I just forgot to put here. I have theorems loaded as well. It did not work. When I copy this and create a new document this works. – Kumarm Nov 27 '18 at 3:08
  • 1
    @Kumarm From your comment it is not clear to me, has this solved your issue? For me I think that the \endcsname error was caused by the use counter from=Definition. Perhaps this was your problem? In any case, this was all that I changed in the \newtcbtheorem definition. – user30471 Nov 27 '18 at 3:18
  • Yes you are right after replacing use counter from=Definition with number within=section this works. However actually I do not want the numbers at all when I delete use counter from=Definition part it still gives me 1. Can you help me how to get rid of the numbering at all. – Kumarm Nov 27 '18 at 3:23
  • @Kumarm To remove the numbering, replace number within=section with no counter. I'll edit my post. – user30471 Nov 27 '18 at 3:27
  • I know that this was the issue because I was just about to post a very similar answer in which just added \newtcbtheorem{Definition}{Theorem}% {colback=white,colframe=red!50!black,fonttitle=\bfseries, separator sign={\ $\blacktriangleright$}}{theo} to solve the issue, this also works. BTW, I'd use \boldmath for the theorem title to make $n$ bold as well. – user121799 Nov 27 '18 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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