我对 LaTeX 还很陌生。我正尝试将一个非常简单的图形写入演示文稿中,其长宽比为 16:9。我使用的是 beamer 包和 TikZ 包,这是我所拥有的,运行良好。
\documentclass[aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{tikzmark, arrows.meta}
\begin{document}
\begin{frame}[aspectratio=169]
\[
\begin{tikzpicture}[baseline=(m.center), every node/.append style={font=\small}]
\node (m) at (-6,0) {
$\begin{bmatrix}
0 & d_{1,2} & \cdots & d_{1,n} \\
d_{2,1} & 0 & \cdots & d_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
d_{n,1} & d_{n,2} & \cdots & 0 \\
\end{bmatrix}$
}; \pause
\node (eq) at (-.5, 0) {
$\begin{aligned}
\pi_1 &= \{S^1_1, S^1_2, \ldots, S^1_{q_1}\} \\
\pi_2 &= \{S^2_1, S^2_2, \ldots, S^2_{q_2}\} \\
\vdots \\
\pi_B &= \{S^B_1, S^B_2, \ldots, S^B_{q_B}\} \\
\end{aligned}$
};
\draw[->, thick, shorten >=5pt, shorten <=5pt] (m.east) -- (eq.west) node[midway, above, font=\tiny] {sampling} node[midway, below, font=\tiny] {EPA distribution};
\pause
\node (pi_est) at (4.5, 1.5) {$\pi_{\text{estimate}}$};
\node (pngs) at (4.5, -2) {$\textbf{IMAGES}$};
\draw[->, thick, shorten >=5pt, shorten <=5pt] (eq.east) -- (pi_est.west) node[midway, sloped, above, font=\tiny] {estimation} node[midway, sloped, below, font=\tiny] {SALSO};
\draw[->, thick, shorten >=5pt, shorten <=5pt] (eq.east) -- (pngs.west) node[midway, sloped, above, font=\tiny] {Uncertainty Quantification};
\end{tikzpicture}
\]
\end{frame}
\end{document}
就像我说的,它运行良好,并产生了我想要的结果,但在 \end{frame} 行,它向我发出警告,提示“Package keyval Error:aspectratio undefined”。有人知道我的代码出了什么问题吗?谢谢!
答案1
aspectratio
只是一个类选项。您不能将其用作框架选项。您收到的不是警告,而是错误。代码运行不“正常”。您永远不应该忽略错误。发生错误后,latex 仅恢复足够的内容以检查文档的其余部分,从而生成可能有效也可能无效的 pdf。
解决方案很简单:从代码中删除无效的框架选项:
\documentclass[aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{tikzmark, arrows.meta}
\begin{document}
\begin{frame}
\[
\begin{tikzpicture}[baseline=(m.center), every node/.append style={font=\small}]
\node (m) at (-6,0) {
$\begin{bmatrix}
0 & d_{1,2} & \cdots & d_{1,n} \\
d_{2,1} & 0 & \cdots & d_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
d_{n,1} & d_{n,2} & \cdots & 0 \\
\end{bmatrix}$
}; \pause
\node (eq) at (-.5, 0) {
$\begin{aligned}
\pi_1 &= \{S^1_1, S^1_2, \ldots, S^1_{q_1}\} \\
\pi_2 &= \{S^2_1, S^2_2, \ldots, S^2_{q_2}\} \\
\vdots \\
\pi_B &= \{S^B_1, S^B_2, \ldots, S^B_{q_B}\} \\
\end{aligned}$
};
\draw[->, thick, shorten >=5pt, shorten <=5pt] (m.east) -- (eq.west) node[midway, above, font=\tiny] {sampling} node[midway, below, font=\tiny] {EPA distribution};
\pause
\node (pi_est) at (4.5, 1.5) {$\pi_{\text{estimate}}$};
\node (pngs) at (4.5, -2) {$\textbf{IMAGES}$};
\draw[->, thick, shorten >=5pt, shorten <=5pt] (eq.east) -- (pi_est.west) node[midway, sloped, above, font=\tiny] {estimation} node[midway, sloped, below, font=\tiny] {SALSO};
\draw[->, thick, shorten >=5pt, shorten <=5pt] (eq.east) -- (pngs.west) node[midway, sloped, above, font=\tiny] {Uncertainty Quantification};
\end{tikzpicture}
\]
\end{frame}
\end{document}