# tikz and limits

I don't really know how to explain what I want to do other than giving you the code I wrote :

\varinjlim\limits_\cI \left( \begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=1em,column sep=1em]{
A & B     \\
C & \null \\
};
\path[-stealth]
(m-1-1) edge node [left]  {} (m-2-1)
edge node [above] {} (m-1-2);
\end{tikzpicture} \right) = C \coprod\limits_A B


The result I get is :

I want it to look like what you would expect it to look like i.e. no space under the diagram

Any suggestions ?

• Could you turn the code snippet into a complete minimal example document? That makes it much easier for others to try and come up with a solution (answering questions is fun, completing test document preambles is not). – Jake Oct 24 '13 at 19:33
• You have to set the baseline to the vertical center of the tikzpicture – egreg Oct 24 '13 at 19:33
• @egreg! TikZ answer! Woo! – Jake Oct 24 '13 at 19:36
• @Jake One has also to trim the bounding box. – egreg Oct 24 '13 at 19:42
• it seems like this particular example could be done without tikz though (ducks, and runs for cover) – cmhughes Oct 24 '13 at 19:43

You have to set the baseline of the tikzpicture to the vertical center of it; also it's better to use left delimiter and right delimiter rather than \left and \right:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
$\varinjlim\limits_{\mathcal{I}} \begin{tikzpicture}[baseline=(current bounding box.center)] \matrix (m) [ matrix of math nodes, row sep=1em, column sep=1em, left delimiter=(, right delimiter=), ]{ A & B \\ C \\ }; \path[-stealth] (m-1-1) edge node [left] {} (m-2-1) edge node [above] {} (m-1-2); \end{tikzpicture} = C \underset{A}{\amalg} B$
\end{document}


I changed \cI into \mathcal{I}, just a guess; also \coprod should not be used as a binary operator. If you really want to set the subscript underneath \amalg use \underset.

With the corrections suggested by Qrrbrbirlbel:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
$\varinjlim\limits_{\mathcal{I}} \begin{tikzpicture}[baseline=-\the\dimexpr\fontdimen22\textfont2] \matrix (m) [ matrix of math nodes, row sep=1em, column sep=1em, outer sep=0pt,inner sep=0pt, nodes={inner sep=.3333em}, left delimiter=(, right delimiter=), ]{ A & B \\ C \\ }; \path[-stealth] (m-1-1) edge node [left] {} (m-2-1) edge node [above] {} (m-1-2); \end{tikzpicture} = C \underset{A}{\amalg} B$
\end{document}


• Wouldn’t it be better to align the vertical center of the matrix to vertical center of the vertical center of the line, something like baseline=-.5ex or even -\the\dimexpr\fontdimen22\textfont2\relax? Maybe also adding inner sep=+0pt, outer sep=+0pt, nodes={inner sep=+.3333em} to the node to make the delimiters closer to the content of the matrix. – Qrrbrbirlbel Oct 24 '13 at 22:41
• @Qrrbrbirlbel Thanks; it would be nice to have a separate option for removing the padding around the matrix, rather than setting inner sep to zero and resetting it for nodes to a value that must be guessed. – egreg Oct 24 '13 at 22:58
• The .3333em value is the default one (also mentioned in the manual). However you can do: nodes/.expanded={inner xsep={\pgfkeysvalueof{/pgf/inner xsep}}, inner ysep={\pgfkeysvalueof{/pgf/inner ysep}}}, inner sep=+0pt, i.e. storing the current values in the every node style and then setting it to 0pt just for the matrix. Of course, one could define also wrapper keys like matrix inner xsep and so on that do these, but this would go beyond a comment, I believe. Maybe it would even be better to set the matrix’ inner sep to -.3333em to get the delimiters even closer (like arrays). – Qrrbrbirlbel Oct 24 '13 at 23:26

the same without tikZ

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\varinjlim\limits_{\mathcal{I}} \left(\begin{array}{l} A\to B \\ \,\downarrow \\ C \end{array}\right) = C \underset{A}{\amalg} B$
\end{document}


• Thanks, I accepted the other answer because it used tikz which I'm used to work with but your answer is great too. – ortholle Oct 24 '13 at 20:17