在矩阵元素之间绘制射线

在矩阵元素之间绘制射线

我想画出下面的数学表达式。

期望输出

我尝试了很多tabular环境,但还是无法获得想要的输出。有人能帮我吗?

另一个问题是如何按照以下方式绘制对角射线:

  1. 在行列式中X,射线来自1c2以及来自b 2c 1
  2. 在行列式中,射线来自c 1a2以及来自c21
  3. 在 1 下的行列式中,来自1b 2以及来自a21

答案1

因此,在不知道您的文档类或已加载的包的情况下,这个(不可否认很丑陋的)示例可能会解决您的问题的第一部分:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$\frac{x}{\begin{vmatrix}b_1&c_1\\ b_2&c_2 \end{vmatrix}}=\frac{y}{\begin{vmatrix} c_1&a_1 \\ c_2&a_2 \end{vmatrix}}=\frac{1}{\begin{vmatrix} a_1&b_1\\a_2&b_2 \end{vmatrix}}$

$\displaystyle\frac{x}{\begin{vmatrix}b_1&c_1\\ b_2&c_2 \end{vmatrix}}=\frac{y}{\begin{vmatrix} c_1&a_1 \\ c_2&a_2 \end{vmatrix}}=\frac{1}{\begin{vmatrix} a_1&b_1\\a_2&b_2 \end{vmatrix}}$
\end{document}

两者之间的区别在于\displaystyle你可能会喜欢或者不喜欢。

答案2

从表 3.6Latex 5.04 版的简要介绍,您将看到两个符号\nearrow\searrow。您可以在行列式中添加一个虚拟列和虚拟行(均位于中间),并将这两个符号放在中间单元格中。为了让它们重叠,我使用了负间距。这不是一个完美的解决方案,但你不需要除 amsmath 之外的任何其他软件包。我还有另一个不太优雅的解决方案,基于raisebox基于https://en.wikibooks.org/wiki/LaTeX/Boxes#raisebox

\documentclass[12pt,a5paper]{article}
\usepackage{amsmath}
\begin{document}
a\\
\(
\begin{vmatrix}
b_1 & & c_1\\
& \nearrow \hspace{-1em} \searrow &\\
b_2 & & c_2\\
\end{vmatrix}
\)
\\
%another solution
\(
\begin{vmatrix}
b_1 & & c_1\\
b_2 & & c_2\\
\end{vmatrix}
\)
\hspace{-3.2em} \raisebox{-0.3ex}\text{{$\nearrow$}}
\hspace{-1.7em} \raisebox{-0.3ex}\text{{$\searrow$}} 
\end{document}

在此处输入图片描述

答案3

代码从用户 jfbu 处复制粘贴回答在矩阵元素之间绘制射线。虽然名字有点拗口,但它避免了使用大型图形引擎。每次需要编译两次。适用于pdflatex

\documentclass{article}

% from https://tex.stackexchange.com/a/277474/4686 (user jfbu)
% --------------------------------START--------------------------------
% matrices
\usepackage{amsmath}

% I discovered a bad interaction of eso-pic with xetex
% which is fixed for an unknown reason to me by loading
% package geometry
\usepackage{geometry}

% transforms the page into a LaTeX picture
\usepackage{eso-pic}

% enhances original LaTeX picture
% there are other packages
% unfortunately I don't know how to draw dashed lines with pict2e
\usepackage{pict2e}

% for some color
\usepackage{color}

\makeatletter
\newbox\JayBox
\def\JayNodeCount{0}%

\def\zapspaces #1 #2{#1#2\zapspaces }

