2

So this is my code

\documentclass{book}
\usepackage[utf8]{inputenc}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{parskip}
\usepackage{emptypage}
\usepackage{multirow}
\usepackage{framed}
\usepackage{bm}
\usepackage{hhline}

\usepackage{mathtools}
\usepackage{amsthm, amsmath}

\newtheoremstyle{definition}
  {\parskip}%                             % Space above
  {\parskip}%                             % Space below
  {\itshape}%                             % Body font
  {}%                                     % Indent amount
  {\bfseries}%                            % Theorem head font
  {~---}%                                 % Punctuation after theorem head
  { }%                                    % Space after theorem head
  {}
\theoremstyle{definition}

\usepackage[left=1in, right=1in, top=1.5in, bottom=1.5in]{geometry}

\usepackage{hyperref}
\hypersetup{
    linktoc=all     %set to all if you want both sections and subsections linked
}


\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{Some Chapter}

\section{Some Section}

\newtheorem{somedef}{Definition}
\begin{somedef}
Some definition
\end{somedef}

\newtheorem{somedef2}{Definition}
\begin{somedef2}
Some other definition
\end{somedef2}

\end{document}

I'm compiling this on Overleaf (not sure if it matters) and the link is here: https://www.overleaf.com/read/tsbqtfwbgsvm

Somehow the theorem counter doesn't increase? It shows 1 for both of the definitions.

Appreciate any help.

EDIT: I want the theorems to start from 1 and increment by 1. Shouldn't this be the default behavior anyway?

1
  • But you are defining two indepedent environments, namely, somedef and somedef2, each with its independent counter! Edit: what are you actually looking for: 1) two different kinds of theorem, e.g., “Theorem” and “Proposition”, that share the same counter, or 2) two instances of the same kind of theorem?
    – GuM
    Mar 12 '16 at 1:09
1

So, it is actually this you are looking for:

\documentclass{book}
\usepackage[utf8]{inputenc}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{parskip}
\usepackage{emptypage}
\usepackage{multirow}
\usepackage{framed}
\usepackage{bm}
\usepackage{hhline}

\usepackage{mathtools}
\usepackage{amsthm, amsmath}

\newtheoremstyle{definition}
  {\parskip}%                             % Space above
  {\parskip}%                             % Space below
  {\itshape}%                             % Body font
  {}%                                     % Indent amount
  {\bfseries}%                            % Theorem head font
  {~---}%                                 % Punctuation after theorem head
  { }%                                    % Space after theorem head
  {}
\theoremstyle{definition}

\usepackage[left=1in, right=1in, top=1.5in, bottom=1.5in]{geometry}

\usepackage{hyperref}
\hypersetup{
    linktoc=all     %set to all if you want both sections and subsections linked
}


\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{Some Chapter}

\section{Some Section}

\newtheorem{somedef}{Definition}
\begin{somedef}
Some definition
\end{somedef}

% Do NOT issue a second \newtheorem{somedef2}{Definition}
% Simply reuse the same environment as above:
\begin{somedef}
Some other definition
\end{somedef}

\end{document}

Or am I misunderstanding again?

3
  • Thanks, I was under the impression that you'll have to define a \newtheorem every single time you begin a definition/theorem/etc. Mar 12 '16 at 1:32
  • @absolutelydevastated: Welcome to TeX.SX! By the way, do you know that you can accept and upvote answers in order to show your appreciation? (:-)
    – GuM
    Mar 12 '16 at 1:47
  • 1
    \newtheorem statements should be in the preamble.
    – egreg
    Mar 12 '16 at 8:39

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.