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 have tried many different things and I just can't wrap my head around how to work around the fact that the column sep option to TikZ's \matrix command changes the positioning of the matrix on the page. The code for my (rather large) picture is below with some added comments.

I would like to have a larger column sep than here (such as the 4em that's commented out below) while having the picture positioned such that the arrows down the middle are centered on the page. I can't see how this is possible without some ugly \hspace trial and error.

\documentclass[a4paper,11pt]{article}

\usepackage{tikz,relsize,mathtools}
\usetikzlibrary{matrix,arrows,shapes}
\usepackage{units}
\newcommand\onehalf{\nicefrac{1}{2}}

\begin{document}
\thispagestyle{empty}
\begin{center}{\huge\textbf{Separation Properties}}\end{center}
%
\vspace{1ex}
\begin{tikzpicture}
\tikzstyle{every node}=[font=\small]
\matrix (m) [nodes={draw,rectangle,thin,fill=blue!10},%
             row sep=1.7em,%column sep=4em,% Uncomment this to see m move around
             text depth=0.25ex,%
             draw=red] % Comment this out to not see the outline of the matrix
{%
\node (Met) {Metrizable};              & \node (T6) {P.\@ Normal Hausdorff (T$_{\smash[b]{6}}$)}; & \node (PN) {P.\@ Normal}; \\
\node (Ord) {Total order};             & \node (T5) {C./H.\@ T$_4$ (T$_{\smash[b]{5}}$)};         & \node (HN) {C./H.\@ Normal}; \\
\node (CH) {Cpt.\@ Hausdorff};         & \node (T4) {Normal Hausdorff (T$_{\smash[b]{4}}$)};      & \node (Norm) {Normal}; \\
\node (LCH) {Loc.\@ Cpt.\@ Hausdorff}; & \node (T3h) {Tychonoff (T$_{\smash[b]{3\onehalf}}$)};    & \node (CReg) {C.\@ Regular}; \\
\node (FH) {F./C.\@ Hausdorff};        & \node (T3) {Regular Hausdorff (T$_{\smash[b]{3}}$)};     & \node (Reg) {Regular}; \\
                                       & \node (T2h) {Urysohn (T$_{\smash[b]{2\onehalf}}$)}; \\
                                       & \node (T2) {Hausdorff (T$_{\smash[b]{2}}$)};             & \node (PReg) {Preregular (R$_1$)};\\
                                       & \node (T1) {T$_{\smash[b]{1}}$}; \\
                                       & \node (T0) {T$_{\smash[b]{0}}$}; \\
};
\path[->,thin]
(T3h)  edge [bend left=90]  node[fill=white,inner sep=2pt,pos=0.25]{$\scriptstyle\beta$} (T5)
(T0)   edge [bend right=60] node[fill=white,inner sep=2pt]{\scriptsize+R$\scriptstyle_1$} (T2)
(PReg) edge [bend right=60] node[fill=white,inner sep=2pt]{\scriptsize+Loc.~Cpt.} (CReg)
(Reg)  edge [bend right=80] node[fill=white,inner sep=2pt,pos=0.70]{\scriptsize+Lindel\"{o}f} (Norm)
(Reg)  edge [bend right=80] node[fill=white,inner sep=2pt,pos=0.75]{\scriptsize+2nd count.} (HN);
\path[->,thick] 
(T6)   edge node[]{} (T5)  (T6)  edge node[]{} (PN)
(T5)   edge node[]{} (T4)  (T5)  edge node[]{} (HN)
(T4)   edge node[auto]{\smaller UL} (T3h) 
    (T4)  edge node[]{} (Norm)
(T3h)  edge node[]{} (T3)  (T3h) edge node[]{} (FH)   (T3h) edge node[above,midway]{\smaller KEQ} (CReg)
(FH)   edge node[]{} (T2h)
(T3)   edge node[]{} (T2h) (T3)  edge node[above,midway]{\smaller KEQ} (Reg)
(T2h)  edge node[]{} (T2)
(T2)   edge node[]{} (T1)  (T2)  edge node[above,midway]{\smaller KEQ} (PReg)
(T1)   edge node[]{} (T0)
(PN)   edge node[]{} (HN)
(HN)   edge node[]{} (Norm)
(CReg) edge node[]{} (Reg)
(Reg)  edge node[]{} (PReg);
\path[->,thick]
(Met) edge node[]{} (T6)
(Ord) edge node[]{} (T5)
(CH)  edge [preaction={draw=white,-,line width=6pt}] node[]{} (T4)  (CH)  edge node[]{} (LCH)
(LCH) edge node[]{} (T3h);
\end{tikzpicture}
\end{document}
share|improve this question
    
The \"{o} breaking the syntax highlighting was only in the preview. Yes, I know, it's really annoying that the preview is so different from the final result; it's already been a long time, but they haven't fixed it yet. –  Hendrik Vogt Mar 1 '11 at 15:44
add comment

1 Answer

up vote 4 down vote accepted

Edit: I changed my original solution using \pgfresetboundingbox to this more elegant one

You can position the matrix around a certain node using matrix anchor=T6.north in the matrix options, and make the tikzpicture crop the bounding box so it only contains the middle line of the matrix using trim left=0pt,trim right=0pt in the tikzpicture options. Then issuing \centering before the tikzpicture will center the image around the vertical middle arrows:

\documentclass[a4paper,11pt]{article}

\usepackage{tikz,relsize,mathtools}
\usetikzlibrary{matrix,arrows,shapes}
\usepackage{units}
\newcommand\onehalf{\nicefrac{1}{2}}

\begin{document}
\thispagestyle{empty}
\begin{center}{\huge\textbf{Separation Properties}}\end{center}
%
\vspace{1ex}
\centering
\begin{tikzpicture}[trim left=0pt,trim right=0pt]
\tikzstyle{every node}=[font=\small]
\matrix (m) [matrix anchor=T6.north,nodes={draw,rectangle,thin,fill=blue!10},%
             row sep=1.7em,column sep=4em,% Uncomment this to see m move around
             text depth=0.25ex,%
             ]
{%
\node (Met) {Metrizable};              & \node (T6) {P.\@ Normal Hausdorff (T$_{\smash[b]{6}}$)}; & \node (PN) {P.\@ Normal}; \\
\node (Ord) {Total order};             & \node (T5) {C./H.\@ T$_4$ (T$_{\smash[b]{5}}$)};         & \node (HN) {C./H.\@ Normal}; \\
\node (CH) {Cpt.\@ Hausdorff};         & \node (T4) {Normal Hausdorff (T$_{\smash[b]{4}}$)};      & \node (Norm) {Normal}; \\
\node (LCH) {Loc.\@ Cpt.\@ Hausdorff}; & \node (T3h) {Tychonoff (T$_{\smash[b]{3\onehalf}}$)};    & \node (CReg) {C.\@ Regular}; \\
\node (FH) {F./C.\@ Hausdorff};        & \node (T3) {Regular Hausdorff (T$_{\smash[b]{3}}$)};     & \node (Reg) {Regular}; \\
                                       & \node (T2h) {Urysohn (T$_{\smash[b]{2\onehalf}}$)}; \\
                                       & \node (T2) {Hausdorff (T$_{\smash[b]{2}}$)};             & \node (PReg) {Preregular (R$_1$)};\\
                                       & \node (T1) {T$_{\smash[b]{1}}$}; \\
                                       & \node (T0) {T$_{\smash[b]{0}}$}; \\
};
\path[->,thin]
(T3h)  edge [bend left=90]  node[fill=white,inner sep=2pt,pos=0.25]{$\scriptstyle\beta$} (T5)
(T0)   edge [bend right=60] node[fill=white,inner sep=2pt]{\scriptsize+R$\scriptstyle_1$} (T2)
(PReg) edge [bend right=60] node[fill=white,inner sep=2pt]{\scriptsize+Loc.~Cpt.} (CReg)
(Reg)  edge [bend right=80] node[fill=white,inner sep=2pt,pos=0.70]{\scriptsize+Lindel\"{o}f} (Norm)
(Reg)  edge [bend right=80] node[fill=white,inner sep=2pt,pos=0.75]{\scriptsize+2nd count.} (HN);
\path[->,thick] 
(T6)   edge node[]{} (T5)  (T6)  edge node[]{} (PN)
(T5)   edge node[]{} (T4)  (T5)  edge node[]{} (HN)
(T4)   edge node[auto]{\smaller UL} (T3h) 
    (T4)  edge node[]{} (Norm)
(T3h)  edge node[]{} (T3)  (T3h) edge node[]{} (FH)   (T3h) edge node[above,midway]{\smaller KEQ} (CReg)
(FH)   edge node[]{} (T2h)
(T3)   edge node[]{} (T2h) (T3)  edge node[above,midway]{\smaller KEQ} (Reg)
(T2h)  edge node[]{} (T2)
(T2)   edge node[]{} (T1)  (T2)  edge node[above,midway]{\smaller KEQ} (PReg)
(T1)   edge node[]{} (T0)
(PN)   edge node[]{} (HN)
(HN)   edge node[]{} (Norm)
(CReg) edge node[]{} (Reg)
(Reg)  edge node[]{} (PReg);
\path[->,thick]
(Met) edge node[]{} (T6)
(Ord) edge node[]{} (T5)
(CH)  edge [preaction={draw=white,-,line width=6pt}] node[]{} (T4)  (CH)  edge node[]{} (LCH)
(LCH) edge node[]{} (T3h);
\end{tikzpicture}
\end{document}

centered large tikzpicture

share|improve this answer
    
Thanks a lot. I wouldn't have found that out by reading the documentation. It didn't help that Ubuntu comes with an old version of TikZ, so I had to put the latest in ~/texmf to get this to work –  kahen Mar 1 '11 at 16:35
    
This is the good answer. My first try was bad. Only fine if the matrix is alone on the page. –  Alain Matthes Mar 1 '11 at 16:39
add 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.