4

I have a macro that has itemize environment in it. I'm trying to remove the spaces between items, preceding, and following texts with control commands, but I still have spaces. How can I remove them? (How can I make tighter itemize environment?)

\documentclass{article}
\usepackage{booktabs}
\newcommand{\fuda}[2]{%
Function:%
\begin{itemize}%
#1%
\end{itemize} \topsep0pt \parskip0pt \partopsep0pt \itemsep0pt \parsep0pt
Data:%
\begin{itemize}%
#2%
\end{itemize}%
}
\begin{document}
\noindent
\fuda{%
\item A%
\item B}
{%
\item X%
\item Y
}
\end{document}

enter image description here

4

itemize sets its own spacing parameters at call time, so setting them before calling it is useless. You can do it easily with enumitem:

\documentclass{article}
\usepackage{enumitem}
\newcommand{\fuda}[2]{%
  Function:
  \begin{itemize}
  #1
  \end{itemize}
  Data:
  \begin{itemize}[nosep]
  #2
  \end{itemize}
}
\begin{document}
\noindent
\fuda{
  \item A
  \item B
}{
  \item X
  \item Y
}
\end{document}

This is a place where almost no % is needed in the definition body, but they don't hurt, either.

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.