5

I have the following code:

\documentclass[12pt, openany]{memoir}
\usepackage{amsmath}
\usepackage{tikz}

\begin{document}    
\[
    \begin{tikzpicture}[node distance=2cm,auto]
        \node (A) {$Q(\sqrt[6]{2}\:)$};
        \node (B) [below of=A]{$Q(\sqrt{2}\:)$};
        \node (C) [below of=B] {$Q$};
        \draw[-] (A) to node {3; $x^3-2=Irr(\sqrt[6]{2},Q(\sqrt{2},x)$} (B);
        \draw[-] (B) to node {2; $x^2-2=Irr(\sqrt{2},Q,x)$} (C);
    \end{tikzpicture}
\]
\end{document} 

I am wanting an arc (or whatever term should be used) from node A to node C without passing through node B; however, all of my attempts have been futile.

The third line that I've been drawing is a straight line from node A to node C; how can I change it so that it instead curves around node B, preferably to the left?

  • 2
    Hi Clayton, welcome to the site! Please make sure that the code you post is compilable by others, by adding the minimal required preamble (starting from \documentclass) and any macro definitions that are necessary. In this case, for example, the \Q is undefined, but you could actually take it out of the code completely, because it is unrelated to the problem. – Jake Jul 18 '13 at 13:49
  • No problem. You can make a block of code by indenting each line 4 spaces or by highlighting everything and clicking on the {} button in the question editor. Also, as @Jake points out, you should make sure that we can compile the code by just copying and pasting it into our own editors. This is called a Minimal Working Example (MWE). Can you update the code so we can compile it? – Adam Liter Jul 18 '13 at 13:52
  • @Jake: I've updated the code (and removed the line that I don't want anyway). – Clayton Jul 18 '13 at 13:55
  • @Adam: I have updated the code, as requested. – Clayton Jul 18 '13 at 13:56
9

You can draw a curved line using \draw (A) to [bend right=40] (C);, where the optional argument to bend right controls the curvature:

\documentclass[12pt, openany]{memoir}
\usepackage{amsmath}
\usepackage{tikz}

\begin{document}    
\[
    \begin{tikzpicture}[node distance=2cm,auto]
        \node (A) {$Q(\sqrt[6]{2}\:)$};
        \node (B) [below of=A]{$Q(\sqrt{2}\:)$};
        \node (C) [below of=B] {$Q$};
        \draw[-] (A) to node {3; $x^3-2=Irr(\sqrt[6]{2},Q(\sqrt{2},x)$} (B);
        \draw[-] (B) to node {2; $x^2-2=Irr(\sqrt{2},Q,x)$} (C);
        \draw (A) to [bend right=45] node [left] {text} (C);
    \end{tikzpicture}
\]
\end{document} 
  • If I may ask; what is the 40 representative of? – Clayton Jul 18 '13 at 14:03
  • 1
    @Clayton: It's the angle by which the start/end differs from the straight line: bend right=0 would be a straight line, bend right=90 means the initial and final directions of the curve are 90 degrees from the straight line. You can additionally control the curvature of the arc using looseness=<value>. A looseness of 2 will make the arc wider, for example. – Jake Jul 18 '13 at 14:06
3

Another possible solution is to use controls, which basically allows you to control the direction that the line 'leaves' the first node at and the direction at which it 'enters' the second node:

Update: You can also add text to the line created by the \draw by placing a node after it, before closing it with ;. See How to label a line created with draw command for the details of how this works.

\documentclass[12pt, openany]{memoir}
\usepackage{amsmath}
\usepackage{tikz}

\begin{document}    
\[
    \begin{tikzpicture}[node distance=2cm,auto]
        \node (A) {$Q(\sqrt[6]{2}\:)$};
        \node (B) [below of=A]{$Q(\sqrt{2}\:)$};
        \node (C) [below of=B] {$Q$};
        \node (D) [below of=C] {};
        \draw[-] (A) to node {3; $x^3-2=Irr(\sqrt[6]{2},Q(\sqrt{2},x)$} (B);
        \draw[-] (B) to node {2; $x^2-2=Irr(\sqrt{2},Q,x)$} (C);
        \draw[-] (A)..controls +(west:2) and +(west:2)..(C) node [left,pos=0.5] {text};
    \end{tikzpicture}
\]
\end{document}  

enter image description here

  • That is fantastic! I didn't know there could be so much control over the diagrams :) Thank you, Adam! – Clayton Jul 18 '13 at 14:05
  • 1
    In your code, I think I understand most of it, but what is the ':2' indicating here? I see that the controls is the command you want to force the entering/exiting part of the line, the west says precisely which part of the node, but what is the 2? – Clayton Jul 18 '13 at 14:08
  • How can I label the arc in this case, as I've done with the two lines? I'm currently running trial and error cases... – Clayton Jul 18 '13 at 14:14
  • 1
    @Clayton It's representative of a length, so anything that indicates length in (La)TeX can be used here (cm, mm, em, in, etc.). The default is cm, I believe. So it takes a point 2 centimeters west and sets it as the control point. – Adam Liter Jul 18 '13 at 14:16
  • 1
    Then, according the TikZ-PGF manual: "Suppose you are at point x and the first control point is y. Then the curve will start going in the direction of y at x, that is, the tangent of the curve at x will point toward y." So, the tangent of the curve at the node points toward the control point, which is 2cm to the west. – Adam Liter Jul 18 '13 at 14:17

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.