8

Inspired by How do you draw the "snake" arrow for the connecting homomorphism in the snake lemma? I created my own snake like diagram (see below).

The entries are rather large and the figure thus too wide. My question is: Why does the figure start only almost in the middle of the page and not on the left-hand side? Why is there so much free space on the left?

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\begin{document}
\begin{tikzpicture}[descr/.style={fill=white,inner sep=1.5pt}]
        \matrix (m) [
            matrix of math nodes,
             row sep=1em,
             column sep=2em,
        ]
        { Q_{5}\oplus\bigoplus_{i\in\{1,2,3,4\}} Q_{12345\setminus i}[1] &
        \bigoplus_{l\in\{1,2,3,4\}} Q_{l5}\oplus Q_{12345}[1] &
        \bigoplus_{j\neq k\in\{1,2,3,4\}} Q_{jk5} \\
          \bigoplus_{i\in\{1,2,3,4\}} Q_{12345\setminus i} &
        Q_{12345} &
        S_{12345} \\
        };
        \path[->, font=\scriptsize,>=latex]
        (m-1-1) edge (m-1-2)
        (m-1-2) edge (m-1-3)
        (m-1-3) edge[out=355,in=175] (m-2-1)
    (m-2-1) edge (m-2-2)
        (m-2-2) edge (m-2-3);
\end{tikzpicture}
\end{document}
2
  • Also, please help me to get my code block rendered appropriately! Thanks in advance!
    – Rasmus
    Oct 28, 2010 at 12:39
  • Fixed. For future reference: To insert a block of code, you can either pre-indent each line by 4 spaces, or, after entering the block, highlight the block and click on the "101010" symbol above the TextField. Oct 28, 2010 at 12:45

3 Answers 3

8

Something about the curvy edge is increasing the bounding box by a lot. This could be considered a bug. To cancel that effect, add overlay to the options for the \path which draws the arrows.

You might also consider using \limits for your \bigopluses and \mathclap (reference) to get the subscripts taking up less space. Here's my version:

\def\mathclap{\mathpalette\mathclapinternal}
\def\mathclapinternal#1#2{\clap{$\mathsurround=0pt#1{#2}$}}
\let\oldbigoplus=\bigoplus
\def\bigoplus{\oldbigoplus\limits}

\begin{tikzpicture}[remember picture=true]
        \matrix (m) [
            matrix of math nodes,
             row sep=1em,
             column sep=2em,
             text height=1.5ex, text depth=0.25ex
        ]
        {Q_{5}\oplus\bigoplus_{\mathclap{i\in\{1,2,3,4\}}} Q_{12345\setminus i}[1] &
        \bigoplus_{\mathclap{l\in\{1,2,3,4\}}} Q_{l5}\oplus Q_{12345}[1] &
        \bigoplus_{\mathclap{j\neq k\in\{1,2,3,4\}}} Q_{jk5} \\
          \bigoplus_{\mathclap{i\in\{1,2,3,4\}}} Q_{12345\setminus i} &
        Q_{12345} &
        S_{12345} \\
        };
        \path[overlay,->, font=\scriptsize,>=latex]
        (m-1-1) edge (m-1-2)
        (m-1-2) edge (m-1-3)
        (m-1-3) edge[out=348,in=172] (m-2-1)
        (m-2-1) edge (m-2-2)
        (m-2-2) edge (m-2-3);
\end{tikzpicture}

diagram

PS: Your descr/.style=... declaration has no effect unless you are actually applying the style to something. So you can cut that out for minimal example purposes.

Edit: I have incorporated @Caramdir's suggested edits.

2
  • 3
    I'm not 100% sure, but my guess would be that the control points for the Bezier curve making up the snake path were what were enlarging the picture. Oct 28, 2010 at 16:18
  • @Antal: good guess. Oct 28, 2010 at 20:31
5

Some additional small improvements on Matthew's version: In the original example I removed text height=1.5ex, text depth=0.25ex which I usually add to center the arrows on complicated the text. However, it is necessary here. Also the starting and ending directions of the curved arrow need to be tweaked a little bit:

\documentclass{article}
\usepackage{tikz,mathtools} %mathtools provides \mathclap
\usetikzlibrary{matrix,arrows}

\let\oldbigoplus=\bigoplus
\def\bigoplus{\oldbigoplus\limits}

\begin{document}

\begin{tikzpicture}
        \matrix (m) [
            matrix of math nodes,
            row sep=2.5em,
            column sep=2em,
            text height=1.5ex, text depth=0.25ex
        ]
        {Q_{5}\oplus\bigoplus_{\mathclap{i\in\{1,2,3,4\}}} Q_{12345\setminus i}[1] &
        \bigoplus_{\mathclap{l\in\{1,2,3,4\}}} Q_{l5}\oplus Q_{12345}[1] &
        \bigoplus_{\mathclap{j\neq k\in\{1,2,3,4\}}} Q_{jk5} \\
          \bigoplus_{\mathclap{i\in\{1,2,3,4\}}} Q_{12345\setminus i} &
        Q_{12345} &
        S_{12345} \\
        };

        \path[overlay,->, font=\scriptsize,>=latex]
        (m-1-1) edge (m-1-2)
        (m-1-2) edge (m-1-3)
        (m-1-3) edge[out=348,in=172] (m-2-1)
        (m-2-1) edge (m-2-2)
        (m-2-2) edge (m-2-3);
\end{tikzpicture}
\end{document}

rendered code

2
  • Nice. I thought about moving the arrows up to align with the center of the opluses but didn't know how best to do it. Oct 29, 2010 at 12:13
  • @Matthew: I favor using the mid east and mid west anchors for this purpose, which eliminates dimension-guessing but requires me to put anchors in just about every coordinate. I wonder if there is an edge style that can do this?
    – Ryan Reich
    Apr 25, 2011 at 23:51
4

It is most definitely the curvy path which is pushing things out. To see this, you can draw the bounding box at a particular point by writing:

\draw (current bounding box.north west) rectangle (current bounding box.south east);

at appropriate junctures, say after the \matrix and after the \path commands. Note that this draws the current bounding box so putting it at different places shows how the bounding box changes during the diagram.

As an alternative solution, the \useasboundingbox sets the bounding box for the picture. To be accurate, it means that as far as the bounding box is concerned everything after this command gets ignored. So putting it after the matrix command but before the path command means that the matrix gets used for the bounding box but the path doesn't. Thus my soution:

\documentclass{article}
\thispagestyle{empty}
\usepackage[scale=.96]{geometry}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\begin{document}
\begin{tikzpicture}
        \matrix (m) [
            matrix of math nodes,
             row sep=2em,
             column sep=2em,
        ]
        { Q_{5}\oplus\bigoplus_{i\in\{1,2,3,4\}} Q_{12345\setminus i}[1] &
        \bigoplus_{l\in\{1,2,3,4\}} Q_{l5}\oplus Q_{12345}[1] &
        \bigoplus_{j\neq k\in\{1,2,3,4\}} Q_{jk5} \\
          \bigoplus_{i\in\{1,2,3,4\}} Q_{12345\setminus i} &
        Q_{12345} &
        S_{12345} \\
        };
        \useasboundingbox (0,0);
        \path[->, font=\scriptsize,>=latex]
        (m-1-1) edge (m-1-2)
        (m-1-2) edge (m-1-3)
        (m-1-3) edge[out=355,in=175] (m-2-1)
    (m-2-1) edge (m-2-2)
        (m-2-2) edge (m-2-3);
\end{tikzpicture}
\end{document}

The effect of the overlay tag is similar. That tag removes the path from the bounding box consideration, whereas the \useasboundingbox removes everything after it (but not including itself).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .