如何在 tikzcd 图表的第一行创建符号的水平“删除线”?

如何在 tikzcd 图表的第一行创建符号的水平“删除线”?

假设我们有以下代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{cd}
\makeatletter
\tikzcdset{diagrams={% this will allow math mode to be deselected
    /tikz/matrix of math nodes/.style={
      /tikz/matrix of nodes,
      /tikz/nodes={
        execute at begin node=\iftikzcd@mathmode$\fi,
        execute at end node=\iftikzcd@mathmode$\fi}}}}
\makeatother
\begin{document}
\begin{equation}\label{diagram:t1t}
\begin{tikzcd}[
  /tikz/cross out/.style={
    append after command=(\tikzlastnode.north west) edge (\tikzlastnode.south east) (\tikzlastnode.south west) edge (\tikzlastnode.north east)},
  /tikz/row 2/.append style={commutative diagrams/math mode=false},
  /tikz/column 1/.append style={anchor=base east},
  cells={inner xsep=+0pt}, row sep=.7em, column sep=width("{,\space}"),
%  tikzcd to/.tip={To[length=+3pt +2.5, width=+2pt +2.5]},
  /utils/exec=
    \renewcommand*\c{\rlap{,}}%
    \newcommand*\LB{\smash{\llap{\{}}}%
    \newcommand*\RB{\unskip\smash{\rlap{\}}}},
]
      & \LB P1\c \dar & P2\c \dar & P3\c  \dar & P4\c \dar
      &     P5\c \dar & P6\c \dar & P7\RB \dar \\
  R = & \LB 1\c  \dar & 2\c  \dar & 1\c  \dar  & |[cross out]| 4\c \dar
      &     3\c  \dar & 1\c  \dar & 1\RB \dar \\
  I = & \LB 1\c  \dar & 2\c  \dar & 3\c  \dar  & |[cross out]| 4\c \dar
      &     5\c  \dar & 6\c  \dar & 7\RB \dar \\
 \mathbf{V} = & \LB 1\c   & 2\c   & 3\c    & \phantom{4} 
      &     5\c   & 6\c  & 7\RB
\end{tikzcd}
\end{equation}
\end{document}

在此处输入图片描述

问题:我们如何在图表的“P4”上创建水平“删除线”?(见下文。)

在此处输入图片描述

答案1

我已经调整了cross out要使用的样式round edges,并稍微缩短了线条,以便它们更适合,在我看来。

代码

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{cd}
\tikzset{
  round edges/.style={every edge/.append style={line cap=round}},
  cross out/.style={append after command={[round edges]
    ([yshift=-3pt]\tikzlastnode.north west) edge ([yshift= 3pt]\tikzlastnode.south east)
    ([yshift= 3pt]\tikzlastnode.south west) edge ([yshift=-3pt]\tikzlastnode.north east)}},
  horizontal cross out/.style={append after command={[round edges]
    (\tikzlastnode.west) edge (\tikzlastnode.east)}}}
\usepackage{cancel}
\begin{document}
\begin{equation}\label{diagram:t1t}
\begin{tikzcd}[
  /tikz/column 1/.append style={anchor=base east},
  cells={inner xsep=+0pt}, row sep=.7em, column sep=width("{,\space}"),
%  tikzcd to/.tip={To[length=+3pt +2.5, width=+2pt +2.5]},
  /utils/exec=
    \renewcommand*\c{\rlap{,}}%
    \newcommand*\LB{\smash{\llap{\{}}}%
    \newcommand*\RB{\unskip\smash{\rlap{\}}}},
]
      & \LB P1\c \dar & P2\c \dar & P3\c  \dar & |[horizontal cross out]| P4\c \dar
      &     P5\c \dar & P6\c \dar & P7\RB \dar \\
  R = & \LB 1\c  \dar & 2\c  \dar & 1\c  \dar  & |[cross out]| 4\c \dar
      &     3\c  \dar & 1\c  \dar & 1\RB \dar \\
  I = & \LB 1\c  \dar & 2\c  \dar & 3\c  \dar  & |[cross out]| 4\c \dar
      &     5\c  \dar & 6\c  \dar & 7\RB \dar \\
 \mathbf{V} = & \LB 1\c & 2\c     & 3\c        & \phantom{4} 
      &     5\c   & 6\c  & 7\RB
\end{tikzcd}
\end{equation}
\end{document}

输出

在此处输入图片描述

相关内容