3

In the following MWE, I am trying to use the tabto package to annotate items in an itemize list:

But, I'd like the "Chapter" annotations to be vertically aligned with the first line of the item, not the last line. How can I do this?

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
]{microtype}
\usepackage{enumitem}

\usepackage{tabto}
\newcommand{\mytab}{\tabto{5.0cm}}

\begin{document}

\begin{itemize}
  \item{Fruits}
    \begin{itemize}
      \item{apples\\(crisp)}\mytab Chapter 1
      \item{oranges\\(juicy)}\mytab Chapter 1
    \end{itemize}
  \item{Vegetables}
    \begin{itemize}
      \item{cucumbers\\(crunchy)}\mytab Chapter 2
      \item{green beans\\(squishy)}\mytab Chapter 2
    \end{itemize}
\end{itemize}

\end{document}

mwe

2
  • 1
    Wouldn't is be easier to use a tabular for this task?
    – leandriis
    Dec 19, 2020 at 21:42
  • @leandriis How would I do that with the itemizes?
    – Andrew
    Dec 19, 2020 at 21:49

2 Answers 2

2

Don't put the \item contents in braces. Rather, slightly redefine \mytab, but its argument in braces AND place the \mytab at the start of the item.

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
]{microtype}
\usepackage{enumitem}

\usepackage{tabto}
\newcommand\mytab[1]{\tabto{5.0cm}#1\tabto*{\TabPrevPos}}

\begin{document}

\begin{itemize}
  \item{Fruits}
    \begin{itemize}
      \item\mytab{Chapter 1}apples\\(crisp)
      \item\mytab{Chapter 1}oranges\\(juicy)
    \end{itemize}
  \item{Vegetables}
    \begin{itemize}
      \item\mytab{Chapter 2}cucumbers\\(crunchy)
      \item\mytab{Chapter 2}green beans\\(squishy)
    \end{itemize}
\end{itemize}

\end{document}

enter image description here

1

Here is how you could imitate the look of the nested itemize uwing a tabular:

enter image description here

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
]{microtype}
\usepackage{enumitem}

\begin{document}

\begin{itemize}
  \item{Fruits}
  
  \begin{tabular}{@{\quad}l@{\;}p{5cm}l}
   -- & apples  &  Chapter 1\\
      &(crisp)              \\[5pt]
   -- & oranges & Chapter 1 \\
      & (juicy)             \\ 
  \end{tabular}
  \item{Vegetables}
  
  \begin{tabular}{@{\quad}l@{\;}p{5cm}l}
   -- & cucumbers   & Chapter 2 \\
      &(cucumbers)              \\[5pt]
   -- & green beans & Chapter 2 \\
      & (squishy)               \\ 
  \end{tabular}
\end{itemize}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .