I am trying to make an enumerate list that should produce the list with tikz node and with automatic numbering e.g Problem 1:, Problem 1.1:, and Problem 2:.

I write the tikz code that only generates the single Problem by mentioning the number myself.

My code is as follows:

\documentclass[a4paper, 12pt]{article}


        text width=1\textwidth-1cm, 
        rounded corners=0.2cm,
        inner sep=0.5cm,

    \noindent\tikz \node[problem](instructions) {#1};

    \problem{\tb{Problem 1:} Explain the term Least Significant Bit (LSB).}
    \problem{\tb{Problem 2:} Explain the term Most Significant Bit (MSB).}
    \problem{\tb{Problem 2.1:} Why MSB is used?}
    \problem{\tb{Problem 2.2:} Why LSB is used in x86 architecture?}
    \problem{\tb{Problem 3:} Assemble the given program and update the values of the registers after single step execution.}

Its output is problems list

How can I generate a similar list with enumerate environment with automatically numbering Problem 1:, Problem 1.1:, and Problem 2:, with the tikz node style (red background color and border)?

1 Answer 1


I would do this by tcolorbox and two counters:

enter image description here



\pgfmathsetlengthmacro\mysep{4mm}% 4mm = default of tcolorbox for left, right
boxrule=0.4pt, % default value TikZ
colframe=red!60!black,   colback=red!10,
top=\mysep, bottom=\mysep,
left=\mysep, right=\mysep,       %boxsep=0mm, 
tcbox width=forced left,
beforeafter skip=1.125\baselineskip, 

before upper={%
\textbf{Problem \themainno.\thesubno:}~
after upper=\end{varwidth},    #1}

before upper={%
\textbf{Problem \themainno:}~
after upper=\end{varwidth},   #1}

%  \subbox{Sub item}
  \mainbox{Main item}

  \mainbox{Main item} 
  \subbox{Sub item}
  \subbox{Sub item}

  \mainbox{Main item}
    \subbox{Sub item. This ia a very long text. This ia a very long text. This ia a very long text. This ia a very long text.}

%  \mainbox{Main item} 
%  \subbox{Sub item}
%   \subbox{Sub item}

You must log in to answer this question.

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