1

I am new to theorems and definitions of the amsthm package and what I am trying to achieve might be really simple.

I have the following theorems:

\theoremstyle{definition}

\newtheorem{matriceDef}{Matrice}[section]
\newtheorem{matriceSomma}[matriceDef]{Somma}
\newtheorem{matriceSommaProp}{Proprietà per la somma tra matrici}[matriceSomma]

defined in a file. When I actually put them all together I have a LaTeX Error: No counter 'matriceSomma' defined. That happens at the last line.

What I am trying to do is have the last definition be a sub-definition of the preceding one. Right now, as you can see, output the output is correct, what I want. The problem is that it gives that error there.

The MWE for this is this one

\documentclass[a4paper]{article}
\usepackage{amsmath,amsfonts,amssymb,mathtools,calrsfs,mathrsfs,amsthm}

\theoremstyle{definition}

\newtheorem{matriceDef}{Matrice}[section]
\newtheorem{matriceSomma}[matriceDef]{Somma}
\newtheorem{matriceSommaProp}{Proprietà per la somma tra matrici}[matriceSomma]
\begin{document}

    \section{Matrici}

    \subsection{Definizioni e teoremi}

    \begin{matriceDef}
      Foo, bar
    \end{matriceDef}

    \begin{matriceSomma}      
      Outside
    \end{matriceSomma}

    \begin{matriceSommaProp}
      Inside
    \end{matriceSommaProp}

\end{document}

I removed the useless typesetting. What I would like to do is create a definition (or a theorem) that depends on another for numbering. Thanks for any help.

  • You forgot to copy the matriceDef theorem environment that you refer in the first newtheorem in the mwe – daleif Sep 24 '18 at 19:23
2

You're stating that matriceSomma uses the same counter as matriceDef, so no matriceSomma counter is defined.

\documentclass[a4paper]{article}
\usepackage{amsmath,amsthm}

\theoremstyle{definition}

\newtheorem{matriceDef}{Matrice}[section]
\newtheorem{matriceSomma}[matriceDef]{Somma}
\newtheorem{matriceSommaProp}{Proprietà per la somma tra matrici}[matriceDef]

\begin{document}

\section{Matrici}

\subsection{Definizioni e teoremi}

\begin{matriceDef}
  Foo, bar
\end{matriceDef}

\begin{matriceSomma}  
  Outside
\end{matriceSomma}

\begin{matriceSommaProp}
  Inside
\end{matriceSommaProp}

\end{document}

enter image description here

On the other hand, you'll have to define scores of such theorem-like environments, because there's the product of matrices and the product of matrices by scalars and whatnot; I propose defining just two and passing the real name at use time.

\documentclass[a4paper]{article}
\usepackage{amsmath,amsthm}

\theoremstyle{definition}

\newtheorem{innerDef}{\envargument}[section]
\newtheorem{innerSubDef}{\envargument}[innerDef]

\newcommand{\envargument}{}
\newenvironment{Def}[1]
 {\renewcommand{\envargument}{#1}\innerDef}
 {\endinnerDef}
\newenvironment{SubDef}[1]
 {\renewcommand{\envargument}{#1}\innerSubDef}
 {\endinnerSubDef}


\begin{document}

\section{Matrici}

\subsection{Definizioni e teoremi}

\begin{Def}{Matrice}
  Foo, bar
\end{Def}

\begin{Def}{Somma}  
  Outside
\end{Def}

\begin{SubDef}{Proprietà per la somma tra matrici}
  Inside
\end{SubDef}

\end{document}

By the way, shouldn't it be “Proprietà della somma fra matrici”?

  • Thanks a lot for the answer, I was just missing that part. I really like the other solution too, I might consider using it, thanks for sharing! – gjkf Sep 24 '18 at 20:42
  • 1
    @gjkf Have a look at the suggestions I added. – egreg Sep 24 '18 at 20:43
  • Just saw them and really like that solution too, thanks a bunch! And yes, it should be, was just transcribing what I wrote down during lectures. – gjkf Sep 24 '18 at 20:45
  • I have a little problem of the same kind so I thought not to create another question. When I add more sub theorems like \newtheorem{matriceDifferenzaProp}{Proprietà per la differenza tra matrici}[matriceDef] the last number stays the same (e.g. both have the number 1.2.1 and not 1.2.1 and 1.2.2). – gjkf Sep 26 '18 at 15:40
  • @gjkf Oh, that's why I suggested to do it differently! – egreg Sep 26 '18 at 15:42

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.