4

I am using tikz for creating commutative diagram in a mathematical text. However, diagrams are part of text/sentences, hence I sometimes would like to end them with a comma or full stop.

A standard layout I use would look like this:

\documentclass[a4paper, reqno, 14pt]{amsart}
\usepackage{amsthm,amsfonts,amssymb,amsmath}
%\tikz
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\setlength\PreviewBorder{5pt}%
\usetikzlibrary{arrows,chains,matrix,positioning,scopes}
\makeatletter
\tikzset{join/.code=\tikzset{after node path={%
\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\makeatother
\tikzset{>=stealth',every on chain/.append style={join},
         every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle,
   execute at end node=$]
%------------------------------------------------------
\begin{document}
    \noindent\hspace*{\fill}
\begin{tikzpicture}
 \matrix (m) [matrix of math nodes, row sep=3em, column sep=3em]
    { 0 & M  & M  & M/fM  & 0 \\
      0 & M_B & M_B & (M/fM)_B & 0 \\ };
  { [start chain] \chainin (m-1-1);
    \chainin (m-1-2);
    { [start branch=A] \chainin (m-2-2)
        [join={node[right,labeled] {}}];}
    \chainin (m-1-3) [join={node[above,labeled] {\cdot f}}];
    { [start branch=B] \chainin (m-2-3)
        [join={node[right,labeled] {}}];}
    \chainin (m-1-4) [join={node[above,labeled] {}}];
    { [start branch=C] \chainin (m-2-4)
        [join={node[right,labeled] {}}];}
    \chainin (m-1-5); }
  { [start chain] \chainin (m-2-1);
    \chainin (m-2-2);
    \chainin (m-2-3) [join={node[above,labeled] {\cdot f \otimes \operatorname{id}}}];
    \chainin (m-2-4) [join={node[above,labeled] {}}];
    \chainin (m-2-5); } 
        \end{tikzpicture} 
        \hspace{\fill} \\
\end{document}

If I just write (in the example above) "0." for the last entry of the second row, the last arrow of the second row will be shorter - which looks horribly. What is the intended way to end this diagram with a full stop?

  • 2
    Welcome to TeX.SX! Would you add the necessary code to make the example compilable? On the other hand, 0\makebox[0pt][l]{.} should work (it would be 0\rlap{.} for the macho TeX programmer). – egreg Jul 1 '14 at 10:52
7

You can use a period that doesn't take any physical space. Add

\newcommand{\nospaceperiod}{\makebox[0pt][l]{\,.}}

to your document preamble and type

0\nospaceperiod

where you want punctuation. You may want to have the same for other punctuations, so maybe a different command is better:

\newcommand{\nospacepunct}[1]{\makebox[0pt][l]{\,#1}}

and you'd type

0\nospacepunct{.}

or \nospacepunct{,} for a comma.


There is a simpler way to achieve the same diagram with the tikz-cd package.

\documentclass{amsart}
\usepackage{tikz-cd}

\newcommand{\nospaceperiod}{\makebox[0pt][l]{\,.}}

\begin{document}
\[
\begin{tikzcd}
0 \arrow{r} &
  M    \arrow{r}{f} \arrow{d} &
  M    \arrow{r}    \arrow{d} &
  M/fM \arrow{r}    \arrow{d} &
  0
\\
0 \arrow{r} &
  M_B      \arrow{r}{f\otimes\mathrm{id}} &
  M_B      \arrow{r} &
  (M/fM)_B \arrow{r} &
  0\nospaceperiod
\end{tikzcd}
\]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.