Latex:数学之外的可拉伸花括号

发布于 2024-08-31 01:52:00 字数 513 浏览 7 评论 0原文

我正在制作一些乳胶投影仪幻灯片(但我认为这本身不是投影仪特定的问题)。

我有以下内容:

\begin{itemize}
\item Issue1
\item Issue2
\item Issue3
\end{itemize}

现在,我希望在问题 1 问题 2 上分布的项目后面有一个右大括号(即“}”)。当然,我想在大括号后面写一些东西。

在完美的世界中,我会写这样的内容:

\begin{itemize}
\left .
\item Issue1
\item Issue2
\right \} One and Two are cool
\item Issue3
\end{itemize}

这不起作用,因为我不在数学环境中,并且我无法将整个片段放入数学环境中,因为在这种情况下逐项排列将不起作用。

是否有一个干净的解决方案或黑客来产生我想要的结果?

问候, 巴斯蒂安.

I am producing some latex beamer slides (but I think it is not a beamer specific question per se).

I have the following:

\begin{itemize}
\item Issue1
\item Issue2
\item Issue3
\end{itemize}

Now, I want to have a right curly brace (i.e. '}') behind the items spreading over issue1 and issue2. And of course I want to write something behind that curly brace.

In a perfect world I would write something like:

\begin{itemize}
\left .
\item Issue1
\item Issue2
\right \} One and Two are cool
\item Issue3
\end{itemize}

This does not work because I am not in a math environment and I can not put the whole snippet inside a math environment because itemize would not work in that case.

Is there a clean solution or a hack to produce my desired result?

Regards,
Bastian.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

贪了杯 2024-09-07 01:52:00

我会使用 tikz 并制作一个叠加层。

首先包含正确的包(您可能不需要包含 tikz 因为这是一个投影仪问题):

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

然后,当您创建列表时,为每个项目后面的位置指定名称:(

\begin{itemize}
    \item Issue 1     
        \tikz[remember picture] \node[coordinate,yshift=0.5em] (n1) {}; 
    \item Issue 2
        \tikz[remember picture] \node[coordinate] (n2) {};
    \item Issue 3
\end{itemize}

注意: 我将 y 值向上移动了 1/2 行,也许更多会更好。)

因为我们使用了 remember picture 我们可以参考这些地方覆盖:

  \begin{tikzpicture}[overlay,remember picture]
      \path (n2) -| node[coordinate] (n3) {} (n1);
      \draw[thick,decorate,decoration={brace,amplitude=3pt}]
            (n1) -- (n3) node[midway, right=4pt] {One and two are cool};
  \end{tikzpicture}

路径用于处理宽度不同的项目。此编辑来自 ESultanik 的回答

结果是:

alt text

旁注:您可以删除所有记住图片选项并添加以下内容以自动将记住添加到所有图片:

\tikzstyle{every picture}+=[remember picture]

I'd use tikz and make an overlay.

First include the proper packages (you may not need to include tikz since this is a beamer question):

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

Then when you make your list, give names to the places after each item:

\begin{itemize}
    \item Issue 1     
        \tikz[remember picture] \node[coordinate,yshift=0.5em] (n1) {}; 
    \item Issue 2
        \tikz[remember picture] \node[coordinate] (n2) {};
    \item Issue 3
\end{itemize}

(Note: I shifted the y value up by 1/2 of a line maybe more would be better.)

Because we used remember picture we can refer to these places in an overlay:

  \begin{tikzpicture}[overlay,remember picture]
      \path (n2) -| node[coordinate] (n3) {} (n1);
      \draw[thick,decorate,decoration={brace,amplitude=3pt}]
            (n1) -- (n3) node[midway, right=4pt] {One and two are cool};
  \end{tikzpicture}

The path is there to deal with items that do not have the same width. This edit comes from ESultanik's answer.

The result is:

alt text

Side note: You can remove all of the remember picture options and add the following to automatically add remember to all pictures:

\tikzstyle{every picture}+=[remember picture]
想你的星星会说话 2024-09-07 01:52:00

您可以(ab)使用表格来代替:

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{tabular}{ll}

\textbullet Issue 1 & \multirow{2}{*}{{\LARGE \}} One and Two are cool} \\
\textbullet Issue 2                                                     \\
\textbullet Issue 3                                                     \\

\end{tabular}

\end{document}

产生:

删除了无效的Imageshack链接

You could (ab)use a table instead:

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{tabular}{ll}

\textbullet Issue 1 & \multirow{2}{*}{{\LARGE \}} One and Two are cool} \\
\textbullet Issue 2                                                     \\
\textbullet Issue 3                                                     \\

\end{tabular}

\end{document}

produces:

removed dead Imageshack link

人生百味 2024-09-07 01:52:00

这是 Geoffs 代码,进行了一些小的调整(仅适用于其他投影仪用户)

