2

While writing a document with lots of enumerate environments, I wanted to add a little subset,

1. So the item is here 
     — and the inset is here

Which I did pretty easily. However, when I wanted to add to this to make it align paragraphs properly, I ran into problems. Does anyone know what I'm doing wrong with measuring the height of the \lrbox?

MWE:

\documentclass{article}
\usepackage{lipsum}
\usepackage{calc}

\newsavebox\mytextbox
\def\linelength{\linewidth-2em-1ex}
\newcommand{\two}[1]{%
    \vspace{3pt}\\\hspace*{1em}---\ 
    \begin{lrbox}{\mytextbox}\parbox[t]{\linelength}{#1}\end{lrbox}
    \parbox[t][\heightof{\usebox{\mytextbox}}][t]{\linelength}{\usebox{\mytextbox}}}

\begin{document}
    \begin{enumerate}
        \item Long Items 
        \item \lipsum*[1]
            \two{Second Level Item}
            \two{\lipsum*[2]}
            \two{Another second level item}
        \item A first level item
    \end{enumerate}
\end{document}

Output:

enter image description here

It doesn't seem to be measuring the box at all, and instead just assigning some kind of default height or something (\parbox doesn't have a default so it's confusing).

4

You're really overcomplicating things: just use a nested itemize:

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}


\begin{document}

\begin{enumerate}
\item Long Items
\item \lipsum*[1]
  \begin{itemize}[label=---,topsep=0pt]
  \item Second Level Item
  \item \lipsum*[2]
  \item Another second level item
  \end{itemize}
\item A first level item
\end{enumerate}

\end{document}

enter image description here

| improve this answer | |
  • This is better, but still slower to type than my way—is there a way to redefine the itemize symbol and topsep globally? – Ryan Dec 7 '14 at 10:45
  • @Ryan You can always say \newenvironment{two}{\itemize[label=---,topsep=0pt]}{\enditemize} and use \begin{two}\item ... \item ... \end{two} – egreg Dec 7 '14 at 10:46
  • Thanks, @egreg but no way to redefine the itimize symbol globally? – Ryan Dec 7 '14 at 10:48
  • @Ryan Sorry, but I don't understand. – egreg Dec 7 '14 at 10:50
  • 1
    @Ryan \setlist[itemize,1]{label=---,topsep=0pt} – egreg Dec 7 '14 at 10:54
0

Well, I guess I really overcomplicated that...

\documentclass{letter}
\usepackage{lipsum}
\usepackage{calc}

\def\linelength{\linewidth-2em-1ex}
\newcommand{\two}[1]{%
    \vspace{3pt}\\\hspace*{1em}---\ 
    \begin{minipage}[t]{\linelength}#1\\\end{minipage}
    \vspace*{-2\baselineskip}\\
}

\begin{document}
    \begin{enumerate}
        \item Long Items 
        \item \lipsum*[1]
            \two{Second Level Item}
            \two{\lipsum*[2]}
            \two{Another second level item}
        \item A first level item
    \end{enumerate}
\end{document}

By simply using a minipage, there aren't any measurement issues at all.

Output:

enter image description here

| improve this answer | |

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.