我需要在偶数个项目符号前加上花括号。下面的帖子对于奇数个项目符号来说非常有效。
我们如何才能将其修改为偶数个子弹?
更新:
有可能有一个通用的解决方案,可以根据我们拥有的子弹数量自动调整。
我正在使用 \documentclass{beamer}。但这应该没关系。我之所以放这条信息,是因为所有发布的解决方案都有 \documentclass{article}
我的编辑器(左侧面板)和 PDF(右侧面板)的快照
答案1
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{itemize}
\item Riemann Sum
\item Trapezoidal Rule
\item Simpson's 1/3 Rule
\item Simpson's 3/8 Rule %
\smash{\raisebox{.5\dimexpr3\baselineskip+4\itemsep+2\parskip}{$\left.\rule{0pt}{.5\dimexpr4\baselineskip+3\itemsep+3\parskip}\right\}\text{Newton Cotes formulae of different degrees}$}}
\end{itemize}
\end{document}
对于beamer
课堂来说,\linewidth
要小得多,您需要将文本放入\parbox
以允许文本换行。还请注意,itemize
beamer 中的环境与普通课堂中的环境完全不同,因此,您可能需要进行一些手动调整:
\documentclass{beamer}
\usepackage{amsmath,lmodern}
\begin{document}
\newcommand{\insm}{%
\smash{\raisebox{.5\dimexpr3\baselineskip+4\itemsep+2\parskip}{$\left.\rule{0pt}{.5\dimexpr4\baselineskip+3\itemsep+3\parskip}\right\}$\ \parbox{5.5cm}{Newton Cotes formulae of different degrees}}}
}
\begin{frame}
\begin{itemize}
\item Riemann Sum
\item Trapezoidal Rule
\item Simpson's 1/3 Rule
\item Simpson's 3/8 Rule \insm
\end{itemize}
\end{frame}
\end{document}
最后,一个灵活的tikz
解决方案(因为我个人很喜欢 tikz,所以我决定发布一个使用 tikz 的替代漂亮解决方案):
\documentclass{beamer}
\usepackage{amsmath,lmodern,calc,tikz,textcomp}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\newcommand\insm{%
$\left.\rule{0pt}{2.5\baselineskip}\right\}$\parbox{\textwidth-2ex}{%
\begin{itemize}
\item[\textbullet] Newton Cotes formulae ...
\item[\textbullet] Newton Cotes formulae ...
\end{itemize}}
}
\begin{frame}
\begin{itemize}
\item Riemann Sum
\item Trapezoidal Rule\tikzmark{S}
\item Simpson's 1/3 Rule\tikzmark{E}
\item Simpson's 3/8 Rule
\end{itemize}
\tikz[remember picture, overlay]{%
\node [shift={(1ex,.6ex)},text width=6.5cm,anchor=west] at ($(pic cs:S)!.5!(pic cs:E)$){\insm};}
\end{frame}
\end{document}
答案2
适用于任何类型的元素(\item
项目符号(偶数或奇数)或其他)的一个选项是使用 TikZ 及其tikzmark
库。在所需位置放置一些标记,然后使用这些标记绘制括号及其附带的文本:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark,decorations.pathreplacing}
\begin{document}
\begin{itemize}
\item Riemann Sum\tikzmark{start}
\item
Trapezoidal Rule
\item
Simpson's 1/3 Rule
\item
Simpson's 3/8 Rule\tikzmark{end}
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
([yshift=2ex]{{pic cs:end}|-{pic cs:start}}) --
node[xshift=15pt,anchor=west] {some test text}
([yshift=-0.5ex]pic cs:end);
\end{tikzpicture}
\end{document}
答案3
我建议建立一个环境braceditemize
,模拟itemize
环境内的环境。blockarray
它有一个可选参数,即括号右侧的文本:
\documentclass{article}
\usepackage{mathtools, etoolbox}
\usepackage{blkarray}
\usepackage[showframe, nomarginpar]{geometry}
\newcommand\tabitem{\ifbool{firstrow}{\relax}{\\[\itemsep]}\boolfalse{firstrow}\makebox[\labelwidth][r]{\textbullet}\hspace*{\labelsep}}
\newbool{firstrow}
\newenvironment{braceditemize}[1][]{%
\booltrue{firstrow}
\vspace*{\topsep}\par\noindent
\setlength\BAextrarowheight{\parsep}\begin{blockarray}{@{}l <{\enspace}\Right{\}}{#1}}}
{\rule[-\itemsep-\parsep]{0pt}{\itemsep + \parsep}\end{blockarray}}
\begin{document}
Text text text text text text text text text text text text text
\begin{braceditemize}[Newton-Cotes formulae of different degrees]
\tabitem Riemann Sum
\tabitem Trapezoidal Rule
\tabitem Simpson's 1/3 Rule
\tabitem Simpson's 3/8 Rule
\end{braceditemize}
\end{document}
答案4
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{itemize}
\item Riemann Sum
\item
Trapezoidal Rule
\item
Simpson's 1/3 Rule
$\smash{\left.\rule{0pt}{.5\dimexpr3\baselineskip+2\itemsep+2\parskip}\right\}
\text{Newton Cotes formulae of different degrees}}$
\item
Simpson's 3/8 Rule
\end{itemize}
\begin{itemize}
\item Riemann Sum
\item
Trapezoidal Rule
\item
Simpson's 1/3 Rule
\smash{\raisebox{.5\dimexpr\baselineskip+\itemsep+\parskip}{%
$\left.\rule{0pt}{.5\dimexpr4\baselineskip+3\itemsep+3\parskip}\right\}$
Newton Cotes formulae of different degrees}}
\item
Simpson's 3/8 Rule
\end{itemize}
\end{document}