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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I overlap matrix cells in tikz relatively (using m-2-2 instead of specifying the coordinates)?

manual alignment

This is the code I have for manual alignment:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\begin{tikzpicture}

    \node(m) at (0,0) [matrix,matrix of nodes,ampersand replacement=\&] {1 \& 2\\3 \& abc\\};
    \node(n) at (12pt,-13pt) [matrix,matrix of nodes,ampersand replacement=\&] {5 \& 6\\7 \& 8\\};


\end{tikzpicture}

\end{document}

I tried some combos of below/above/anchors which didn't really work.

share|improve this question
up vote 5 down vote accepted

Here you go.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\begin{tikzpicture}

    \matrix[inner sep=0pt] (m) at (0,0) [matrix of nodes,ampersand replacement=\&,nodes={inner sep=4pt}] {1 \& 2\\3 \& abc\\};
    \matrix[inner sep=0pt] (n) at (m-2-2.center) [matrix of nodes,ampersand replacement=\&,anchor=n-1-1.center,nodes={inner sep=4pt}] {5 \& 6\\7 \& 8\\};


\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Please study the code, ask for clarifications, if any. I got to rush now. – Harish Kumar May 31 '14 at 4:20
    
Ah!. Image gives trouble. Somebody please update the image. – Harish Kumar May 31 '14 at 4:22

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.