我正在尝试构建一个具有两列和多行的矩阵。顶行有两个节点,它们都需要保存多行文本和数学。当我按照规定的方法使用花括号括起多行单元格时\\
,我根本无法编译代码(texmaker 永远运行,我的机器变得非常热,我不得不关闭应用程序)。任何帮助都将不胜感激。
\documentclass{beamer}
\mode<presentation>
{
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}
%%%%%%%%%
\usetikzlibrary{calc}
%%%%%%%%
\tcbuselibrary{theorems}
\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth}{lem}
\tcbset{colframe=green, colback=white}
\resetcounteronoverlays{tcb@cnt@mylemmma}
\begin{document}
\section{Proofs}
\newtcbtheorem[]{mydef}{Problem Statement}{colframe=white, colback=white}{ps}
\tcbset{colframe=black, colback=white}
\resetcounteronoverlays{tcb@cnt@mydef}
\begin{frame}[fragile]
\centering
\begin{tikzpicture}[optimization problem/.style = {%
rounded corners,
draw = blue,
thick,
fill= yellow,
inner ysep=5pt,
inner xsep=5pt,
align = center},
myplainproblem/.style = {%
rounded corners,
draw = blue,
thick,
fill= white,
inner ysep=5pt,
inner xsep=5pt,
align = center},
]
\matrix[matrix of nodes,row sep=1em,column sep=1em,
nodes={anchor=west,optimization problem,
visible on=<\the\numexpr\pgfmatrixcurrentcolumn+2*\pgfmatrixcurrentrow-2\relax->,},
column 1/.style={nodes={myplainproblem,
}},
column 2/.style={nodes={myplainproblem,
}},
row 1/.style={nodes={optimization problem,
}},
](M){
vectors & matrices \\
reason 1 & matrix reason 1\\
reason 2 & matrix reason 2\\
};
\end{tikzpicture}
\end{frame}
\end{document}
答案1
当我们查看 pgfmanual v3.1.5 中相应部分时60.2 节点矩阵中的行尾和行末字符,人们发现在示例中text width
设置了。它确实提到
仅当您使用节点的文本宽度选项时才会出现此问题。
但我同意,这是否意味着必须设置才能text width
使花括号技巧发挥作用这一点并不明确。无论如何,一旦我们设置了它,它就会起作用。
\documentclass{beamer}
\mode<presentation>
{
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}
%%%%%%%%%
\usetikzlibrary{calc}
%%%%%%%%
\tcbuselibrary{theorems}
\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth}{lem}
\tcbset{colframe=green, colback=white}
\resetcounteronoverlays{tcb@cnt@mylemmma}
\begin{document}
\section{Proofs}
\newtcbtheorem[]{mydef}{Problem Statement}{colframe=white, colback=white}{ps}
\tcbset{colframe=black, colback=white}
\resetcounteronoverlays{tcb@cnt@mydef}
\begin{frame}[fragile]
\centering
\begin{tikzpicture}[optimization problem/.style = {%
rounded corners,
draw = blue,
thick,
fill= yellow,
inner ysep=5pt,
inner xsep=5pt,
align = center},
myplainproblem/.style = {%
rounded corners,
draw = blue,
thick,
fill= white,
inner ysep=5pt,
inner xsep=5pt,
align = center},
]
\matrix[matrix of nodes,row sep=1em,column sep=1em,
nodes={anchor=west,optimization problem,text width=8em,
visible on=<\the\numexpr\pgfmatrixcurrentcolumn+2*\pgfmatrixcurrentrow-2\relax->,},
column 1/.style={nodes={myplainproblem,
}},
column 2/.style={nodes={myplainproblem,
}},
row 1/.style={nodes={optimization problem,
}},
](M){
{vectors\\ tensors} & {matrices\\ tableaux} \\
reason 1 & matrix reason 1\\
reason 2 & matrix reason 2\\
};
\end{tikzpicture}
\end{frame}
\end{document}
如果你觉得手册在这里可以更清楚(我当然同意这个说法),你可以提交一个问题。