How to encircle section of matrix in LaTeX?












2















I am currently working on a lab report where I have to explain the Gaussian Elimination Method for a matrix. As part of my explanation, I want to circle/oval portions of a matrix.



Is there any way to circle the main diagonal of a matrix or a corner of it? Pics below with examples. I am thinking I may have to use a put structure on top of an array/matrix environment but I do not know how to do that.



EDIT: Here's what I currently have to generate the matrix that I drew on in the pictures:



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}


Circle the main diagonal



Circle the bottom left corner



Circle the top right corner










share|improve this question

























  • HI ! Could you show us what you code so far ? tex.meta.stackexchange.com/questions/228/…

    – flav
    2 hours ago











  • Added the code I used for the matrix, plus the obnoxiously long list of packages I'm using. Let me know if you need more, I don't think I have much more that may be relevant to the question though

    – elkshadow5
    1 hour ago


















2















I am currently working on a lab report where I have to explain the Gaussian Elimination Method for a matrix. As part of my explanation, I want to circle/oval portions of a matrix.



Is there any way to circle the main diagonal of a matrix or a corner of it? Pics below with examples. I am thinking I may have to use a put structure on top of an array/matrix environment but I do not know how to do that.



EDIT: Here's what I currently have to generate the matrix that I drew on in the pictures:



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}


Circle the main diagonal



Circle the bottom left corner



Circle the top right corner










share|improve this question

























  • HI ! Could you show us what you code so far ? tex.meta.stackexchange.com/questions/228/…

    – flav
    2 hours ago











  • Added the code I used for the matrix, plus the obnoxiously long list of packages I'm using. Let me know if you need more, I don't think I have much more that may be relevant to the question though

    – elkshadow5
    1 hour ago
















2












2








2


2






I am currently working on a lab report where I have to explain the Gaussian Elimination Method for a matrix. As part of my explanation, I want to circle/oval portions of a matrix.



Is there any way to circle the main diagonal of a matrix or a corner of it? Pics below with examples. I am thinking I may have to use a put structure on top of an array/matrix environment but I do not know how to do that.



EDIT: Here's what I currently have to generate the matrix that I drew on in the pictures:



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}


Circle the main diagonal



Circle the bottom left corner



Circle the top right corner










share|improve this question
















I am currently working on a lab report where I have to explain the Gaussian Elimination Method for a matrix. As part of my explanation, I want to circle/oval portions of a matrix.



Is there any way to circle the main diagonal of a matrix or a corner of it? Pics below with examples. I am thinking I may have to use a put structure on top of an array/matrix environment but I do not know how to do that.



EDIT: Here's what I currently have to generate the matrix that I drew on in the pictures:



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}


Circle the main diagonal



Circle the bottom left corner



Circle the top right corner







matrices arrays draw






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago







elkshadow5

















asked 2 hours ago









elkshadow5elkshadow5

165




165













  • HI ! Could you show us what you code so far ? tex.meta.stackexchange.com/questions/228/…

    – flav
    2 hours ago











  • Added the code I used for the matrix, plus the obnoxiously long list of packages I'm using. Let me know if you need more, I don't think I have much more that may be relevant to the question though

    – elkshadow5
    1 hour ago





















  • HI ! Could you show us what you code so far ? tex.meta.stackexchange.com/questions/228/…

    – flav
    2 hours ago











  • Added the code I used for the matrix, plus the obnoxiously long list of packages I'm using. Let me know if you need more, I don't think I have much more that may be relevant to the question though

    – elkshadow5
    1 hour ago



















HI ! Could you show us what you code so far ? tex.meta.stackexchange.com/questions/228/…

– flav
2 hours ago





HI ! Could you show us what you code so far ? tex.meta.stackexchange.com/questions/228/…

– flav
2 hours ago













Added the code I used for the matrix, plus the obnoxiously long list of packages I'm using. Let me know if you need more, I don't think I have much more that may be relevant to the question though

– elkshadow5
1 hour ago







Added the code I used for the matrix, plus the obnoxiously long list of packages I'm using. Let me know if you need more, I don't think I have much more that may be relevant to the question though

– elkshadow5
1 hour ago












1 Answer
1






active

oldest

votes


















4














Here is a possible way using 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}


enter image description here






share|improve this answer


























  • That looks really good! thats a lot of code though...

    – elkshadow5
    1 hour ago











  • @elkshadow5 Yes. I slightly simplified it. One could write TikZ styles that do the computations, if that's not already been done somewhere.

    – marmot
    25 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475937%2fhow-to-encircle-section-of-matrix-in-latex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Here is a possible way using 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}


enter image description here






share|improve this answer


























  • That looks really good! thats a lot of code though...

    – elkshadow5
    1 hour ago











  • @elkshadow5 Yes. I slightly simplified it. One could write TikZ styles that do the computations, if that's not already been done somewhere.

    – marmot
    25 mins ago
















4














Here is a possible way using 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}


enter image description here






share|improve this answer


























  • That looks really good! thats a lot of code though...

    – elkshadow5
    1 hour ago











  • @elkshadow5 Yes. I slightly simplified it. One could write TikZ styles that do the computations, if that's not already been done somewhere.

    – marmot
    25 mins ago














4












4








4







Here is a possible way using 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}


enter image description here






share|improve this answer















Here is a possible way using 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}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 27 mins ago

























answered 1 hour ago









marmotmarmot

102k4119229




102k4119229













  • That looks really good! thats a lot of code though...

    – elkshadow5
    1 hour ago











  • @elkshadow5 Yes. I slightly simplified it. One could write TikZ styles that do the computations, if that's not already been done somewhere.

    – marmot
    25 mins ago



















  • That looks really good! thats a lot of code though...

    – elkshadow5
    1 hour ago











  • @elkshadow5 Yes. I slightly simplified it. One could write TikZ styles that do the computations, if that's not already been done somewhere.

    – marmot
    25 mins ago

















That looks really good! thats a lot of code though...

– elkshadow5
1 hour ago





That looks really good! thats a lot of code though...

– elkshadow5
1 hour ago













@elkshadow5 Yes. I slightly simplified it. One could write TikZ styles that do the computations, if that's not already been done somewhere.

– marmot
25 mins ago





@elkshadow5 Yes. I slightly simplified it. One could write TikZ styles that do the computations, if that's not already been done somewhere.

– marmot
25 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475937%2fhow-to-encircle-section-of-matrix-in-latex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Сан-Квентин

8-я гвардейская общевойсковая армия

Алькесар