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

I want to draw a TikZ matrix with its border and I would like to define the distance between most external matrix nodes and matrix border. Something like a matrix inner sep. If I change inner sep in matrix options declaration, all nodes inside the matrix also change its inner separation.

I know how to do it with fit library. I just want to know if its possible without it.

share|improve this question
up vote 7 down vote accepted

The inner sep for the matrix can be set and then nodes={inner sep=...} can be reset individually for the inner nodes.

\matrix[draw,matrix of nodes,inner sep=2mm,nodes={draw,inner sep=5mm}](a){

\draw[->,thick](a-1-1.base) -| ++(2cm,-5mm) node [right] {5mm};
\draw[->,thick](a.north)    -| ++(2cm,-2mm) node [right] {2mm};

enter image description here

share|improve this answer

Your Answer


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.