# How create new counter that counts by order of appearance

I want to create a counter (and be able to label each time a new item of it appears) that counts problems and name them in order of their appearance, indifferent to which section they appear in. Such as:

Problem 1. Text text text equation....

and then in a totally different section/chapter

Problem 2. Text ... equation text etc

And so on.

You can simply define a new counter

\newcounter{problem}

and its numbering won't depend on sectioning levels.

But, looking at the result you want to achieve, I suggest you to define a new theorem-like environment

\theoremstyle{definition}
\newtheorem{problem}{Problem}

MWE:

\documentclass{book}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{problem}{Problem}

\begin{document}

\chapter{First}

\begin{problem}\label{prob:first}
Some text
\end{problem}

\begin{problem}\label{prob:second}
Some text
\end{problem}

\chapter{Second}

\begin{problem}\label{prob:third}
Some text
\end{problem}

A reference to problem \ref{prob:second}

\end{document}

Output:

## EDIT (in response to the OP's comment)

You can define a new style and use it instead of definition style:

\newtheoremstyle{problem}%  <name>
{\topsep}%                <space above>
{\topsep}%                <space below>
{}%                       <body font>
{}%                       <indent amount>
\theoremstyle{problem}

Change \large to whatever you want.

MWE:

\documentclass{book}
\usepackage{amsthm}
\newtheoremstyle{problem}%  <name>
{\topsep}%                <space above>
{\topsep}%                <space below>
{}%                       <body font>
{}%                       <indent amount>
\theoremstyle{problem}
\newtheorem{problem}{Problem}

\begin{document}

\chapter{First}

\begin{problem}\label{prob:first}
Some text
\end{problem}

\begin{problem}\label{prob:second}
Some text
\end{problem}

\chapter{Second}

\begin{problem}\label{prob:third}
Some text
\end{problem}

A reference to problem \ref{prob:second}

\end{document}

Output:

• Thanks, it works great thus far. Is it possible to change the size of the font of the thing that says "Problem 3" in your output example? – Your Majesty Feb 24 '15 at 12:42
• @LoveLearning Yes, see the edit. – karlkoeller Feb 24 '15 at 13:05
• Wow amazing, you're a true Maestro! – Your Majesty Feb 24 '15 at 13:22
• @LoveLearning Thanks for your kind words, but "Maestro" here is someone else than me :-) I'm just a simple LaTeX user with 20 years of experience... – karlkoeller Feb 24 '15 at 15:51