3

Look at the following image and notice that $2$ is no vertically aligned with $1+i$ and $1-i$

enter image description here

Could someone tell me what I'm doing wrong? Here is my code:

\documentclass{standalone}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usepackage{chngcntr}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,quotes}
\tikzset{close/.style={outer sep=-2pt}}
\usepackage[outline]{contour}

\begin{document}
    \begin{tikzpicture}[
        dot/.style = {circle,
            draw,
            fill,
            inner sep=1.5pt}
        ]
        % curve above
        %---nodes---
        \node (Spec-Gauss) [label=center:${\text{Spec}(\mathbb{Z}[\,i\,])}$]{};
        \node (zero) [right = 1.5 cm of Spec-Gauss,
            dot,
            label=left:$0$]{};
        \node (two) [above right = 1 cm and 1 cm of zero,
            dot,
            "$1+i\vphantom{\big|}$"]{};
        %---curve---
        \draw [] (zero)
        to [out=45, in=180] (two);
        % curve below
        %--- nodes---
        \node (two-b)[below = 2 cm of two,
            dot,
            label=below:$1-i\vphantom{\big|}$]{};
        %---curve---
        \draw [] (zero)
        to [out=-45, in=180] (two-b);
        % integer line
        %---nodes---
        \node (Spec-Z) [below=2.5 cm of Spec-Gauss,
            label=center:${\text{Spec}(\mathbb{Z})}$]{};
        \node (zero-z) [right= 1.5 cm of Spec-Z,
            dot,
            "$0$"]{};
        \node (two-z) [right=1cm of zero-z,
            dot,
            "$2$"]{};
        %---line---
        \draw [] (zero-z)
            to (two-z);
    \end{tikzpicture}
\end{document}

9
  • Unfortunately ... when we copy your code, it can't compile ...
    – MS-SPO
    Feb 12 at 15:49
  • 1
    Can you make a sketch which shows how you want the alignment to be? Feb 12 at 15:54
  • 1
    WHY does it compile at all on your system ?? Lots of errors ...
    – MS-SPO
    Feb 12 at 15:58
  • 1
    @MS-SPO I'm deeply sorry. A bunch of packages were missing. I've tested with Overleaf and it compiles now. Feb 12 at 16:21
  • 1
    @LeandroCaniglia, right, I now can compile it and see everything besides the red rectangle ...
    – MS-SPO
    Feb 12 at 16:38

1 Answer 1

9

The issue is that positioning commands measure distance from the edges of the nodes, not the centers. To measure from the center of the previous node, use right = 2cm of Spec-Gauss.center. To measure to the center of the current node, add anchor=center.

Then you can place Spec(ℤ) as the node contents instead of as a label for an empty node.

enter image description here

\documentclass{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning, quotes}

\usetikzlibrary[fit]

\tikzset{dot/.style = {circle, draw, fill, inner sep=1.5pt}}

\begin{document}
    \begin{tikzpicture}
        % curve above
        %---nodes---
        \node (Spec-Gauss) {$\mathrm{Spec}(\mathbb{Z}[\,i\,])$};
        \node (zero) [right = 2cm of Spec-Gauss.center, anchor=center, dot, label=left:$0$]{};
        \node (two) [above right = 1 cm and 1 cm of zero.center, anchor=center, dot, label=above:$1+i$]{};
        %---curve---
        \draw (zero) to [out=45, in=180] (two);
        % curve below
        %--- nodes---
        \node (two-b)[below = 2 cm of two.center, anchor=center, dot, label=below:$1-i$]{};
        %---curve---
        \draw (zero) to [out=-45, in=180] (two-b);
        % integer line
        %---nodes---
        \node (Spec-Z) [below=2.5 cm of Spec-Gauss.center, anchor=center]{${\mathrm{Spec}(\mathbb{Z})}$};
        \node (zero-z) [below=2.5 cm of zero.center, anchor=center, dot, "$0$"]{};
        \node (two-z) [right=1cm of zero-z.center, anchor=center, dot, "$2$"]{};
        %---line---
        \draw (zero-z) to (two-z);
        \node[draw, fit=(two)(two-z), red, inner sep=0pt]{};
        \node[draw, fit=(zero)(zero-z), red, inner sep=0pt]{};
    \end{tikzpicture}
\end{document}

You must log in to answer this question.

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