1

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!

JAG2024
  • 113
  • 2
    This is something like a \newtheorem etc. with packages amsthm, thmtools, tcolorbox, mdframed, the later can produce lists of theorems etc. –  Jul 14 '17 at 21:01
  • Maybe helpful https://tex.stackexchange.com/a/249980/124842 or https://tex.stackexchange.com/a/45821/124842. – Bobyandbob Jul 14 '17 at 21:13

1 Answers1

1

enter image description here

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}