[Tex/LaTex] change the style of numbering the theorem, definition in sections

numberingsectioning

enter code hereCould you help me please to create a paper which appears in the following way:

The Newton's Law – section

1 Definition – \begin{definition} \end{definition}

2 Theorem – \begin{theorem} \end{theorem}

The conjecture of Poincare – section

1 Definition – \begin{definition} \end{definition}

2 Theorem – \begin{theorem} \end{theorem}

For me it is hard to create different sections which have same numbering, and also to put the number in front of the theorem or of the definition. Thanks!

\documentclass[a4paper,12pt]{article}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage[usenames,dvipsnames]{color}
\usepackage{color,graphicx}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{hyperref}

\usepackage{variations}
\usepackage[romanian]{babel}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,amsthm}
\swapnumbers 
\newtheorem{definition}{Definition}
\newtheorem{theorem}[definition]{Theorem} 
\let\origsection\section 
\renewcommand\section{\setcounter{definition}{0}\origsection}
\newtheorem{lemma}[theorem]{Lem\u a}

\newtheorem{corollary}[theorem]{Corolar}
\newtheorem{proposition}[theorem]{Not\u a}

%\theoremstyle{definition}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Consecin\c t\u a}
\newtheorem{example}[theorem]{Exemplul}
\newtheorem*{acknowledgements}{Observa\c{t}ie}

Best Answer

One way to achieve your objective would be to (i) make sure that the definition and theorem environments share the same counter and (ii) redefine the \section command in a way that resets this counter to 0, regardless of whether the sections are numbered or not. The example below does these things, while using the amsthm package.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,amsthm}
\swapnumbers % place definition/theorem number *before* name
\newtheorem{definition}{Definition}
\newtheorem{theorem}[definition]{Theorem} % link the counters
\let\origsection\section % save the original section definition
\renewcommand\section{\setcounter{definition}{0}\origsection}

\begin{document}
\section*{Newton's Law}
\begin{definition}[Here we go] bla bla bla\end{definition}
\begin{theorem}[Deep thoughts] more bla bla \end{theorem}

\section*{The Poincaré Conjecture}
\begin{definition}[More to say] bla bla bla\end{definition}
\begin{theorem}[Random thoughts] Still more bla bla \end{theorem}

\end{document}
Related Question