# renewcommand for description

I have a document with many \description environments. All of them are defined like this:

\begin{description}[leftmargin=2.5cm,style=sameline]
\item[\texttt{foo}] bar
\item[\hspace{7mm}\texttt{sub}] inner
\end{description}


How can I use \renewcommand (or something similar) to not always have to write [leftmargin=2.5cm,style=sameline] and also have the argument of \item automatically be in \texttt and optionally be preceded by some space \hspace{7mm}?

Other solutions are also greatly appreciated.

-

## 2 Answers

You can use newlist from the enumitem package to define your custom styles.

## Code:

\documentclass{article}
\usepackage{enumitem}

\newlist{MyDescription}{description}{1}
\setlist[MyDescription]{leftmargin=2.5cm,style=sameline, font=\texttt}

\newcommand*{\IndentedItem}[1][]{\item[\hspace{7mm}#1]}%

\begin{document}\noindent
Manually specified:
\begin{description}[leftmargin=2.5cm,style=sameline]
\item[\texttt{foo}] bar
\item[\hspace{7mm}\texttt{sub}] inner
\end{description}

\noindent
Using \verb|MyDescription|:
\begin{MyDescription}
\item[foo] bar
\IndentedItem[sub] inner
\end{MyDescription}
\end{document}

-
This looks awesome! Going to use it - Thank You! One more question, I don't know if it's possible: I would like to replace \item[\hspace{7mm}sub] inner with something like \item2[sub] inner and have the same result. Is it possible? Thank You for your superfast help! – jlordo Dec 4 '12 at 20:12
@jlordo: Not recommended to have numbers in the macro names, btu can be done. Have updated solution to define a \IndentedItem macro. – Peter Grill Dec 4 '12 at 20:18
Works like a charm! Thank You! – jlordo Dec 4 '12 at 20:20

You can define a new environment:

\newenvironment{mydescription}{\begin{description}[leftmargin=2.5cm,style=sameline]}
{\end{description}

-
This looks like it solves the first part of my problem. Thank You! Do You also have a hint for the default formatting of my \item items? – jlordo Dec 4 '12 at 20:06
I'd go with peter grill's solution. – A.Ellett Dec 4 '12 at 20:11