标签矩阵尺寸

标签矩阵尺寸

我有一个矩阵方程

Ax=b

我想在每个下面添加尺寸,就像这样

\underset{p\times k}{A} \underset{k\times 1}{x} = \underset{p\times 1}{b} 

问题是这很丑陋,至少在我使用的 Beamer 模板中是这样的。有没有更好的排版方法?

答案1

通常将矩阵维度作为下标,因此您可以使用

\[
A_{\scriptscriptstyle p\times k}x_{\scriptscriptstyle k\times 1}=b_{\scriptscriptstyle p\times 1}
\]

编辑:一个选项是仅在一张幻灯片上显示尺寸,并在其他幻灯片上隐藏它们,方法如下:

\[
  \onslide<1,2>{A}\only<1>{_{\scriptscriptstyle p\times k}}    
  \onslide<1,2>{x}\only<1>{_{\scriptscriptstyle k\times 1}} =
  \onslide<1,2>{b}\only<1>{_{\scriptscriptstyle p\times 1}} 
\]

EDIT2:Caramdir 解决方案的变体,但重点关注以下内容:

\documentclass{beamer}
\usepackage{tikz}
\usefonttheme[mathonly]{serif}

\begin{document}

\begin{frame}
\begin{center}
\begin{tikzpicture}[every node/.style={inner sep =1pt},dim/.style={red!50!black}]
\onslide<1->{\node (meq) at (0,0) {$Ax=b$};}
\onslide<2->{\node[dim] (A) at (-1,-0.8) {$\scriptscriptstyle p\times k$};
  \draw[->,red!50!black] (A) -- (meq.200);}\pause
\onslide<3->{\node[dim] (x) at (-0.25,-0.8) {$\scriptscriptstyle k\times 1$};
  \draw[->,red!50!black] (x) -- (meq.215);}\pause
\onslide<4->{\node[dim] (b) at (1,-0.8) {$\scriptscriptstyle p\times 1$};
  \draw[->,red!50!black] (b) -- (meq.341);}\pause
\end{tikzpicture}
\end{center}
\end{frame}

\end{document}

答案2

如果你想要更高级一点,你可以使用 TikZ:

TikZ 建议

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

% for some reason it is impossible to define keys with arguments inside a frame.
\pgfkeys{/tikz/l/.style={right=0pt of #1.base east, anchor=base west}}

\begin{document}

\begin{frame}
\begin{center}
\begin{tikzpicture}[
    inner sep=0,
    style-A/.style={color=red!50!black},
    style-x/.style={color=blue!50!black},
    style-b/.style={color=green!50!black},
    a/.style={->,shorten >=2pt,thick}
    ]
    \node[style-A] (A) {$A$};
    \node[l=A, style-x] (x) {$x$};
    \node[l=x] (eq) {${}={}$};
    \node[l=eq, style-b] (b) {$b$};

    \node[style-A] (A-desc) at (-0.5,-0.7) {$p \times k$};
    \node[style-x] (x-desc) at (0.5,-1.2) {$k \times 1$};
    \node[style-b] (b-desc) at (1.4,-0.7) {$p \times 1$};

    \draw[a,style-A] (A-desc) -- (A.south);
    \draw[a,style-x] (x-desc) -- (x.south);
    \draw[a,style-b] (b-desc) -- (b.south);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

相关内容