[Tex/LaTex] \begin{problem} analogue to \begin{proof}

environmentsmacrostheorems

I recently learned about \begin{proof} ... \end{proof}, which is a good environment to work in. My question is whether there exists a similar environment to state a problem, or whether I can write some commands for something like that myself. Ideally, I would want something like this:

\begin{problem} Prove that $2+2 = 4$. \end{\problem}

And then it should output something like:

\\\\\noindent\textem{Problem.} Prove that $2+2 = 4$.\\\\

Best Answer

The following provides a MWE:

\documentclass{article}
\usepackage{amsmath}

\newtheorem{problem}{Problem}

\begin{document}
\begin{problem}
    This is a new problem.
\end{problem}
\end{document}

enter image description here

To further customize the look of the problem environment, we can resort to the amsthm package and the \newtheoremstyle command. A MWE is given below:

\documentclass{article}
\usepackage{amsmath,amsthm}
\newtheoremstyle{problemstyle}  % <name>
        {3pt}                                               % <space above>
        {3pt}                                               % <space below>
        {\normalfont}                               % <body font>
        {}                                                  % <indent amount}
        {\bfseries\itshape}                 % <theorem head font>
        {\normalfont\bfseries:}         % <punctuation after theorem head>
        {.5em}                                          % <space after theorem head>
        {}                                                  % <theorem head spec (can be left empty, meaning `normal')>
\theoremstyle{problemstyle}

\newtheorem{problem}{Problem}[section] % Comment out [section] to remove section number dependence

\begin{document}
\section{Simple Problems}
\begin{problem}[Analytic]
    Prove that $2+2 = 4$.
\end{problem}
\end{document}

enter image description here

Related Question