1

I am beginner in Latex I've been trying for a day to draw a super simple straight line with three nodes on that. it goes fine but when I see the pdf. the beginning node doesn't start from the beginning of the line. it's a bit on the right side compared to a paragraph above it. I am so frustrated not to be able to control it.

Please don't make this question as a duplicate one I searched a lot couldn't find the answer.

The code is:

\begin{tikzpicture}
\filldraw[red] 
(0,0)   circle (2pt) node[blue,above]{$bin_1$}  --
(15,0)  circle (2pt) node[blue,above] {$bin_{nyquist}$}     -- 
(7,0)   circle (2pt) node[blue,above] {$k_1$};
\end{tikzpicture}

I meant coordinate (0,0). It is not the beginning of the line it's a bit in the right side compared to the paragraph above it. how can force it to go to the beginning of the line.

Torbjørn T.
  • 206,688
  • Welcome to TeX.SX! The coordinates inside a tikzpicture is only relative to the other things inside the tikzpicture, so (0,0) has no direct connection to the start of the line. The first node label ($bin_1$) will probably extend to the left of (0,0). – Torbjørn T. Oct 05 '16 at 11:18
  • @TorbjørnT. thanks for your comment. how can i shift it to the left then? – Chamran Ashour Oct 05 '16 at 11:20
  • If the picture starts a paragraph, it will be indented; add \noindent to remove it, or put the picture into a flushleft environment. The remaining indentation is the border of the label {$bin_1$}; if you change it to node[blue,above,inner sep=0mm]{$bin_1$} this indentation is also gone. But now the label is too close to the node, so you need node[blue,above,inner sep=0mm,yshift=0.5ex]{$bin_1$} to counter act that. – gernot Oct 05 '16 at 11:22
  • Essentially, http://tex.stackexchange.com/questions/176723/align-tikzpicture-to-body-text-with-node-as-reference/176727#176727 See also http://tex.stackexchange.com/a/12455/586 for more explanation of what happens (if needed). – Torbjørn T. Oct 05 '16 at 11:23
  • @TorbjørnT. with links give whole picture of the issue thanks! – Chamran Ashour Oct 05 '16 at 11:30

1 Answers1

0

If this is just the start of your diagram, it might be worthwhile to define the circles as nodes and to associate the labels explicitly. The code is longer, but more flexible and more structured.

\documentclass{article}
\usepackage{tikz}
\begin{document}
XXX%
\begin{tikzpicture}%
  [mynode/.style={circle,fill=green,minimum width=5pt,inner sep=0pt,outer sep=0pt},
   mylabel/.style={blue,inner sep=0mm,label distance=0.5ex}
  ]
\node[mynode,label={[mylabel]$bin_1$}]                  (a) at (0,0) {};
\node[mynode,label={[mylabel]$k_1$}]                    (b) at (2,0) {};
\node[mynode,label={[mylabel]$bin_{\mathrm{nyquist}}$}] (c) at (4,0) {};
\draw[red] (a) -- (b) -- (c);
\end{tikzpicture}%
XXX
\end{document}

enter image description here

gernot
  • 49,614