0

The following code renders a graph of three vertices and three edges. (Nothing exciting.) Between the first vertex and the second vertex, I want to convey that there may be n - 1 more vertices. The second "displayed" vertex may actually be the nth vertex. I am getting error messages with my use of the \underbrace command. I am using it within a node command. I think this is allowed within a node command. Can \mathrlap be used within a node command? Should any of this be coded in math mode?

I may want to have a longer text under the brace - like "$n+1$ more vertices may be here but that is for me to know and you to find out." How would I typeset that on two or three lines?

In a graph, what is the convention regarding edges between consecutive "displayed" vertices when there may be more to the graph between them? Do I draw part of an edge off of each vertex? Do I typeset ellipses in the middle between the two "displayed" vertices? Do I typeset a pair of ellipses between the "displayed" vertices - one ellipses next to each vertex?

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{mathtools} %Loads amsmath


\usepackage{tikz}
\usetikzlibrary{calc,intersections}


\begin{document}

\begin{tikzpicture}

\path (0,0) coordinate (vertex_1) (3,0) coordinate (vertex_n) (5,0) coordinate (vertex_n+1);
\draw[fill] (vertex_1) circle (1.5pt);
\draw[fill] (vertex_n) circle (1.5pt);
\draw[fill] (vertex_n+1) circle (1.5pt);

\draw (vertex_1) -- ($(vertex_1) +(0.75,0)$);
\draw (vertex_n) -- ($(vertex_n) +(-0.75,0)$) -- (vertex_n+1);

\coordinate (midpoint) at ($($(vertex_1) +(0.75,0)$)!0.5!($(vertex_n) +(-0.75,0)$)$);
\coordinate (brace) at ($(midpoint) +(0,-0.75)$);
%\node at (brace){\mathrlap{\underbrace{\phantom{n + 1\text{ more vertices}}}_{text}}};

\end{tikzpicture}


\end{document}
4
  • 1
    It is usable inside a node, but you must use it inside math mode.
    – user156344
    Commented Apr 14, 2019 at 20:03
  • I just added the following command, and it compiles. Thanks. Commented Apr 14, 2019 at 20:13
  • \node at (brace){$\mathrlap{\underbrace{\phantom{n + 1\text{ more vertices}}}_{n + 1\text{ more vertices}}}$}; Commented Apr 14, 2019 at 20:13
  • 1
    If your graph is a Dynkin diagram, or looks like one, you might try the dynkin-diagrams package on CTAN, which has built in support for braces between vertices and for dots to indicate indefinitely many vertices omitted: ctan.org/pkg/dynkin-diagrams?lang=en Commented May 7, 2019 at 18:49

2 Answers 2

4

Between the first vertex and the second vertex, I want to convey that there may be n - 1 more vertices. The second "displayed" vertex may actually be the nth vertex. I am getting error messages with my use of the \underbrace command. I am using it within a node command. I think this is allowed within a node command. Can \mathrlap be used within a node command? Should any of this be coded in math mode?

