tikz-network icon indicating copy to clipboard operation
tikz-network copied to clipboard

Global options for tikzpicture

Open martinalex000 opened this issue 5 years ago • 1 comments

Not a bug but rather the wish for an additional feature.

I'd like to be able to insert arbitrary text between \begin{tikzpicture} and the first \Vertex-Statement. In particular this would allow me to insert lines such as the following: \SetDistanceScale{1.2} \SetVertexStyle[FillColor=blue,FillOpacity=0.7,LineOpacity=0.7,MinSize=0.5cm] as well as comments for myself.

Especially when using a lot of options, the resulting .tex-file becomes much more readable by not repeating global options within every vertex or edge statement. It would also allow to use features for nodes, which are not implemented in tikz-network such as LineOpacity for the borders of nodes.

martinalex000 avatar Dec 04 '19 14:12 martinalex000

Hi, thank you for your interest in tikz-network.

I am not sure if I understand your comment correctly. You like to change the Vertex and Edge style for all objects in your .tex file with the option \SetVertexStyle[<options>]? If so, this should already be possible:

\documentclass{article}
\usepackage{tikz-network}
\begin{document}

% This overwrites the default tikz-network options in the whole document
\SetDistanceScale{1.2} \SetVertexStyle[FillColor=blue,FillOpacity=0.7,LineOpacity=0.7,MinSize=0.5cm]

% graph with a new style for all vertices
\begin{tikzpicture}
  \Vertex{a} \Vertex[x=2]{b} \Edge(a)(b)
\end{tikzpicture}

% also the same modified style for the vertices
\begin{tikzpicture}
  \Vertex{a} \Vertex[x=2]{b} \Edge(a)(b)
\end{tikzpicture}

% changing the style again
\SetVertexStyle[FillColor=green,FillOpacity=0.7,LineOpacity=0.7,MinSize=0.5cm]

% graph with new style
\begin{tikzpicture}
  \Vertex{a} \Vertex[x=2]{b} \Edge(a)(b)
\end{tikzpicture}

\begin{tikzpicture}
% change the vertex style only within this tikzpicture
  \SetVertexStyle[FillColor=red,FillOpacity=0.7,LineOpacity=0.7,MinSize=0.5cm]

  \Vertex{a} \Vertex[x=2]{b} \Edge(a)(b)
\end{tikzpicture}

% here the same style as globally defined before
\begin{tikzpicture}
  \Vertex{a} \Vertex[x=2]{b} \Edge(a)(b)
\end{tikzpicture}

\end{document}

hackl avatar Dec 16 '19 16:12 hackl