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{}?



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:]

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:




    \begin{enumerate}[\textbf{#1} \bfseries #2:]


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


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.