我觉得答案应该很明显,但我却想不出来。我附上了一张我需要的图片(7 个项目垂直排列在不同行上:item1、item2、item3、item4、item5、item7、item7 以及一个左花括号,横跨项目 1-7,居中标签为 Z,右花括号横跨项目 1-4,标签为 A,另一个右花括号横跨项目 5-7,标签为 B)。我还附上了一个示例代码,它有一个左括号和一个右括号,横跨项目 1-7。问题是如何在右侧生成 2 个括号
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
X \left\{
\begin{gathered}
\text{item 1} \\
\text{item 2} \\
\text{item 3} \\
\text{item 4} \\
\text{item 5} \\
\text{item 6} \\
\text{item 7}
\end{gathered} \right\} Y
\end{equation*}
\end{document}
非常感谢!
最佳答案
3
与 Sigur 的答案类似,但没有cases
,而是使用array
:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
Z \left\{
\begin{array}[c]{@{}l@{}}
\!\left.
\begin{tabular}[c]{@{}l@{}}
item 1 \\
item 2 \\
item 3 \\
item 4 \\
\end{tabular}
\right\} A
\\
\!\left.
\begin{tabular}[c]{@{}l@{}}
item 5 \\
item 6 \\
item 7 \\
\end{tabular}
\right\} B
\end{array}
\right.\!
\end{equation*}
\end{document}
4
-
1请解释一下最后一个
\!
吗?
–
-
1@Sigur 正确居中。每个
\left.
都会\right.
添加一些填充,如果不需要,则需要将其删除。
– -
1哦,我明白了…将整个等式内容置于中心…很好!
– -
非常感谢,请参阅我的另一个回答,它是给你们两个的。
–
|
像这样?
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
X
\begin{cases}
\left.
\begin{tabular}{l}
item 1 \\
item 2 \\
item 3 \\
item 4
\end{tabular}
\right\} A \\
\left.
\begin{tabular}{l}
item 5 \\
item 6 \\
item 7
\end{tabular}
\right\} B
\end{cases}
\end{equation*}
\end{document}
5
-
非常感谢你们!真希望我能请你们每人喝一杯!我已经花了几个小时和 chatgpt 和 gemini 一起尝试回答这个问题,但他们无法做到。而你用你的人类智慧很快就做到了。我真的非常感谢你们。我以前从未使用过方程式,所以我无法在这两个答案之间做出决定。我只想感谢你们。希望这也能在未来帮助到别人。
– -
1@vtheb,欢迎来到 TEX.SE。学习 TeX 的一个好方法是研究这里人们编写的代码。恕我直言,我建议不要花时间研究 GPT。在这里搜索并研究代码。祝你有美好的一天。
– -
1嗨@vtheb,我也欢迎你。就像 Sigur 说的,不要为 GPT 或类似的 LLM 烦恼。根据我的经验,它们只适用于你已经至少具备基础知识来过滤幻觉的领域。太多人认为这些人工智能说的话是理所当然的,或者太信任它们了。至于接受哪个答案:无论你认为哪个看起来更好,或者如果有疑问,接受更快的那个。两者的基本思想是相同的。
– -
1@vtheb,除了 Skillmon 的评论,如果你仔细观察,会发现我的解决方案中的括号对齐方式略有不同。我会选择使用另一种方法,因为它具有完美的垂直对齐方式。但如果你认为我的代码更容易学习,请不要担心。重要的是学习 TeX 并享受它。
– -
谢谢你们!我已经使用基本的 LaTeX 来写论文和海报 10 年了,这只是我第二次找不到我的问题的答案(以前从未使用过方程式)。法学硕士被吹捧为非常适合编码,有趣的是你说“别费心了”,因为他们只是让我在很多提示中转来转去。ChatGPT 甚至无法理解一个括号跨越 4 行而另一个只有 3 行的概念,它一直在右侧产生大小相同的括号(使用 tikz!?!?),无论我如何重新表述它。
–
|
您可以使用nicematrix
\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}
\begin{document}
\begin{equation*}
\begin{NiceMatrix}
\Block{7-1}{Z} & \text{item 1} & \Block{4-1}{A}\\
& \text{item 2} \\
& \text{item 3} \\
& \text{item 4} \\
& \text{item 5} & \Block{3-1}{B} \\
& \text{item 6} \\
& \text{item 7} \\
\CodeAfter
\SubMatrix\{{1-2}{7-2}.
\SubMatrix.{1-2}{4-2}\}
\SubMatrix.{5-2}{7-2}\}
\end{NiceMatrix}
\end{equation*}
\end{document}
如果您希望物品周围有一些空间,请使用NiceArray
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}
\begin{document}
\begin{equation*}
\begin{NiceArray}{c>{\ }c<{\ }c}
\Block{7-1}{Z} & \text{item 1} & \Block{4-1}{A}\\
& \text{item 2} \\
& \text{item 3} \\
& \text{item 4} \\
& \text{item 5} & \Block{3-1}{B} \\
& \text{item 6} \\
& \text{item 7} \\
\CodeAfter
\SubMatrix\{{1-2}{7-2}.
\SubMatrix.{1-2}{4-2}\}
\SubMatrix.{5-2}{7-2}\}
\end{NiceArray}
\end{equation*}
\end{document}
|
|