You need to put \underbrace, etc. inside math mode for it to work (I don't know if this is the intended output)

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{mathtools} %Loads amsmath
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{tikzpicture}
\path (0,0) coordinate (vertex_1) (3,0) coordinate (vertex_n) (5,0) coordinate (vertex_n+1);
\draw[fill] (vertex_1) circle (1.5pt);
\draw[fill] (vertex_n) circle (1.5pt);
\draw[fill] (vertex_n+1) circle (1.5pt);
\draw (vertex_1) -- ($(vertex_1) +(0.75,0)$);
\draw (vertex_n) -- ($(vertex_n) +(-0.75,0)$) -- (vertex_n+1);
\coordinate (midpoint) at ($($(vertex_1) +(0.75,0)$)!0.5!($(vertex_n) +(-0.75,0)$)$);
\coordinate (brace) at ($(midpoint) +(0,-0.75)$);
\node at (brace){$\mathrlap{\underbrace{\phantom{n + 1\text{ more vertices}}}_{text}}$};
\end{tikzpicture}
\end{document}

enter image description here


I may want to have a longer text under the brace - like "$n+1$ more vertices may be here but that is for me to know and you to find out." How would I typeset that on two or three lines?

My recommended version with automatic line breaks:

\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{tikzpicture}
\path (0,0) coordinate (vertex_1) (3,0) coordinate (vertex_n) (5,0) coordinate (vertex_n+1);
\draw[fill] (vertex_1) circle (1.5pt);
\draw[fill] (vertex_n) circle (1.5pt);
\draw[fill] (vertex_n+1) circle (1.5pt);
\draw (vertex_1) -- ($(vertex_1) +(0.75,0)$);
\draw (vertex_n) -- ($(vertex_n) +(-0.75,0)$) -- (vertex_n+1);
\coordinate (midpoint) at ($($(vertex_1) +(0.75,0)$)!0.5!($(vertex_n) +(-0.75,0)$)$);
\node (x) at (midpoint) {$\cdots$};
\node[draw,font=\footnotesize,text width=3cm] (callout) at (2,-2) {$n+1$ more vertices may be here but that is for me to know and you to find out.};
\draw[->] (callout) -- (x);
\end{tikzpicture}
\end{document}

enter image description here

or with manual line breaks:

\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{tikzpicture}
\path (0,0) coordinate (vertex_1) (3,0) coordinate (vertex_n) (5,0) coordinate (vertex_n+1);
\draw[fill] (vertex_1) circle (1.5pt);
\draw[fill] (vertex_n) circle (1.5pt);
\draw[fill] (vertex_n+1) circle (1.5pt);
\draw (vertex_1) -- ($(vertex_1) +(0.75,0)$);
\draw (vertex_n) -- ($(vertex_n) +(-0.75,0)$) -- (vertex_n+1);
\coordinate (midpoint) at ($($(vertex_1) +(0.75,0)$)!0.5!($(vertex_n) +(-0.75,0)$)$);
\node (x) at (midpoint) {$\cdots$};
\node[draw,font=\footnotesize,align=center] (callout) at (2,-2) {$n+1$ more vertices may\\be here but that is for me to\\know and you to find out.};
\draw[->] (callout) -- (x);
\end{tikzpicture}
\end{document}

enter image description here


In a graph, what is the convention regarding edges between consecutive "displayed" vertices when there may be more to the graph between them? Do I draw part of an edge off of each vertex? Do I typeset ellipses in the middle between the two "displayed" vertices? Do I typeset a pair of ellipses between the "displayed" vertices - one ellipses next to each vertex?

This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.

11
  • The option text width=3cm instructs TikZ to typeset text on more lines ... if needed. I have a request to modify to your code. How do I center the text? This is important in case I use \\ to artificially break a line. Commented Apr 14, 2019 at 20:23
  • @AgalnamedDesire Then you have options align=center and \\. However, I thought you were looking for text width.
    – user156344
    Commented Apr 14, 2019 at 20:24
  • OK. I have two options: \text width=3cm or align=center. With the second option, I would have to use \\. Commented Apr 14, 2019 at 20:27
  • @AgalnamedDesire I edited my answer.
    – user156344
    Commented Apr 14, 2019 at 20:29
  • 1
    \node[font=\footnotesize, anchor=north, inner sep=0, align=center] at (center_of_brace){\mbox{$n + 1$ more} \\ {\mbox{vertices}}}; Commented May 7, 2019 at 17:25
0
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{mathtools} %Loads amsmath


\usepackage{tikz}
\usetikzlibrary{calc,intersections}


\begin{document}

\begin{tikzpicture}

\path (0,0) coordinate (vertex_1) (3,0) coordinate (vertex_n) (5,0) coordinate (vertex_n+1);
\draw[fill] (vertex_1) circle (1.5pt);
\draw[fill] (vertex_n) circle (1.5pt);
\draw[fill] (vertex_n+1) circle (1.5pt);

\draw (vertex_1) -- ($(vertex_1) +(0.75,0)$);
\draw (vertex_n) -- ($(vertex_n) +(-0.75,0)$) -- (vertex_n+1);

\coordinate (midpoint) at ($(vertex_1)!0.5!(vertex_n)$);
\coordinate (center_of_brace) at ($(midpoint) +(0,-0.75)$);
\node[font=\footnotesize, anchor=north, inner sep=0, align=center] at (center_of_brace){\mbox{$n + 1$ more} \\
{\mbox{vertices}}};

\end{tikzpicture}

\end{document}

You must log in to answer this question.

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