1

Im trying to get something like the picture but Im not able to get the rectangle to the next line and have a horizontal space between the items

enter image description here

\usepackage[inline]{enumitem}
\begin{document}
\begin{enumerate*}[label=(\alph*)]
    \item eigth  \addtocounter{enumi}{1}
    \begin{tikzpicture}[%
        baseline=(current bounding box.north west),
        level/.style={sibling distance=10mm/#1},scale =0.5
      ]

      \draw [draw=black] (2,4) rectangle (0,0);

    \end{tikzpicture}

    \item 
    \begin{tikzpicture}[%
        baseline=(current bounding box.north),
        level/.style={sibling distance=10mm/#1},scale =0.5
      ]

      \draw [draw=black] (2,4) rectangle (0,0);

    \end{tikzpicture}
\end{enumerate*}
\end{document}
1
  • Do you really need a hammersledge like tikz for that? – Bernard May 13 '20 at 18:27
1

Just make the text a node the baseline of which you make the baseline of the tikzpicture.

\documentclass{article}
\usepackage{tikz}
\usepackage[inline]{enumitem}
\begin{document}
\begin{enumerate*}[label=(\alph*)]
    \item  \begin{tikzpicture}[baseline=(X.base)]
      \node(X) {eigth};

      \draw [draw=black,path picture={
      \draw (path picture bounding box.south) -- 
      (path picture bounding box.north);
      }] ([yshift=-1ex]X.south west) rectangle ++ (2,-4);

    \end{tikzpicture}\addtocounter{enumi}{1}

    \item \begin{tikzpicture}[baseline=(X.base)]
      \node(X) {eleven};

      \draw [draw=black,path picture={
      \draw (path picture bounding box.south) -- 
      (path picture bounding box.north);
      }] ([yshift=-1ex]X.south west) rectangle ++ (2,-4);

    \end{tikzpicture}
\end{enumerate*}
\end{document}

enter image description here

This does not introduce horizontal spacing between the items, but you can add such spacing e.g. by adding \path ([xshift=2em]current bounding box.east); to the tikzpicture.

7
  • 2
    It could be easier to add the horizontal spacing using enumitem's itemjoin key in the options of the enumerate environment. – Vincent May 13 '20 at 17:48
  • 1
    @Vincent Thanks! Yes, this is a good point. I was meaning to say that this does not introduce unwanted additional spacing but you are right, the enumitem methods are more appropriate to obtain consistent spacing. – user194703 May 13 '20 at 17:50
  • 1
    @JoesphMama It is the ,path picture={ \draw (path picture bounding box.south) -- (path picture bounding box.north); }. This is a trick that adds a vertical line in the middle, which will be in the middle even when you change the dimensions of the rectangle. – user194703 May 13 '20 at 18:37
  • 1
    @JoesphMama Then you may need a different construction. It depends on which lines (horizontal, vertical, whatever), equally spaced or not, and so on. This post was written to produce something along the lines of the screen shot you posted. – user194703 May 13 '20 at 18:41
  • 1
    @JoesphMama One example: add \usetikzlibrary{calc} to the preamble and use \draw [draw=black,path picture={ \draw foreach \X in {1,2}{($(path picture bounding box.south west)!\X/3!(path picture bounding box.south east)$) -- ($(path picture bounding box.north west)!\X/3!(path picture bounding box.north east)$)}; }] ([yshift=-1ex]X.south west) rectangle ++ (2,-4);. There are zillions of possibilities, and if one proposes one typically many additional answers pop up suggesting the poster of the first option was unaware of all the other options.... ;-) – user194703 May 13 '20 at 21:05

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.