因此,我正在为一个班级做演讲beamer
,我决定在一个itemize
环境中使用花括号括住多个项目,这些项目将逐一被发现。因此,按照我从另一个问题中得到的建议这里,我让花括号在我想要的时候出现在所选项目周围,但有些括号莫名其妙地旋转了。我的意思是,
这是我最好的尝试MWE
:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{metropolis}
\usepackage[normalem]{ulem}
\usepackage{amsmath,lmodern,calc,tikz,textcomp}
\usetikzlibrary{tikzmark,calc, decorations.pathreplacing}
\begin{document}
\begin{frame}
\begin{itemize}
\setlength\itemsep{0.7em}
\item\only<1>{\(b > v > p\)}\onslide<2->{\sout{\(b > v > p\)}}\tikzmark{start}
\item\only<2>{\(p > b > v\)}\only<3->{\sout{\(p > b > v\)}}\tikzmark{end}
\item\only<3>{\(b > p > v\)}\only<4->{\sout{\(b > p > v\)}}\tikzmark{start1} \tikzmark{end1}
\item\only<4>{\(v > b > p\)}\only<5->{\sout{\(v > b > p\)}}\tikzmark{start2}
\item\only<5>{\(p > v > b\)}\only<6->{\sout{\(p > v > b\)}}\tikzmark{end2}
\item\only<6>{\(v > p > b\)}\only<7->{\sout{\(v > p > b\)}}\tikzmark{start3} \tikzmark{end3}
\only<3->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
([yshift=2ex]{{pic cs:end}|-{pic cs:start}}) --
node[xshift=15pt,anchor=west] {No change by raising}
([yshift=-0.5ex]pic cs:end);
\end{tikzpicture}}
\only<4->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
([yshift=2ex]{{pic cs:end}|-{pic cs:start1}}) --
node[xshift=15pt,anchor=west] {Raising won, but now neg. profit}
([yshift=-0.5ex]pic cs:end1);
\end{tikzpicture}}
\only<6->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
([yshift=2ex]{{pic cs:end}|-{pic cs:start2}}) --
node[xshift=15pt,anchor=west] {No change by lowering}
([yshift=-0.5ex]pic cs:end2);
\end{tikzpicture}}
\only<7->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
([yshift=2ex]{{pic cs:end}|-{pic cs:start3}}) --
node[xshift=15pt,anchor=west] {Lost by lowering}
([yshift=-0.5ex]pic cs:end3);
\end{tikzpicture}}
\end{itemize}
\end{frame}
\end{document}
无论我做什么,或者我将项目之间的间距增加多少,一些括号上的旋转仍然存在。有人能帮我解决这个错误吗?
答案1
最小修复:
删除 之间的空格
\tikzmarks
:\tikzmark{start1} \tikzmark{end1}
并用替换,对和\tikzmark{start1}\tikzmark{end1}
之间的其他空格也同样操作。tikzmark{start3}
tikzmark{end3}
在第二个括号的代码中,
{pic cs:end}|-{pic cs:start1}
用替换{pic cs:end1}|-{pic cs:start1}
(添加1
到end
)。对第三和第四个括号执行相同操作:分别end
用end2
和替换end3
。
为了稍微清理一下代码,我建议定义命令
\mybrace{<start mark>}{<end mark>}{<alignment mark>}{<text>}
作为
\newcommand\mybrace[4]%
{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
([yshift=2ex]{{pic cs:#3}|-{pic cs:#1}}) --
node[xshift=15pt,anchor=west] {#4}
([yshift=-0.5ex]{{pic cs:#3}|-{pic cs:#2}});
\end{tikzpicture}%
}
然后括号中的代码简化为
\only<3->{\mybrace{start}{end}{end}{No change by raising}}
\only<4->{\mybrace{start1}{end1}{end}{Raising won, but now neg. profit}}
\only<6->{\mybrace{start2}{end2}{end}{No change by lowering}}
\only<7->{\mybrace{start3}{end3}{end}{Lost by lowering}}
如果分项文本的长度不同,额外的对齐标记有助于将括号对齐。如果没有要对齐的内容(例如第一个括号),则将结束标记作为对齐标记。
这是完整的代码和结果。
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{metropolis}
\usepackage[normalem]{ulem}
\usepackage{amsmath,lmodern,calc,tikz,textcomp}
\usetikzlibrary{tikzmark,calc, decorations.pathreplacing}
\newcommand\mybrace[4]%
{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
([yshift=2ex]{{pic cs:#3}|-{pic cs:#1}}) --
node[xshift=15pt,anchor=west] {#4}
([yshift=-0.5ex]{{pic cs:#3}|-{pic cs:#2}});
\end{tikzpicture}%
}
\begin{document}
\begin{frame}
\begin{itemize}
\setlength\itemsep{0.7em}
\item\only<1>{\(b > v > p\)}\onslide<2->{\sout{\(b > v > p\)}}\tikzmark{start}
\item\only<2>{\(p > b > v\)}\only<3->{\sout{\(p > b > v\)}}\tikzmark{end}
\item\only<3>{\(b > p > v\)}\only<4->{\sout{\(b > p > v\)}}\tikzmark{start1} \tikzmark{end1}
\item\only<4>{\(v > b > p\)}\only<5->{\sout{\(v > b > p\)}}\tikzmark{start2}
\item\only<5>{\(p > v > b\)}\only<6->{\sout{\(p > v > b\)}}\tikzmark{end2}
\item\only<6>{\(v > p > b\)}\only<7->{\sout{\(v > p > b\)}}\tikzmark{start3} \tikzmark{end3}
\only<3->{\mybrace{start}{end}{end}{No change by raising}}
\only<4->{\mybrace{start1}{end1}{end}{Raising won, but now neg. profit}}
\only<6->{\mybrace{start2}{end2}{end}{No change by lowering}}
\only<7->{\mybrace{start3}{end3}{end}{Lost by lowering}}
\end{itemize}
\end{frame}
\end{document}