有人知道如何处理垂直箭头吗?我目前的代码如下:
\hspace{0.75cm}
$\xleftrightarrow{\text{\hspace{4.25cm}j \hspace{4.25cm}}}$
\newline
\updownarrow{\text{i}}
\newline
\updownarrow{\text{i}}
\[
\begin{pmatrix}
y_0 & y_1 & ... & y_{j-1} \\
... & ... & ... & ... \\
y_{i-2} & y_{i-1} & ... & y_{i+j-3} \\
y_{i-i} & y_{i} & ... & y_{i+j-2} \\
\noindent\rule{2cm}{0.4pt} & \noindent\rule{2cm}{0.4pt} & \noindent\rule{2cm}{0.4pt} & \noindent\rule{2cm}{0.4pt} \\
y_{i} & y_{i+1} & ... & y_{i+j-1} \\
y_{i+1} & y_{i+2} & ... & y_{i+j} \\
... & ... & ... & ... \\
y_{2i-1} & y_{2i} & ... & y_{2i+j-2} \\
\end{pmatrix}
\]
答案1
这是一种可能的方法:标记一些特殊点(例如矩阵的角)的坐标,然后用来tikz
绘制箭头。你可能需要编译几次
\documentclass[]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\newcommand{\pincoord}[1]{\tikz[overlay, remember picture] \coordinate (#1);}
\begin{document}
\[
Y_{0|2i-1} \stackrel{\rm def}{=} \quad\pincoord{A}
\begin{pmatrix}
\pincoord{B} y_0 & y_1 & ... & y_{j-1} \pincoord{C} \\
... & ... & ... & ... \\
y_{i-2} & y_{i-1} & ... & y_{i+j-3} \\
\pincoord{F} y_{i-i} & y_{i} & ... & y_{i+j-2} \pincoord{G} \\
y_{i} & y_{i+1} & ... & y_{i+j-1} \\
y_{i+1} & y_{i+2} & ... & y_{i+j} \\
... & ... & ... & ... \\
\pincoord{D} y_{2i-1}& y_{2i} & ... & y_{2i+j-2} \pincoord{E}\\
\end{pmatrix}
\pincoord{H} \qquad\stackrel{\rm def}{=} \left(\frac{Y_{0|i-1}}{Y_{i|2i-1}}\right) \quad\stackrel{\rm def}{=}
\left(\frac{Y_p}{Y_f}\right)
\]
\begin{tikzpicture}[overlay, remember picture, >=stealth]
\draw[<->] ([xshift = -1ex, yshift = 2pt]A) -- ([xshift = -1ex]A |- B) node[midway, left] {i};
\draw[<->] ([xshift = -1ex, yshift =-2pt]A) -- ([xshift = -1ex]A |- D) node[midway, left] {i};
\draw[<->] ([yshift = 3ex]B) -- ([yshift = 3ex]B -| C) node[midway, above] {J};
\draw[] ([yshift = -5pt]F) -- ([yshift = -5pt]G);
\draw[<->] ([xshift = 1ex, yshift = 2pt]H) -- ([xshift = 1ex]H |- B) node[midway, right] {``past''};
\draw[<->] ([xshift = 1ex, yshift =-2pt]H) -- ([xshift = 1ex]H |- D) node[midway, right] {``future''};
\end{tikzpicture}
\end{document}
答案2
对于 来说这是一份完美的工作tikz matrix
!
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix, arrows.meta}
\begin{document}
\[
Y_{0\mid 2i-1} \stackrel{\text{def}}{=}
\begin{tikzpicture}[>=Stealth, baseline=(mybaseline)]
\matrix[
matrix of math nodes,
left delimiter=(,
right delimiter=),
inner xsep=2pt,
] (mymatr) {%
y_0 & y_1 & \cdots & y_{j-1} \\[-6pt]
\vdots & \vdots & \ddots & \vdots \\
y_{i-2} & y_{i-1} & \cdots & y_{i+j-3} \\
y_{i-1}% there was a little typo here
& y_{i} & \cdots & y_{i+j-2} \\[12pt]
y_{i} & y_{i+1} & \cdots & y_{i+j-1} \\
y_{i+1} & y_{i+2} & \cdots & y_{i+j} \\[-6pt]
\vdots & \vdots & \ddots & \vdots \\
y_{2i-1} & y_{2i} & \cdots & y_{2i+j-2} \\
};
\coordinate (mybaseline) at ([yshift=-9pt]mymatr-4-1.south west);
\coordinate (mystart) at ([yshift=-6pt]mymatr-4-1.south west);
\coordinate (mystop) at ([yshift=-6pt]mymatr-4-4.south east);
\coordinate (myne) at ([xshift=16pt]mymatr.north east);
\coordinate (myse) at ([xshift=16pt]mymatr.south east);
\coordinate (mynw) at ([xshift=-16pt]mymatr.north west);
\coordinate (mysw) at ([xshift=-16pt]mymatr.south west);
\draw (mystart) -- (mystop);
\begin{scope}[every node/.style={midway},
every path/.style={<->}]
\draw (myne) -- (myne |- mystop) node[right] {``past''};
\draw (myse) -- (myse |- mystop) node[right] {``future''};
\draw (mynw) -- (mynw |- mystop) node[left] {$i$};
\draw (mysw) -- (mysw |- mystop) node[left] {$i$};
\draw ([yshift=10pt]mymatr.north west) -- ([yshift=10pt]mymatr.north east) node[above] {$j$};
\end{scope}
\end{tikzpicture}
\hspace{-34pt}% <--- but I would omit this
\stackrel{\text{def}}{=}
\biggl(\frac{Y_{0\mid i-1}}{Y_{i\mid 2i-1}}\biggr)
\stackrel{\text{def}}{=}
\biggl(\frac{Y_{p}}{Y_{f}}\biggr)
\]
\end{document}
答案3
与。{NiceArray}
nicematrix
\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{booktabs}% for \cmidrule
\begin{document}
\NiceMatrixOptions
{
exterior-arraycolsep,
xdots =
{
horizontal-labels ,
line-style = { solid , <-> }
}
}
\[
Y_{0\mid 2i-1} \stackrel{\text{def}}{=}
\begin{NiceArray}{cccccc}[baseline = line-6]
& \Hdotsfor{4}^{j} \\
\Vdotsfor{4}_{i}
& y_0 & y_1 & \cdots & y_{j-1} &
\Vdotsfor{4}^{\text{``past''}} \\
& \vdots & \vdots & \ddots & \vdots \\
& y_{i-2} & y_{i-1} & \cdots & y_{i+j-3} \\
& y_{i-1} & y_{i} & \cdots & y_{i+j-2} \\
\cmidrule(lr){2-5}
\Vdotsfor{4}_{j}
& y_{i} & y_{i+1} & \cdots & y_{i+j-1} &
\Vdotsfor{4}^{\text{``future''}} \\
& y_{i+1} & y_{i+2} & \cdots & y_{i+j} \\
& \vdots & \vdots & \ddots & \vdots \\
& y_{2i-1} & y_{2i} & \cdots & y_{2i+j-2} \\
\CodeAfter
\SubMatrix({2-2}{9-5})
\end{NiceArray}
\stackrel{\text{def}}{=}
\biggl(\frac{Y_{0\mid i-1}}{Y_{i\mid 2i-1}}\biggr)
\stackrel{\text{def}}{=}
\biggl(\frac{Y_{p}}{Y_{f}}\biggr)
\]
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。