3

The second, third and fourth formulæ should be on the right side of the point like the formula in the first line.

enter image description here

MWE

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{tikz}

\begin{document} 

\begin{tikzpicture}

% Graph Paper
\draw[step=0.5,help lines,black!20] (-5,-5) grid (10,5);

% Coordinate
\coordinate (a) at (0,0);

% Nodes
\node[right of=a] {\(y = 5 - 3x\)};
\node[below of=a] (b) {\(y = 5 - 3x\)};
\node[below of=b] (c) {\(y = 5 - 3x\)};
\node[below of=c] (d) {\(\frac{1}{2}\)};

% Points
\fill (a) circle[radius=2pt];
\fill (b) circle[radius=2pt];
\fill (c) circle[radius=2pt];
\fill (d) circle[radius=2pt];

\end{tikzpicture}

\end{document}
Bernard
  • 271,350

1 Answers1

6

Here is another approach, using the positioning library and its below=of syntax, instead of the deprecated below of= syntax (cf. Difference between "right of=" and "right=of" in PGF/TikZ). A key point here is the on grid key in the eqitem style, which indicates that the distance between nodes is measured between the center points of the nodes, not the edges.

The nodes themselves are just filled black circles, while the equations are added as labels to the nodes, supplied by the default argument to the eqitem style. The presence of a #1 in a style definition means that it has to be used as eqitem={...}, where ... is the label text, which is placed in math mode.

See also some comments in the code.

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document} 

\begin{tikzpicture}[
node distance=10mm, % set distance between nodes
eqitem/.style={
  on grid,            % node distance measured between node centers
  circle,             % circular node ...
  fill,               % filled (with black, the default colour) ...
  minimum size=4pt,   % diameter 4pt because no content and ...
  inner sep=0,        % no padding between content and node edge
  label={right:$#1$}} % add label right of the node
]

% Graph Paper
\draw[step=0.5,help lines,black!20] (-5,-5) grid (10,5);

\node [eqitem={y = 5 - 3x}] (a) at (0,0.25) {};
\node [eqitem={y = 5 - 3x},below=of a] (b) {};
\node [eqitem={y = 5 - 3x},below=of b] (c) {};
\node [eqitem={y = 5 - 3x},below=of c] (d) {};

\end{tikzpicture}

\end{document}

enter image description here

chains

A possibly useful extension of this is to make use of the chains library. This lets you make "chains" of nodes that are automatically placed below or next to the previous node in the chain.

The new additions in the style are on chain, and that I added a name to the label, which lets you refer to those as coordinates later, e.g. if you need to draw arrows to/from one.

output of below code

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{
  positioning,
  chains
}
\begin{document} 

\begin{tikzpicture}[
node distance=10mm,
eqitem/.style={
   on grid,
   circle,
   fill,
   minimum size=4pt,
   inner sep=0,
   label={[name=\tikzchaincurrent-l]right:$#1$}, % \tikzcurrent is name of current node in chain
   node contents={}, % node text, with this we can use \node[...]; instead  of \node[...] {};
   on chain % add node to current chain
}]

% Graph Paper
\draw[step=0.5,help lines,black!20] (-5,-5) grid (10,5);

\begin{scope}[
  start chain=eqs1 going below
]
\node [eqitem={y = 5 - 3x}];
\node [eqitem={y = 5 - 3x}];
\node [eqitem={y = 5 - 3x}];
\node [eqitem={y = 5 - 3x}];
\end{scope}

\begin{scope}[
  start chain=eqs2 going below
]
% place the first node in the chain with at={(x,y)}, the rest are placed automatically
\node [eqitem={y = 5 - 4x},at={(3,0)}];
\node [eqitem={y = 5 - 5x}];
\node [eqitem={y = 5 - 6x}];
\node [eqitem={y = 5 - 7x}];
\end{scope}

% to illustrate that node names are available
% the circles in the eqs1 chain are named eqs-N, while the labels
% (i.e. the equations) are named eqs-N-l (l for label)
\draw [red,shorten <=2pt,shorten >=3pt,->] (eqs1-1) to[bend left] (eqs2-1);
\draw [blue,shorten <=2pt,shorten >=3pt,->] (eqs1-4-l) to[bend right] (eqs2-4-l);

\end{tikzpicture}

\end{document}
Torbjørn T.
  • 206,688