1

Is it possible to define a list environment where each item has a user-specified amount of space below it? I'm looking for something to the effect of

\begin{myitemize}
    \item[1in] One
    \item[.5in] Two
    \item[2in] Three
\end{myitemize}

Some text...

In the compiled document, there should be 1 in of space between "One" and "Two", .5 in between "Two" and "Three", and 2 in between "Three" and "Some text".

My best attempt so far resembles

\documentclass{article}

\newlength{\itemspace}
\let\olditem\item

\newenvironment{myitemize}{
    \setlength{\itemspace}{0in}
    \begin{itemize}
    \renewcommand{\item}[1][0in]{
        \vspace{\itemspace}
        \olditem
        \setlength{\itemspace}{##1}}
}{
    \vspace{\itemspace}
    \end{itemize}
}


\begin{document}
 Some text
\begin{myitemize}
\item[0in] Foo\underline{\hspace{4.3in}}
\item Bar
\item Baz
\end{myitemize}
Some other text
\end{document}

The problem shows up in the first item. With 0in specified, the spacing between Foo and Bar should be the same as the spacing between Bar and Baz. However, I get something like this:

image

The problem seems to be that the length of the first line is exactly the maximum line width. Adding the vspace afterwards seems to be also add a small amount of horizontal space, forcing TeX to start a new line before the next item. Shortening the hspace to only 4.2in causes the extra line to disappear.

Edit: For an even simpler example of my problem,

\begin{itemize}
\item Foo\underline{\hspace{4.3in}}\vspace{0in}
\item Bar
\item Baz
\end{itemize}

has no extra line, but

\begin{itemize}
\item Foo\underline{\hspace{4.3in}}
\vspace{0in}
\item Bar
\item Baz
\end{itemize}

does. Why does this happen?

  • 1
    isn't this \vspace{1in}\item One \vspace{xx} \item two ? – David Carlisle Jan 27 '16 at 10:37
  • Not quite... that places the 1in of vspace above \item one, whereas I'd like it below. I did try something similar; however, it leads to some unwanted behavior in certain cases. I've added more detail to my original question to clear things up. – TheMac Jan 27 '16 at 22:45
  • Yes sure but put the 1in before the second item in that case. Your horizontal space is most likely due to you not using %` at ends of lines so adding white space (also you should have a \par or blank line before vspace. – David Carlisle Jan 27 '16 at 23:29
0

the bad spacing in your example is due to the spurious space you've added from the end of line characters, This just adds \par before \vspace so it is used in vertical mode, and % to avoid adding white space

\documentclass{article}

\newlength{\itemspace}
\let\olditem\item

\newenvironment{myitemize}{%
    \setlength{\itemspace}{0in}%
    \begin{itemize}%
    \renewcommand{\item}[1][0in]{%
        \par\vspace{\itemspace}%
        \olditem
        \setlength{\itemspace}{##1}}%
}{%
    \par\vspace{\itemspace}%
    \end{itemize}%
}


\begin{document}
 Some text
\begin{myitemize}
\item[0in] Foo\underline{\hspace{4.3in}}
\item Bar
\item Baz
\end{myitemize}
Some other text
\end{document}

enter image description here

  • Thanks! I guess I'm still a little confused about how TeX interprets ends of lines, though - can you recommend any resources for explaining this? – TheMac Jan 27 '16 at 23:46
  • @TheMac it treats them exactly the same as a space. but see tex.stackexchange.com/questions/7453/… – David Carlisle Jan 27 '16 at 23:53

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.