\begin{frame}{Example}

\begin{itemize}
\item The long Issue 1
\tikz[remember picture] \node[coordinate,yshift=0.7em] (n1) {}; \\
spanning 2 lines


\item Issue 2
  \tikz[remember picture] \node[coordinate, xshift=1.597cm] (n2) {};
\item Issue 3

\end{itemize}

\visible<2->{
\begin{tikzpicture}[overlay,remember picture]
  \draw[thick,decorate,decoration={brace,amplitude=5pt}]
        (n1) -- (n2) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
 } % end visible

\end{frame}

结果(该帧的第二张幻灯片):

beamer result

调整是:

  • 添加了 visible 命令(因为我认为稍后混合大括号很有用)
  • 使项目变得更加复杂,因此有必要使用 xshift (我简单地通过尝试和错误计算出 xshift 值,这有点苦涩)编辑 2018-12-23: 可以通过使用 这个方法:(n1 -| n2) -- (n2) 而不是 (n1) -- (n2)

Here is Geoffs code with some small adaptions (just for other beamer users)

\begin{frame}{Example}

\begin{itemize}
\item The long Issue 1
\tikz[remember picture] \node[coordinate,yshift=0.7em] (n1) {}; \\
spanning 2 lines


\item Issue 2
  \tikz[remember picture] \node[coordinate, xshift=1.597cm] (n2) {};
\item Issue 3

\end{itemize}

\visible<2->{
\begin{tikzpicture}[overlay,remember picture]
  \draw[thick,decorate,decoration={brace,amplitude=5pt}]
        (n1) -- (n2) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
 } % end visible

\end{frame}

Ressult (2nd slide of that frame):

beamer result

The adaptions are:

  • added the visible command (because I think it is useful to blend in the brace later)
  • made the items more complex so the use of xshift became necessary (I figured out the xshift value simply by try and error so thats a drop of bitterness) Edit 2018-12-23: manual try-and-error shifting can be overcome by using this method: (n1 -| n2) -- (n2) instead of (n1) -- (n2).
南城追梦 2024-09-07 01:52:00

解决这个问题的一种方法是使用像align这样的数学环境,手动放置项目符号点(使用\bullet),然后使用数学环境的资源来表示大括号等。

One way to get around this would be to use a math environment like align, put the bullet points by hand (with \bullet ), and then use the resources of the math environment for big braces and such.

留一抹残留的笑 2024-09-07 01:52:00

我曾经做过类似的事情。我让列表位于左侧的一列中,在右侧的列中,我执行了 $\right\}$ 操作,以便它与某些 \mbox< 一样高/code> 或其他东西(我用 \vphantom 或类似的东西决定)。不幸的是我没有时间把它挖出来......我实际上现在根本没有时间;)

I did something similar once. I let the list be in a column to the left, and in the right column, I did the $\right\}$-thing so that it was as tall as some \mbox or something (which I decided with \vphantom or something similar). Unfortunately I don't have time to dig it out... I actually don't have time to be at SO at all right now ;)

逆蝶 2024-09-07 01:52:00

我尝试了我的想法,如下。它不起作用:不幸的是,itemize 环境生成的 vbox 都有宽度 \textwidth

我建议的 UI 很好,通过重新定义 \item 应该可以使项目 vbox 具有合理的宽度。或者计算包含项目的垂直盒子的合理宽度。但由于已经有功能性的解决方案,我不会再花时间在这上面。

\documentclass{article}

\def\setgrouptext#1{\gdef\grouptext{#1}}
\newenvironment{groupeditems}{\begin{displaymath}\left.\vbox\bgroup\setgrouptext}{%
  \egroup\right\rbrace\hbox{\grouptext}\end{displaymath}}

\begin{document}

\begin{itemize}
\item Line 1
\begin{groupeditems}{Lines 2 and 3 together!}
\item Line 2
\item Line 3
\end{groupeditems}
\item Line 4
\end{itemize}

\end{document}

I tried my idea, below. It doesn't work: unfortunately, the vboxes produced by the itemize environment all have width \textwidth.

The UI of my suggestion is nice, and by redefining \item it should be possible to get the item vboxes be of reasonable width. Or calculate a reasonable width for the vboxes containing the items. But since there are functional solutions already, I won't spend anymore time on this.

\documentclass{article}

\def\setgrouptext#1{\gdef\grouptext{#1}}
\newenvironment{groupeditems}{\begin{displaymath}\left.\vbox\bgroup\setgrouptext}{%
  \egroup\right\rbrace\hbox{\grouptext}\end{displaymath}}

\begin{document}

\begin{itemize}
\item Line 1
\begin{groupeditems}{Lines 2 and 3 together!}
\item Line 2
\item Line 3
\end{groupeditems}
\item Line 4
\end{itemize}

\end{document}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文