# How to create function that creates definitions and is formatted in a certain way

I'm new to LaTeX macros and am hoping to create a command that definitions a function called "definition". When I use \definition{}, it would automatically format whatever is in {} to be bold, on a new line, and followed by colon. So it would look like this:

So it would look like this:

definition 1: blah blah blah

definition 2: blah blah blah

definition 3: blah blah blah

And then would there be a way to list all of the definitions at the end of the doc by calling on \definition{}?

Thanks!

• This is something like a \newtheorem etc. with packages amsthm, thmtools, tcolorbox, mdframed, the later can produce lists of theorems etc. – user31729 Jul 14 '17 at 21:01
• – Bobyandbob Jul 14 '17 at 21:13

You need to use environ package to define a new listing environment in the way you want. In the preamble use the following syntax:

\NewEnviron{definition}[Numer of Inputs][Default Option]
{%
\begin{enumerate}[\textbf{#1} \bfseries #2:]
\BODY
\end{enumerate}
}


You can then use the syntax: \begin{definition}[Your Definition]{Numbering Format} to begin an environment.

Note that Default Option defines the first option (#1) in the definition above and if you used \begin{definition}{numbering format} and the predefined code above will put "Default Option" for the name of listing.

Here is the full code:

\documentclass{scrartcl}

\usepackage{paralist}

\usepackage{environ}

\NewEnviron{definition}[2][Definition]
{%
\begin{enumerate}[\textbf{#1} \bfseries #2:]
\BODY
\end{enumerate}
}

\begin{document}

\begin{definition}[Custom Definition]{1}
\item First entry
\item Second entry
\item Third entry
\end{definition}

\end{document}