我正在尝试使用\tikzmark
命令将带有标签的右括号覆盖在 旁边pmatrix
。不幸的是,当前输出存在两个问题:
- 我的代码在矩阵的行之间引入了额外的垂直空间。我该如何解决这个问题?
- 我想将支架向右移动几毫米。我该怎么做?
我的代码和输出如下所示。
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand\tikzmarkeast[2][]{\tikz[remember picture,baseline=(#1.east)]
\node[inner sep=0,outer sep=0](#1){#2};}
\begin{document}
\[
\begin{pmatrix}
1 & 1 & 1 & & & & & & \\
& & & 1 & 1 & 1 & & & \\
& & & & & & 1 & 1 & 1 \\
& 1 & 1 & & 1 & 1 & & & \\
& & & & 1 & 1 & & 1 & 1 \\
& 1 & 1 & & 1 & 1 & & 1 & 1
\end{pmatrix}
\begin{pmatrix}
\gamma_1^0 \\ \gamma_1^1 \\ \gamma_1^2 \\
\gamma_2^0 \\ \gamma_2^1 \\ \gamma_2^2 \\
\gamma_3^0 \\ \gamma_3^1 \\ \gamma_3^2
\end{pmatrix}
\leq
\begin{pmatrix}
\tikzmarkeast[select-1]{1} \\ 1 \\ \tikzmarkeast[select-2]{1} \\
1 \\ 1 \\
L
\end{pmatrix}
%
\tikz[remember picture,overlay]
\draw[decorate,decoration={brace,amplitude=3pt},xshift=6mm]
(select-1.north east)
-- node[right=3pt]{$\sum \gamma_t^k \leq 1$}
(select-2.south east);
\]
\end{document}
答案1
你的问题是baseline=(#1.east)
。应该是baseline=(#1.base)
。此外,你可以xshift
在坐标中输入
\tikz[remember picture,overlay]
\draw[decorate,decoration={brace,amplitude=3pt},]
([xshift=6mm]select-1.north east)
-- node[right=3pt]{$\sum \gamma_t^k \leq 1$}
([xshift=6mm]select-2.south east);
完整代码:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\newcommand\tikzmarkeast[2][]{\tikz[remember picture,baseline=(#1.base)]\node[inner sep=0,outer sep=0](#1){#2};}%
\begin{document}
\[
\begin{pmatrix}
1 & 1 & 1 & & & & & & \\
& & & 1 & 1 & 1 & & & \\
& & & & & & 1 & 1 & 1 \\
& 1 & 1 & & 1 & 1 & & & \\
& & & & 1 & 1 & & 1 & 1 \\
& 1 & 1 & & 1 & 1 & & 1 & 1
\end{pmatrix}
\begin{pmatrix}
\gamma_1^0 \\ \gamma_1^1 \\ \gamma_1^2 \\
\gamma_2^0 \\ \gamma_2^1 \\ \gamma_2^2 \\
\gamma_3^0 \\ \gamma_3^1 \\ \gamma_3^2
\end{pmatrix}
\leq
\begin{pmatrix}
\tikzmarkeast[select-1]{1} \\
1 \\ \tikzmarkeast[select-2]{1} \\
1 \\ 1 \\
L
\end{pmatrix}
%
\tikz[remember picture,overlay]
\draw[decorate,decoration={brace,amplitude=3pt},]
([xshift=6mm]select-1.north east)
-- node[right=3pt]{$\sum \gamma_t^k \leq 1$}
([xshift=6mm]select-2.south east);
\]
\end{document}