# Problem with an environment definition

I know it is an easy and quite specific request but I've been on it all day and I cannot really understand what's wrong!

\documentclass[12pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amssymb,amsthm,mathtools}
\usepackage{amsmath, textcomp}
\usepackage{titling}

\theoremstyle{definition}
\newtheorem{Gcal}{Grande Caloria \textit{Cal} o \textit{kcal}}[section]
\theoremstyle{definition}
\newtheorem{Pcal}[Gcal]{Piccola Caloria \textit{cal}}
\theoremstyle{definition}
\newtheorem{CalS}[Pcal]{Calore Specifico}

\begin{document}

\chapter{1}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\chapter{2}
\section{2.1}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

\begin{itemize}
\itemsep0em
\item[] \begin{Gcal}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{Gcal}
\item[] \begin{Pcal}
blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{Pcal}
\end{itemize}

blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

\begin{CalS}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{CalS}

\end{document}


Errors Report

1. ! LaTeX Error: No counter 'Pcal' defined. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.22 \newtheorem{CalS}[Pcal]{Calore Specifico} Your command was ignored.

2. ! LaTeX Error: Environment CalS undefined. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.45 \begin{CalS} Your command was ignored. Type I to replace it with another command, or to continue without it. ! LaTeX Error: \begin{document} ended by \end{CalS}. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.47 \end{CalS} Your command was ignored.

3. ! LaTeX Error: \begin{document} ended by \end{CalS}. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.47 \end{CalS} Your command was ignored.

Can someone explain what did I do wrong? Why only the third enviroment gives problem even if I've copyed/pasted them all?

• Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. May 19, 2014 at 19:43
• There is no Pcal counter, because the Pcal environment is defined to share the Gcal counter. Try \newtheorem{CalS}[Gcal]{Calore Specifico} and it will work. May 19, 2014 at 19:49
• Thanks so much...I'm learning how to write in latex by doing it so I get informations from here and there but sometimes they're not totally comprehensible! May 19, 2014 at 20:08

When you say

 \newtheorem{abc}{Abc}[section]
\newtheorem{xyz}[abc]{Xyz}


you're telling LaTeX that the statement environments abc and xyz must share the counter; so no counter xyz is defined.

You could do

\theoremstyle{definition}
\newtheorem{Gcal}{Grande Caloria \textit{Cal} o \textit{kcal}}[section]
\newtheorem{Pcal}[Gcal]{Piccola Caloria \textit{cal}}
\newtheorem{CalS}[Gcal]{Calore Specifico}


Note that one \theoremstyle{definition} declaration suffices.

Actually there's a better way.

\documentclass[12pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[utf8]{inputenc}

\usepackage{amssymb,amsthm,mathtools}
\usepackage{amsmath, textcomp}
\usepackage{titling}

\theoremstyle{definition}
\newtheorem{vardef*}{\vardefname}[section]
\newcommand\vardefname{} % initialize
\newenvironment{vardef}[1]
{\renewcommand\vardefname{#1}\begin{vardef*}}
{\end{vardef*}}

\begin{document}

\chapter{1}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

\chapter{2}
\section{2.1}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

\begin{vardef}{Grande Caloria \textit{Cal} o \textit{kcal}}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{vardef}

\begin{vardef}{Piccola Caloria \textit{cal}}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{vardef}

blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

\begin{vardef}{Calore Specifico}
blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{vardef}

blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

\end{document}


You have just a generic environment for definitions and give the title at statement time rather than having a different environment for each in the preamble.

• It works perfectly and it's much better not to have to redefine each time a new enviroment!! Thanks so much for the patience with my questions that may look so silly...I'm just at the beginning with latex code but I'm already learning so much thanks to all of you. May 20, 2014 at 21:52