# Macro for problem set with equations

I'm looking for a way to setup a macro for organizing my problem sets. Basically, I'm looking for a shortcut to replace what I currently do, which is:

Problem 1)

\begin{equation*}
\begin{gathered}
\int_{-\infty}^{\infty} f(x) dx \\
\text{A well thought out proof}
\end{gathered}

Problem 2)
etc...


I think I need a custom environment where I can just say \begin{problem} ... \end{problem} and it will head the section accordingly and be in math mode. I don't know anything about how to set that up though. Any insights appreciated, much thanks!

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – CarLaTeX Sep 22 '17 at 2:52
• What part of the problem should be automated? For example, if you write \begin{problem}...\end{problem} without adding anything inbetween, what should the output look like? – Werner Sep 22 '17 at 5:28

## 1 Answer

As Werner told you, it is not clear if you like to have a problem environment or only a new environment which substitutes the equation* and gathered ones. I've done them both (I called the latter eqga).

I have also added these lines (credits to Paulo Cereda):

\newtheoremstyle{mystyle}% name
{3pt}% space above
{3pt}% space below
{}% body font
{}% indent amount
{\bfseries}% theorem head font
{)\newline}% punctuation after theorem head
{.5em}% space after theorem head
{}% theorem head spec
\theoremstyle{mystyle}


to have the problem style as you indicated in your question, but I prefer the classical layout with the dot at the end of the number, just remove the above lines and uncomment this one:

%\theoremstyle{definition}


to look at it.

\documentclass{article}
\usepackage{amsmath}

\usepackage{amsthm}

% code from: https://tex.stackexchange.com/a/26116/101651 (slightly modified)
\newtheoremstyle{mystyle}% name
{3pt}% space above
{3pt}% space below
{}% body font
{}% indent amount
{\bfseries}% theorem head font
{)\newline}% punctuation after theorem head
{.5em}% space after theorem head
{}% theorem head spec
\theoremstyle{mystyle}
%\theoremstyle{definition}
\newtheorem{problem}{Problem}

\newenvironment{eqga}{%
\begin{equation*}
\begin{gathered}
}{%
\end{gathered}
\end{equation*}
}

\begin{document}
\begin{problem}
Description of the problem
\begin{eqga}
\int_{-\infty}^{\infty} f(x) dx \\
\end{eqga}
\end{problem}
\begin{proof}
A well thought out proof
\end{proof}
\begin{problem}
Description of another problem
\end{problem}
\begin{proof}
Another well thought out proof
\end{proof}
\end{document}