\newcommand\Node [2]{%
% make the code work also if no amsmath
    \ifcsname ifmeasuring@\endcsname
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
    {\unless\ifmeasuring@}\iftrue
      \xdef\JayNodeCount{\the\numexpr\JayNodeCount+\@ne}%
      \ifcsname JAY@nodecoords@\romannumeral\JayNodeCount\endcsname
        \global
        \expandafter\let
        \csname JAY@nodename@\expandafter\zapspaces\detokenize{#1} \@gobble
        \expandafter\endcsname
        \csname JAY@nodecoords@\romannumeral\JayNodeCount\endcsname
      \else\typeout{========> New JAY node: run LaTeX again ! <========}%
      \fi
         \sbox\JayBox{$\m@th #2$}%
      \pdfsavepos
         \edef\JAY@temp{%
              \global
              \def\@backslashchar
                          JAY@nodecoords@\romannumeral\JayNodeCount
                  {{\noexpand\the\numexpr\pdflastxpos+\number\wd\JayBox/2}%
                   {\noexpand\the\numexpr\pdflastypos+\number\ht\JayBox/2}%
                   {\number\wd\JayBox/2}{\number\ht\JayBox/2}}%
                       }%
         \write\@mainaux\expandafter{\JAY@temp}%
    \fi
    #2%
}%

\def\JAY@north{north}
\def\JAY@south{south}
\def\JAY@west {west}
\def\JAY@east {east}
\def\JAY@northwest{northwest}
\def\JAY@northeast{northeast}
\def\JAY@southeast{southeast}
\def\JAY@southwest{southwest}


\def\JAY@setupAnode #1#2#3#4%
{%
    \def\JAY@Ax {#1}\def\JAY@Ay {#2}\def\JAY@Adx {#3}\def\JAY@Ady {#4}%
    \ifx\JAY@Aspec\JAY@north\edef\JAY@Ay {\the\numexpr\JAY@Ay+\JAY@Ady}\fi
    \ifx\JAY@Aspec\JAY@south\edef\JAY@Ay {\the\numexpr\JAY@Ay-\JAY@Ady}\fi
    \ifx\JAY@Aspec\JAY@west \edef\JAY@Ax {\the\numexpr\JAY@Ax-\JAY@Adx}\fi
    \ifx\JAY@Aspec\JAY@east \edef\JAY@Ax {\the\numexpr\JAY@Ax+\JAY@Adx}\fi
    \ifx\JAY@Aspec\JAY@northwest
                   \edef\JAY@Ay {\the\numexpr\JAY@Ay+\JAY@Ady}%
                   \edef\JAY@Ax {\the\numexpr\JAY@Ax-\JAY@Adx}%
    \fi
    \ifx\JAY@Aspec\JAY@northeast
                   \edef\JAY@Ay {\the\numexpr\JAY@Ay+\JAY@Ady}%
                   \edef\JAY@Ax {\the\numexpr\JAY@Ax+\JAY@Adx}%
    \fi
    \ifx\JAY@Aspec\JAY@southeast
                   \edef\JAY@Ay {\the\numexpr\JAY@Ay-\JAY@Ady}%
                   \edef\JAY@Ax {\the\numexpr\JAY@Ax+\JAY@Adx}%
    \fi
    \ifx\JAY@Aspec\JAY@southwest
                   \edef\JAY@Ay {\the\numexpr\JAY@Ay-\JAY@Ady}%
                   \edef\JAY@Ax {\the\numexpr\JAY@Ax-\JAY@Adx}%
    \fi
}%

\def\JAY@setupBnode #1#2#3#4%
{%
    \def\JAY@Bx {#1}\def\JAY@By {#2}\def\JAY@Bdx {#3}\def\JAY@Bdy {#4}%
    \ifx\JAY@Bspec\JAY@north\edef\JAY@By {\the\numexpr\JAY@By+\JAY@Bdy}\fi
    \ifx\JAY@Bspec\JAY@south\edef\JAY@By {\the\numexpr\JAY@By-\JAY@Bdy}\fi
    \ifx\JAY@Bspec\JAY@west \edef\JAY@Bx {\the\numexpr\JAY@Bx-\JAY@Bdx}\fi
    \ifx\JAY@Bspec\JAY@east \edef\JAY@Bx {\the\numexpr\JAY@Bx+\JAY@Bdx}\fi
    \ifx\JAY@Bspec\JAY@northwest
                   \edef\JAY@By {\the\numexpr\JAY@By+\JAY@Bdy}%
                   \edef\JAY@Bx {\the\numexpr\JAY@Bx-\JAY@Bdx}%
    \fi
    \ifx\JAY@Bspec\JAY@northeast
                   \edef\JAY@By {\the\numexpr\JAY@By+\JAY@Bdy}%
                   \edef\JAY@Bx {\the\numexpr\JAY@Bx+\JAY@Bdx}%
    \fi
    \ifx\JAY@Bspec\JAY@southeast
                   \edef\JAY@By {\the\numexpr\JAY@By-\JAY@Bdy}%
                   \edef\JAY@Bx {\the\numexpr\JAY@Bx+\JAY@Bdx}%
    \fi
    \ifx\JAY@Bspec\JAY@southwest
                   \edef\JAY@By {\the\numexpr\JAY@By-\JAY@Bdy}%
                   \edef\JAY@Bx {\the\numexpr\JAY@Bx-\JAY@Bdx}%
    \fi
}%

\newcommand\NodeLine [2][]{\def\JAY@opt{#1}\JAY@NodeLine #2\JAY@NodeLine}

\def\JAY@NodeLine #1[#2]#3->#4[#5]#6\JAY@NodeLine
{%
    \edef\JAY@nodeA {\expandafter\zapspaces\detokenize{#1} \@gobble}%
    \edef\JAY@nodeB {\expandafter\zapspaces\detokenize{#4} \@gobble}%
    \let\JAY@temp\empty
    \ifcsname JAY@nodename@\JAY@nodeA\endcsname
    \ifcsname JAY@nodename@\JAY@nodeB\endcsname
       \edef\JAY@Aspec {\zapspaces #2 \@gobble}%
       \edef\JAY@Bspec {\zapspaces #5 \@gobble}%
       \expandafter\expandafter\expandafter
            \JAY@setupAnode\csname JAY@nodename@\JAY@nodeA\endcsname
       \expandafter\expandafter\expandafter
            \JAY@setupBnode\csname JAY@nodename@\JAY@nodeB\endcsname
    \edef\JAY@temp {%
     \noexpand\AddToShipoutPictureFG*{%
% THIS IS THE ONLY PLACE WHERE THE PICTURE SYNTAX IS USED
% here we use \Line from package pict2e
% The optional argument to \NodeLine contains optional commands
       {\setlength{\unitlength}{1sp}%
       \linethickness{1pt}%
       \unexpanded\expandafter{\JAY@opt}%
       \noexpand\Line (\JAY@Ax,\JAY@Ay)(\JAY@Bx,\JAY@By)%
                   }}}%
    \fi\fi
  \JAY@temp
}
\makeatother
% --------------------------------FINISH-------------------------------

\begin{document}

\Huge

\[\frac{x}
  {\begin{vmatrix}\Node{B1}{b_1}&\Node{C1}{c_1}\\
    \Node{B2}{b_2}&\Node{C2}{c_2}\end{vmatrix}}
=
  \frac{y}
  {\begin{vmatrix} 
    \Node{C1y}{c_1}&\Node{A1y}{a_1} \\
    \Node{C2y}{c_2}&\Node{A2y}{a_2} \end{vmatrix}}
=
   \frac{1}
    {\begin{vmatrix}
    a_1&b_1\\a_2&b_2 \end{vmatrix}}
\]
% No need to be inside the display, but
% make sure to issue these commands on the same page !

% TWO COMPILATIONS NEEDED AFTER ANY MODIFICATION

\NodeLine[\color{blue}]{B1[south east] -> C2[north west]}
\NodeLine[\color{red}] {C1[south west]-> B2[north east]}
% for some reason B2[east] gives more pleasing result than B2[north east]
% note that B2 alone does not work, must be B2[]

\NodeLine[\color{green}]{C1y[] -> A2y[]}
\NodeLine[\color{magenta}] {A1y[]-> C2y[]}

\end{document}

引用

相关内容