我想将一个 itemize 环境用括号括起来,并将其括在 itemize 环境里面。
\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}
有没有办法在 itemize 环境中做到这一点
请问 Harish Kumar 教授,在这种情况下,对于长文本和短文本以及反之亦然,我该怎么做,如下所示:
\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}
答案1
像这样?
\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}
使用宏
如果您最终需要多次使用它,您可以制作一个宏。
\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}
对编辑后的查询的回复
这里我们做一些假设:
- 子项的长度可以变化
- 但它们足够短,不会跨越多行(因为如果跨越多行,那么描述就变得毫无意义)
基于这些假设,你可以将子 itemize 环境放入minipage
宽度等于0.5\textwidth
环境中。您可以根据需要改变此宽度。
\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]
另一个选择是将每个子项放在\parbox
宽度为的范围内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}