4

I have the following macro that I found:

\newenvironment{itemizetight}[2]
  {\begin{list}{\labelitemi}{%
     \setlength{\itemsep}{#1}%
     \setlength{\labelwidth}{#2}%
     \setlength{\leftmargin}{\labelwidth}%
     \addtolength{\leftmargin}{\labelsep}%
   }%
  }
  {\end{list}}

However, it does not let me use \item[1.]. How can I change it so that I can use labels like in a typical itemize environment? Or alternatively, what would be the parallel for an enumerate environment?

The way to use it, for example is:

\begin{itemizetight}{-0.2em}{0.5em}
\item item 1
\item item 2
\end{itemizetight}
  • 1
    You should look up the enumitem package; it would make your life easier for this sort of things. – jub0bs Jan 13 '14 at 13:19
  • 2
    I can't see any reason why \item should not work as usual (since you show no code that changes it) Please always include a complete document that shows the problem. – David Carlisle Jan 13 '14 at 13:20
4

Apart from the fact that I'm able to use things like \item[1.] inside your itemizetight environment, the "parallel" for the enumerate environment could be:

\newenvironment{enumtight}[2]
  {\begin{list}{\labelenumi}{%
     \usecounter{enumi}%
     \setlength{\itemsep}{#1}%
     \setlength{\labelwidth}{#2}%
     \setlength{\leftmargin}{\labelwidth}%
     \addtolength{\leftmargin}{\labelsep}%
   }%
  }
  {\end{list}}

You only have to change \labelitemi to \labelenumi and add the line \usecounter{enumi} to let the list use this counter.

MWE:

\documentclass{article}

\newenvironment{itemizetight}[2]
  {\begin{list}{\labelitemi}{%
     \setlength{\itemsep}{#1}%
     \setlength{\labelwidth}{#2}%
     \setlength{\leftmargin}{\labelwidth}%
     \addtolength{\leftmargin}{\labelsep}%
   }%
  }
  {\end{list}}

\newenvironment{enumtight}[2]
  {\begin{list}{\labelenumi}{%
     \usecounter{enumi}%
     \setlength{\itemsep}{#1}%
     \setlength{\labelwidth}{#2}%
     \setlength{\leftmargin}{\labelwidth}%
     \addtolength{\leftmargin}{\labelsep}%
   }%
  }
  {\end{list}}

\begin{document}

\begin{itemizetight}{-0.2em}{0.5em}
\item[1.] item 1
\item[2.] item 2
\end{itemizetight}

\begin{enumtight}{-0.2em}{0.5em}
\item item 1
\item item 2
\end{enumtight}

\end{document}

Output:

enter image description here

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.