4

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.

6

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:

enter image description here


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>
  {\bfseries\large}%        <theorem head font>
  {.}%                      <punctuation after theorem head>
  {.5em}%                   <space after theorem head>
  {}%                       <theorem head spec>
\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>
  {\bfseries\large}%        <theorem head font>
  {.}%                      <punctuation after theorem head>
  {.5em}%                   <space after theorem head>
  {}%                       <theorem head spec>
\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:

enter image description here

  • 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
  • 1
    @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
  • 1
    @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

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.