7

I work on TexMaker, and I would like to insert an identity arrow shaped like a long equal in a tikz diagram, and to do so people on internet often suggest to use the edge style "double". The problem is that I don't find the output very appealing (It has lateral edges that make it look like a box):

\documentclass[tikz,10pt]{article}

\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\begin{document}

\begin{tikzpicture}
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=2.5em, text height=1.5ex, text depth=0.25ex]
{ X & X \\ };
\path[-,font=\scriptsize]
(m-1-1) edge[double,thick,double distance=5pt] (m-1-2);
\end{tikzpicture}

\end{document}

enter image description here

I also tried the "transform canvas" option to draw a pair of parallel arrows, but it's very messy and the distance between the two edges doesn't seem to be constant. Is there an easier way to get a nice output?

  • 3
    Those edges are a viewer artifact I think, I see them in Evince, but not TeXworks or Okular. – Torbjørn T. Jul 16 '15 at 14:40
  • Is this for commutative diagrams? – Gonzalo Medina Jul 16 '15 at 14:42
  • Commutative, homotopy commutative, your pick. Let's say that it's for a generic diagram of arrows :) – LK512 Jul 16 '15 at 14:43
  • Why not double distance=2\fontdimen22\font? – Bernard Jul 16 '15 at 15:32
  • 1
    Ok, I can confirm that my problem was due to the fact that my version of tikz was obsolete. Sorry for the disturb and thanks for the help. – LK512 Jul 16 '15 at 16:09
10

You can use the equal "arrow" from tikz-cd.

  1. Using directly tikz-cd (if you are planning to draw a commutative diagram):

    \documentclass[10pt]{article}
    \usepackage{tikz-cd}
    
    \begin{document}
    
    \begin{tikzcd}
     X \ar[r,equal] & X 
    \end{tikzcd}
    
    \end{document}
    

enter image description here

  1. Using the tikz-cd features (in particular, equal) with your TikZ matrix:

    \documentclass[10pt]{article}
    \usepackage{tikz-cd}
    \usetikzlibrary{matrix,arrows}
    
    \begin{document}
    
    \begin{tikzpicture}[commutative diagrams/every diagram]
    \matrix (m) [matrix of math nodes, row sep=3em,
    column sep=2.5em, text height=1.5ex, text depth=0.25ex]
    { X & X \\ };
    \path[commutative diagrams/.cd, every arrow, every label,font=\scriptsize]
    (m-1-1) edge[commutative diagrams/equal] (m-1-2);
    \end{tikzpicture}
    
    \end{document}
    

enter image description here

The minimal class is so minimal that it's better not to use it except for test documents containing no much more than "Hello world!"

| improve this answer | |
  • I'm sorry but if i try to compile this script it returns me this error: "! Package tikz-cd Error: Arrow direction argument must contain only the characters l, r, u or d." Did I do something wrong? – LK512 Jul 16 '15 at 14:49
  • 1
    @LK512 You need an updated version of tikz-cd. Which version do you use? – Gonzalo Medina Jul 16 '15 at 14:51
  • 1
    @LK512 Try this (using the old syntax): \documentclass[tikz,10pt]{article} \usepackage{tikz-cd} \begin{document} \begin{tikzcd} X \ar[equal]{r} & X \end{tikzcd} \end{document} – Gonzalo Medina Jul 16 '15 at 14:53
  • 1
    @LK512 Ah, that error message strongly suugests that your version is old. Run \documentclass[tikz,10pt]{article} \usepackage{tikz-cd} \listfiles \begin{document} \begin{tikzcd} X & X \end{tikzcd} \end{document} which shouldn't give any errors and check the .log file or the console for the section *File List*; there you can find the version of tikz.cd` in your system. – Gonzalo Medina Jul 16 '15 at 15:01
  • 1
    @LK512 Really outdated. My system has version 2014/10/30 v0.9e Commutative diagrams with tikz. I suggest you update your packages (you will probably need to update tikz-cd and PGF/TikZ); the best thing to do would be to update your whole LaTeX System. Once you update your system, my code will work flawlessly and you'll have the latest versions of all packages (which, in the case of tikz-related packages) is always good. – Gonzalo Medina Jul 16 '15 at 15:08

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.