Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to enclose an itemize environment with a bracket inside an itemize environment.

\documentclass[a4paper]{article}
 \usepackage{enumitem}
 \usepackage{pifont}
\begin{document}
\begin{itemize}[label=\ding{42}, leftmargin=2cm]
   \item  Example I
   \item Example II
        \begin{itemize}
                    \left. 
                          \begin{array}{ll}
        \item SubExample II-1
        \item SubExample II-2
                          \end{array}
                      \right \}=Text
         \end{itemize}
    \item Example III
    \item Example IV
                \end{itemize}
\end{document}

enter image description here

Is there any way to do that in itemize environnment

Please Prof. Harish Kumar what can i do in this case with long text and short text and vice-versa as you see below :

enter image description here

\documentclass[a4paper]{article}
\usepackage{tikz,xparse}
\usetikzlibrary{decorations.pathreplacing,}
\newcommand{\tikzmark}[1]{\tikz[baseline={(#1.base)},overlay,remember picture] \node[outer sep=0pt, inner sep=0pt] (#1) {\phantom{A}};}

%% syntax
%%%\mybrace{<first>}{<second>}[<Optional text>]
\NewDocumentCommand\mybrace{mmo}{%
\IfValueTF {#3}{%
\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=1ex}]
  \draw[decorate,thick] (#1.north east) -- (#2.south east) node[midway, right=0.1cm] {$=$}node[midway, right=0.5cm,text=black,text width = 2in,] {{#3}};
\end{tikzpicture}%
}%
{%
\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=1ex}]
  \draw[decorate,thick] (#1.north east) -- (#2.south east);
\end{tikzpicture}%
}%
}%

\begin{document}
\begin{itemize}
   \item  Example I
   \item Example II
        \begin{itemize}
        \item long text bla bla bla\tikzmark{a}
        \item short text bla\tikzmark{b}
         \end{itemize}
    \item Example III
    \item Example IV
\end{itemize}
\mybrace{a}{b}[Text comes here to describe these to items and justify for your case]

\end{document}
share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Like this?

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,}
\newcommand{\tikzmark}[1]{\tikz[baseline={(#1.base)},overlay,remember picture] \node[outer sep=0pt, inner sep=0pt] (#1) {\phantom{A}};}

\begin{document}
\begin{itemize}
   \item  Example I
   \item Example II
        \begin{itemize}                    
        \item SubExample II-1\tikzmark{a}
        \item SubExample II-2\tikzmark{b}
         \end{itemize}
    \item Example III
    \item Example IV
\end{itemize}
\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=2pt}]
  \draw[decorate,thick] (a.north east) -- (b.south east) node[midway, right=0.1cm] {$=$}node[midway, right=0.5cm,text=black,text width = 2in,] {Text comes here to describe these to items and justify for your case};
\end{tikzpicture}%
\end{document}

enter image description here

With a macro

You can make a macro, if you end up using it for many times.

\documentclass[a4paper]{article}
\usepackage{tikz,xparse}
\usetikzlibrary{decorations.pathreplacing,}
\newcommand{\tikzmark}[1]{\tikz[baseline={(#1.base)},overlay,remember picture] \node[outer sep=0pt, inner sep=0pt] (#1) {\phantom{A}};}

%% syntax
%%%\mybrace{<first>}{<second>}[<Optional text>]
\NewDocumentCommand\mybrace{mmo}{%
\IfValueTF {#3}{%
\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=1ex}]
  \draw[decorate,thick] (#1.north east) -- (#2.south east) node[midway, right=0.1cm] {$=$}node[midway, right=0.5cm,text=black,text width = 2in,] {{#3}};
\end{tikzpicture}%
}%
{%
\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=1ex}]
  \draw[decorate,thick] (#1.north east) -- (#2.south east);
\end{tikzpicture}%
}%
}%

\begin{document}
\begin{itemize}
   \item  Example I
   \item Example II
        \begin{itemize}
        \item SubExample II-1\tikzmark{a}
        \item SubExample II-2\tikzmark{b}
         \end{itemize}
    \item Example III
    \item Example IV
\end{itemize}
\mybrace{a}{b}[Text comes here to describe these to items and justify for your case]

\end{document}

enter image description here

Response to the edited query

Here we make some assumptions:

  1. The sub items can have variable length
  2. But they are short enough not to span multiple lines (for if they do, then description becomes meaningless)

With these assumptions, you can put the sub itemize environment inside a minipage of width equal to 0.5\textwidth. You can vary this width as per your need.

\begin{itemize}
   \item  Example I
   \item Example II
      \begin{minipage}[t]{0.5\textwidth}
        \begin{itemize}
        \item SubExample II-1 just more length\tikzmark{a}
        \item SubExample II-2\hfill\tikzmark{b}
         \end{itemize}
      \end{minipage}
    \item Example III
    \item Example IV
\end{itemize}
\mybrace{a}{b}[Text comes here to describe these to items and justify for your case]

Another option will be to put each sub item inside a \parbox of width 0.5\textwidth:

\documentclass[a4paper]{article}
\usepackage{tikz,xparse}
\usetikzlibrary{decorations.pathreplacing,}
\newcommand{\tikzmark}[1]{\tikz[baseline={(#1.base)},overlay,remember picture] \node[outer sep=0pt, inner sep=0pt] (#1) {\phantom{A}};}

%% syntax
%%%\mybrace{<first>}{<second>}[<Optional text>]
\NewDocumentCommand\mybrace{mmo}{%
\IfValueTF {#3}{%
\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=1ex}]
  \draw[decorate,thick] (#1.north east) -- (#2.south east) node[midway, right=0.1cm] {$=$}node[midway, right=0.5cm,text=black,text width = 2in,] {{#3}};
\end{tikzpicture}%
}%
{%
\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=1ex}]
  \draw[decorate,thick] (#1.north east) -- (#2.south east);
\end{tikzpicture}%
}%
}%

\begin{document}
\begin{itemize}
   \item  Example I
   \item Example II \par
      %\begin{minipage}{0.5\textwidth}
        \begin{itemize}
        \item \parbox[t]{0.5\textwidth}{SubExample II-1 just more length as they come here}\tikzmark{a}
        \item \parbox{0.5\textwidth}{SubExample II-2}\tikzmark{b}
         \end{itemize}
%      \end{minipage}
    \item Example III
    \item Example IV
\end{itemize}
\mybrace{a}{b}[Text comes here to describe these to items and justify for your case]

\end{document}

enter image description here

share|improve this answer
    
@@Harish Kumar Please Prof. Harish Kumar Check the second code with marco doesn't work !! –  Educ Feb 20 at 8:58
    
@Educ It works, but you have to compile it atleast 2-3 times. Did you? :) And you have to have xparse package installed. –  Harish Kumar Feb 20 at 9:03
    
@@Harish Kumar Please Prof. Harish Kumar i upadate my question :what can i do in this case with long text and short text –  Educ Feb 20 at 9:31
1  
@Educ Please see the update at the end. –  Harish Kumar Feb 20 at 13:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.