我目前正在撰寫一份實驗室報告,其中我必須解釋矩陣的高斯消去法。作為我的解釋的一部分,我想要矩陣的圓形/橢圓形部分。
有什麼方法可以圈出矩陣的主對角線或矩陣的角嗎?下面的圖片帶有範例。我想我可能必須\put
在陣列/矩陣環境之上使用結構,但我不知道該怎麼做。
編輯:這是我目前必須生成的在圖片中繪製的矩陣:
\usepackage[utf8]{inputenc}
\usepackage{indentfirst}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[numbers]{natbib}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
\usepackage{layout}
\usepackage[title]{appendix}
\usepackage[justification=centering]{caption}
\usepackage{titlesec}
\usepackage[percent]{overpic}
\usepackage{amsmath}
\usepackage{systeme}
\usepackage{blkarray, bigstrut}
...
\begin{center}
\begin{blockarray}{cccc}
\begin{block}{ [ ccc| c ]}
\bigstrut[t]
1 & -1 & 3 & -3 \\
-1 & 0 & -2 & 1 \\
2 & 2 & 4 & 0 \bigstrut[b] \\
\end{block}
\end{blockarray}
\end{center}
答案1
這是一種可能的使用方式tikzmark
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{blkarray, bigstrut}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,fit}
\begin{document}
\begin{center}
\begin{blockarray}{cccc}
\begin{block}{ [ ccc| c ]}
\bigstrut[t]
\tikzmarknode{A11}{1} & -1 & 3 & -3 \\
-1 & 0 & -2 & 1 \\
2 & 2 & \tikzmarknode{A33}{4} & 0 \bigstrut[b] \\
\end{block}
\end{blockarray}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\draw let \p1=($(A33)-(A11)$),\n1={atan2(\y1,\x1)} in
node[rotate fit=\n1,fit=(A11) (A33),draw,rounded corners,inner sep=2pt]{};
\end{tikzpicture}
\begin{center}
\begin{blockarray}{cccc}
\begin{block}{ [ ccc| c ]}
\bigstrut[t]
1 & -1 & 3 & -3 \\
\tikzmarknode{B21}{-1} & 0 & -2 & 1 \\
\tikzmarknode{B31}{2} & \tikzmarknode{B32}{2} & 4 & 0 \bigstrut[b] \\
\end{block}
\end{blockarray}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\node[fit=(B21) (B31) (B32),inner sep=2pt] (FB){};
\path (FB.south east) arc(-90:45:4pt) coordinate(aux1);
\draw (aux1) arc(45:-90:4pt) -- ([xshift=4pt]FB.south west)
arc(-90:-180:4pt) -- (FB.north west) arc(180:45:4pt) -- cycle;
\end{tikzpicture}
\begin{center}
\begin{blockarray}{cccc}
\begin{block}{ [ ccc| c ]}
\bigstrut[t]
1 & \tikzmarknode{C12}{-1} & \tikzmarknode{C13}{3} & -3 \\
-1 & 0 & \tikzmarknode{C23}{-2} & 1 \\
2 & 2 & 4 & 0 \bigstrut[b] \\
\end{block}
\end{blockarray}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\node[fit=(C12) (C23) (C13),inner sep=2pt] (FC){};
\path (FC.north west) arc(90:225:4pt) coordinate(aux2);
\draw (aux2) arc(225:90:4pt) -- ([xshift=-4pt]FC.north east)
arc(90:0:4pt) -- (FC.south east) arc(0:-135:4pt) -- cycle;
\end{tikzpicture}
\end{document}
更短的解由下式給出
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{blkarray, bigstrut}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{center}
\begin{blockarray}{cccc}
\begin{block}{ [ ccc| c ]}
\bigstrut[t]
\tikzmarknode{A11}{1} & -1 & 3 & -3 \\
-1 & 0 & -2 & 1 \\
2 & 2 & \tikzmarknode{A33}{4} & 0 \bigstrut[b] \\
\end{block}
\end{blockarray}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\draw[red] plot[smooth cycle] coordinates {(A11.north)
(A33.north east) (A33.south) (A11.south west)};
\end{tikzpicture}
\begin{center}
\begin{blockarray}{cccc}
\begin{block}{ [ ccc| c ]}
\bigstrut[t]
1 & -1 & 3 & -3 \\
\tikzmarknode{B21}{-1} & 0 & -2 & 1 \\
\tikzmarknode{B31}{2} & \tikzmarknode{B32}{2} & 4 & 0 \bigstrut[b] \\
\end{block}
\end{blockarray}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\draw[red] plot[smooth cycle] coordinates {(B21.north west) (B21.north east)
(B32.north east) (B32.south east) (B31.south west)};
\end{tikzpicture}
\begin{center}
\begin{blockarray}{cccc}
\begin{block}{ [ ccc| c ]}
\bigstrut[t]
1 & \tikzmarknode{C12}{-1} & \tikzmarknode{C13}{3} & -3 \\
-1 & 0 & \tikzmarknode{C23}{-2} & 1 \\
2 & 2 & 4 & 0 \bigstrut[b] \\
\end{block}
\end{blockarray}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\draw[red] plot[smooth cycle] coordinates {(C12.north west) (C13.north east)
(C23.south east) (C23.south west) (C12.south west)};
\end{tikzpicture}
\end{document}
如果全部替換\tikzmarknode
為\tikzmarknode[inner sep=1pt]
,則變為