Denote point with letter in tikz

tikz-pgf

I want to make a line, like this one.

\documentclass{article}
\usepackage(tikz}
\begin{tikzpicture}
   \draw (0,0) -- (1,0.5)
\end{tikzpicture}

For example, I draw a line that starts from coordinate (0,0) to (1,0.5). It should be like this one.

enter image description here

(Note: This is a picture that I draw in Paint)

Unfortunately, I don't know how to denote the points (for example A is the coordinate of (0,0) and B is the coordinate of (1,0.5).).

Another example, I copied one of the codes in this link:
How to draw parallelepiped and cube with LaTeX, and then I replace it as

\begin{center}
    \begin{tikzpicture}[every edge quotes/.append style={auto, text=black}]
  \pgfmathsetmacro{\cubex}{3}
  \pgfmathsetmacro{\cubey}{3}
  \pgfmathsetmacro{\cubez}{3}
  \draw [draw=, every edge/.append style={draw=black, densely dashed, opacity=.5}, fill=white]
    (0,0,0) coordinate (o) -- ++(-\cubex,0,0) coordinate (a) -- ++(0,-\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubez)  -- ++(\cubex,0,0) coordinate (c) -- cycle
    (o) -- ++(0,0,-\cubez) coordinate (d) -- ++(0,-\cubey,0) coordinate (e) edge (g) -- (c) -- cycle
    (o) -- (a) -- ++(0,0,-\cubez) coordinate (f) edge (g) -- (d) -- cycle;
  \path [every edge/.append style={draw=black, |-|}]
    (b) +(0,-5pt) coordinate (b1) edge ["8cm"'] (b1 -| c)
    (b) +(-5pt,0) coordinate (b2) edge ["8cm"] (b2 |- a)
    (c) +(3.5pt,-3.5pt) coordinate (c2) edge ["8cm"'] ([xshift=3.5pt,yshift=-3.5pt]e)

And I don't know how to denote point (for example let ABCDEFGH be a cube).

Best Answer

Welcome to TeX.SE!

Just add nodes above given coordinates:

\documentclass[border=3.141593]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \draw (0,0) node[above] {A} -- (2,1) node[above] {B};
\end{tikzpicture}
\end{document}

[![enter image description here][1]][1]

Addendum:

  • You are quite demanding: full service for two equal problems.
  • At the cube the adding of labels is the same problem as it is already solved for the line, in the answer above. So you only need to add labels to coordinates accordingly
  • However, your code for the cube is erroneous, so I guess that this is your main problem at it.
  • Since you are novice, I made exception and clean-up your code for cube and add desired labels for all corners (next time your question probably will be closed as Needs details or clarity).
  • Please, always provide complete small document called MWE (Minimal Working Example), which reproduce your problem and not only uncomplete code fragment. Many times problems has source in MWE preamble.
  • And finally, please one problem per question.

MWE for the cube can be for example:

\documentclass[border=3.141593]{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes}
\usepackage{siunitx}

\begin{document}
    \begin{tikzpicture}[
every edge quotes/.style={auto, font=\footnotesize, sloped, inner sep=2pt},
every label/.style = {inner sep=1pt, font=\scriptsize}
                        ]
  \pgfmathsetmacro{\cubex}{3}
  \pgfmathsetmacro{\cubey}{3}
  \pgfmathsetmacro{\cubez}{3}
  \draw 
    (0,0,0) coordinate[label=below left:A] (a) 
    -- ++ ( \cubex,0,0) coordinate[label=below right:B] (b) 
    -- ++ (0, \cubey,0) coordinate[label=above  left:C] (c) 
    -- ++ (-\cubex,0,0) coordinate[label=above  left:D] (d)
    -- cycle
    (d) -- ++ (0,0,-\cubez) coordinate[label=above right:E] (e) 
        -- ++ ( \cubex,0,0) coordinate[label=above right:F] (f) 
        -- ++ (0,-\cubey,0) coordinate[label=above right:G] (g) 
        -- (b)
    (c) -- (f);
  \fill[red!30, semitransparent] (a) -- (d) -- (e) -- (f) -- (g) -- (b) -- cycle;
  \draw[densely dashed] 
    (a) -- (e |- g) coordinate[label=above right:H] (h) -- (g)
           (h) -- (e);
  \path[draw=cyan, |-|]
    ([yshift=-3mm] a) edge ["\qty{8}{cm}"'] ([yshift=-3mm] b)
    ([xshift=-3mm] a) edge ["\qty{8}{cm}" ] ([xshift=-3mm] d)
    ([shift={(3mm,-3mm)}] b) to ["\qty{8}{cm}"'] ([shift={(3mm,-3mm)}] g)
    ;
\end{tikzpicture}
\end{document}

[![enter image description here][2]][2]

Edit: Added is siunitx package and lenght is written as \qty{8}{cm}. [1]: https://i.stack.imgur.com/64Npi.png [2]: https://i.stack.imgur.com/1NlAR.png