3

I'm using a \rule in a custom list environment to push down the text, but doing this seems to add vertical space both before and after. You can tell there is vertical space because the first item does not line up with the column separator. How do I get rid of the space before?

\documentclass[10pt]{article}
\usepackage[inner=1.1in,outer=.7in,top=.9in,bottom=1in,paperwidth=8.5in,paperheight=11in,twoside]{geometry}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{tikz}

\setlength{\columnsep}{1cm}
\setlength{\columnseprule}{0.3pt}

\newlist{qenum}{enumerate}{2}
\setlist[qenum,1]{
  leftmargin=12pt,
  labelsep=10pt,
  label={\protect\begin{tikzpicture}[]
    \protect\node[overlay,text width={\linewidth + 8mm},fill=lightgray,anchor=west,inner sep=0pt,minimum height=1.1em] (bg) {};
    \protect\node[overlay,anchor=west,minimum height=1.1em,inner sep=0pt,fill=black,align=center,text width=1.9em,text=white] at (bg.west) {\arabic*};
    \protect\node {\rule[3em]{0pt}{15pt}}; % this is part of the issue
    \protect\end{tikzpicture}}
  }
\setlist[qenum,2]{label=\Alph*),topsep=0pt,leftmargin=22pt,labelsep=7pt,itemsep=-2pt}

\begin{document}

\begin{multicols*}{2}
\raggedcolumns\raggedright
\begin{qenum}

\item For ${i = \sqrt{-1}}$, which of the following is equivalent to $(5 - 3i) - (-2 + 5i)$? % C
\begin{qenum}
\item 
\item 
\item 
\item 
\end{qenum}

\item Which of the following is equal to ${(5 + 2i)(5 - 2i)}$? (Note: $i = \sqrt{-1}$) % B
\begin{qenum}
\item 
\item 
\item 
\item 
\end{qenum}
\end{qenum}
\end{multicols*}

\end{document}

enter image description here

  • it isn't clear which space you do not want also why use a rule rather than specify the space using enumitem? If you change the rule to be 1pt wide you just see each entry is pushed down by a rule in its label, what did you want to happen? – David Carlisle Jan 27 '16 at 16:03
  • don't you just want to specify itemsep for the outer list? – David Carlisle Jan 27 '16 at 16:04
  • If you change \protect\node {\rule[3em]{0pt}{15pt}}; to \protect\node {\rule[0em]{0pt}{0pt}};, you will see that the text runs into the gray bar. If this didn't happen, then changing the itemsep would be fine. – Nelson Jan 27 '16 at 16:10
3

The rule won't work as it occupies more space than you want. If you don't want to use Davids solution you could change the baseline of the tikzpicture with the baseline-key:

\documentclass[10pt]{article}
\usepackage[inner=1.1in,outer=.7in,top=.9in,bottom=1in,paperwidth=8.5in,paperheight=11in,twoside]{geometry}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{tikz}

\setlength{\columnsep}{1cm}
\setlength{\columnseprule}{0.3pt}

\newlist{qenum}{enumerate}{2}
\setlist[qenum,1]{
  leftmargin=12pt,
  labelsep=0pt,
  align=left,
  label={\protect\begin{tikzpicture}[baseline=-2em]
    \protect\node[minimum height=1.1em]{};% force minimum height
    \protect\node[overlay,text width={\linewidth + 8mm},fill=lightgray,anchor=west,inner sep=0pt,minimum height=1.1em] (bg) {};
    \protect\node[overlay,anchor=west,minimum height=1.1em,inner sep=0pt,fill=black,align=center,text width=1.9em,text=white] at (bg.west) {\arabic*};
    \protect\end{tikzpicture}}
  }
\setlist[qenum,2]{label=\Alph*),topsep=0pt,leftmargin=22pt,labelsep=7pt,itemsep=-2pt}

\begin{document}

\begin{multicols*}{2}
\raggedcolumns\raggedright
\begin{qenum}

\item For ${i = \sqrt{-1}}$, which of the following is equivalent to $(5 - 3i) - (-2 + 5i)$? % C
\begin{qenum}
\item
\item
\item
\item
\end{qenum}

\item Which of the following is equal to ${(5 + 2i)(5 - 2i)}$? (Note: $i = \sqrt{-1}$) % B
\begin{qenum}
\item
\item
\item
\item
\end{qenum}
\end{qenum}
\end{multicols*}

\end{document}
2

rather than make the grey box have zero space let it be natural size then the list automatically adjusts:

enter image description here

\documentclass[10pt]{article}
\usepackage[inner=1.1in,outer=.7in,top=.9in,bottom=1in,paperwidth=8.5in,paperheight=11in,twoside]{geometry}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{tikz}

\setlength{\columnsep}{1cm}
\setlength{\columnseprule}{0.3pt}

\newlist{qenum}{enumerate}{2}
\setlist[qenum,1]{
  leftmargin=12pt,
  labelsep=10pt,
  itemsep=15pt,
 align=left,
  label={\protect\begin{tikzpicture}[]
    \protect\node[text width={\linewidth + 8mm},fill=lightgray,anchor=west,inner sep=0pt,minimum height=1.1em] (bg) {};
    \protect\node[anchor=west,minimum height=1.1em,inner sep=0pt,fill=black,align=center,text width=1.9em,text=white] at (bg.west) {\arabic*};
 %   \protect\node {\rule[20pt]{1pt}{5pt}}; % this is part of the issue
    \protect\end{tikzpicture}}
  }
\setlist[qenum,2]{label=\Alph*),topsep=0pt,leftmargin=22pt,labelsep=7pt,itemsep=-2pt}

\begin{document}

\begin{multicols*}{2}
\raggedcolumns\raggedright
\begin{qenum}

\item For ${i = \sqrt{-1}}$, which of the following is equivalent to $(5 - 3i) - (-2 + 5i)$? % C
\begin{qenum}
\item 
\item 
\item 
\item 
\end{qenum}

\item Which of the following is equal to ${(5 + 2i)(5 - 2i)}$? (Note: $i = \sqrt{-1}$) % B
\begin{qenum}
\item 
\item 
\item 
\item 
\end{qenum}
\end{qenum}
\end{multicols*}

\end{document}

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.