Graphics, Figures & TablestikZ | Labels beneath Nodes

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
gaelle
Posts: 1
Joined: Wed Jun 13, 2012 10:47 am

tikZ | Labels beneath Nodes

Post by gaelle »

Hi,

This my code :

Code: Select all

\documentclass{article}
\usepackage{tikz}

\begin{document}
 \begin{figure}
 \centering 
\begin{tikzpicture}
 [acteur/.style={circle, fill=black,thick, inner sep=2pt, minimum size=0.2cm}] 
\node (a1) at ( 2.5,2.5) [acteur][label=A]{};
\node (a2) at ( 2,1)[acteur][label={B}]{}; 
\node (a3) at ( 1,2.5) [acteur][label=C]{}; 
\node (a4) at ( 0,0) [acteur][label=D]{}; 
\node (a5) at ( -1.5,1.5) [acteur][label=E]{}; 
\node (a6) at ( -2,3) [acteur][label=F]{};
\node (a7) at ( -3,1) [acteur][label=G]{}; 
\node (a8) at ( -3.5,2) [acteur][label=H]{}; 
\node (a9) at ( 0,3) [acteur][label=I]{}; 
\draw [-, thick, red] (a1) -- (a2); 
\draw [-, thick, red] (a2) -- (a3); 
\draw [-, thick, red] (a1) -- (a3);
\draw [-, thick, red] (a2) -- (a4);
\draw [-, thick, red] (a5) -- (a4);
\draw [-, thick, red] (a5) -- (a6);
\draw [-, thick, red] (a6) -- (a7);
\draw [-, thick, red] (a7) -- (a8);
\draw [-, thick, red] (a8) -- (a5);
\draw [-, thick, red] (a7) -- (a5);
\draw [-, thick, red] (a9) -- (a5);
\draw [-, thick, red] (a9) -- (a4);
\draw [-, thick, red] (a5) -- (a3);
\draw [-, thick, red] (a6) -- (a2);
\end{tikzpicture} 
 \end{figure}
\end{document}
I would like to place some labels under the nodes. Any suggestions?

thanks in advance
Gaëlle

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tikZ | Labels beneath Nodes

Post by localghost »

Section 3.9 of the pgf/tikZ user guide describes quite precise how to do that.

Code: Select all

\documentclass[11pt]{article}
\usepackage{tikz}

\begin{document}
  \begin{figure}
    \centering 
    \begin{tikzpicture}[
      thick,
      acteur/.style={
        circle,
        fill=black,
        thick,
        inner sep=2pt,
        minimum size=0.2cm
      }
    ] 
      \node (a1) at (2.5,2.5) [acteur,label=A]{};
      \node (a2) at (2,1)[acteur,label=below:B]{}; 
      \node (a3) at (1,2.5) [acteur,label=C]{}; 
      \node (a4) at (0,0) [acteur,label=below:D]{}; 
      \node (a5) at (-1.5,1.5) [acteur,label=below:E]{}; 
      \node (a6) at (-2,3) [acteur,label=F]{};
      \node (a7) at (-3,1) [acteur,label=below:G]{}; 
      \node (a8) at (-3.5,2) [acteur,label=H]{}; 
      \node (a9) at (0,3) [acteur,label=I]{}; 
      \draw[red] (a1) -- (a2); 
      \draw[red] (a2) -- (a3); 
      \draw[red] (a1) -- (a3);
      \draw[red] (a2) -- (a4);
      \draw[red] (a5) -- (a4);
      \draw[red] (a5) -- (a6);
      \draw[red] (a6) -- (a7);
      \draw[red] (a7) -- (a8);
      \draw[red] (a8) -- (a5);
      \draw[red] (a7) -- (a5);
      \draw[red] (a9) -- (a5);
      \draw[red] (a9) -- (a4);
      \draw[red] (a5) -- (a3);
      \draw[red] (a6) -- (a2);
    \end{tikzpicture} 
  \end{figure}
\end{document}

Best regards and welcome to the board
Thorsten
Attachments
The obtained output.
The obtained output.
tikZ-labels.png (5.29 KiB) Viewed 31656 times
uyysidmc
Posts: 3
Joined: Thu Sep 06, 2018 12:26 pm

tikZ | Labels beneath Nodes

Post by uyysidmc »

How to make more thicker of a line ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10315
Joined: Mon Mar 10, 2008 9:44 pm

tikZ | Labels beneath Nodes

Post by Stefan Kottwitz »

You can add options for that:

Code: Select all

\draw [red, thick]      (a1) -- (a2);
\draw [red, very thick] (a2) -- (a3);
Stefan
LaTeX.org admin
Post Reply