Redefining an environment or a command with an indefinite numbers of items

According to LaTeX's basic commands if I want to create a list of items I have to use the following concept code:

\begin{itemize}   \item first   \item second   \item third \end{itemize} 

To keep my code as clean as possible and really customizable I use another concept:

\begin{myenv}   \item first   \item second   \item third \end{myenv} 

If it's possible, I'd like to also customize the "item command" like this (but it's not really essential):

\begin{myenv}   \myitem first   \myitem second   \myitem third \end{myenv} 

The problem is: How I can redefine an environment like this?

\newenvironment{myenv}   {?}   {?} 

I'd like to ask the same question for the newly created command with



You could use the enumitem package to set up your own list.

Note that in the code below I have used \newlist to create the environment mylist and setlist to customize it. The {10} refers to the max-depth, which means that you could have at most 10 nested versions you are likely to have.

The enumitem package provides many more options for customizing the labels, indentation, margins, font, etc- see the documentation for more details.




    \item my first item
    \item my second item


Defining a new environment that matches the itemize environment is done in the following way:

  {\begin{itemize}}% \begin{myenv}
  {\end{itemize}}% \end{myenv}

Defining a command that does something similar to \item is done in the following way:

\LetLtxMacro{\mycmd}{\item}% \mycmd = \item

Note that \item may take an optional argument, and it is therefore not as easy to merely "copy" it through \newcommand{\mycmd}{\item}. The letltxmacro package allows for making a "responsible" copy. Here is a minimal example that shows the usage:

Redefining an environment or a command with an indefinite numbers of items

  {\begin{itemize}}% \begin{myenv}
  {\end{itemize}}% \end{myenv}
\LetLtxMacro{\mycmd}{\item}% \mycmd = \item
  \mycmd first
  \mycmd second
  \mycmd third

As mentioned above, you can now also use \mycmd[<stuff>] which will override the traditional \textbullet itemized bullet.

Category: lists Time: 2011-11-08 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.134 (s). 12 q(s)