Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to add a label that is diagonal to the following box, underneath the n', such that it is horizontally just below the box. Basically, I would like to "subtract" the difference between the content in the two cells. I'd like to add a label that says "Diff" just off the bottom left corner and then place the difference just below (p, n') box, outside of it.

For a picture of the box, see an earlier questions: making a box in beamer -- center aligning the title

Thank you very much for your help!

\documentclass[professionalfont, fleqn]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,fit,shapes.misc}

\begin{document}

\begin{frame}

\centering
 \only<1>{%
 \begin{tikzpicture}[
 box/.style = {draw,rectangle,minimum size=1.0cm,text
width=1cm,align=center}
 ]
\matrix (conmat) [row sep=0cm,column sep=0cm,ampersand
replacement=\&] {
\node (tpos) [box,label=left:\( \mathbf{p'} \),label=above:\(
\mathbf{p} \),] {};
  \& \node (fneg) [box,label=above:\textbf{n},] {$\checkmark$}; \\
 \node (fpos) [box,label=left:\( \mathbf{n'} \),] {$\checkmark$};
  \& \node (tneg) [box] {$\checkmark$}; \\
  };

\node [left=.05cm of conmat,text width=1.5cm,align=center]
{\textbf{actual \\ value}};
\node [above=.05cm of conmat] {\textbf{prediction}};
\end{tikzpicture}%
}

\end{frame}
\end{document}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I think beamer part is not related to this and previous question as it is only using TikZ content for just one frame. Just addding \node[below left= 2mm of conmat.south west] {diff}; to my answer given in the previous question linked is a solution.

\documentclass{beamer}
\usefonttheme{professionalfonts}
\usepackage{tikz}
\usetikzlibrary{positioning,matrix}
\begin{document}

\begin{frame}

\centering
\only<1>{%
 \begin{tikzpicture}
\matrix (conmat) [
draw,
matrix of math nodes, 
nodes in empty cells,
ampersand replacement=\&,
nodes={minimum size=1cm,outer sep=0,inner sep=0,anchor=center}
] {
                     \& \checkmark \\
\checkmark           \& \checkmark \\
  };
\draw (conmat.north) -- (conmat.south) (conmat.east) -- (conmat.west);
\node[above=2mm of conmat-1-1] {\(\mathbf{p}\)};
\node[left =2mm of conmat-1-1] {\(\mathbf{p'}\)}; 
\node[left =2mm of conmat-2-1] {\(\mathbf{p'}\)};
\node[above=2mm of conmat-1-2] {\textbf{n}};

\node[below left= 2mm of conmat.south west] {diff};

\node [left= 4mm of conmat,text width=1.5cm,align=center] {\textbf{actual \\ value}};
\node [above=4mm of conmat] {\textbf{prediction}};
\end{tikzpicture}%
}
\end{frame}
\end{document}

enter image description here

share|improve this answer
    
how can i add color to a cell? –  J G Jul 26 '12 at 18:16
    
@JG add |[fill=red]| to any cell together with inner sep=0, to the matrix options. –  percusse Jul 26 '12 at 19:00
    
Thank you! Also, how would I write normal text instead of the checkmark. When I tried to, it came out all italicized and without any space between the words. –  J G Jul 26 '12 at 23:07
    
@JG That's due to the matrix of math nodes option as it automatically makes every node text in math mode. You can change it to matrix of nodes but then you need to introduce the \(...\) to math text again or you keep the same option and use \text{regular text here}. So it depends which one is more common. –  percusse Jul 26 '12 at 23:10
    
Thank you! Could you please give me a more concrete example where to put that line in about color. I'm sorry but I do not understand what you mean. I also don't fully understand how to apply your last answer on the \text. Could you please give me a concrete example with the code? That would help so much. Thank you! –  J G Jul 27 '12 at 0:34
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.