Graphics, Figures & Tables ⇒ using edge in tikz II
using edge in tikz II
I use edge to place lables along straight line.
I should want to the lines and the node with different colours, see the attached files.
Anybody?
I should want to the lines and the node with different colours, see the attached files.
Anybody?
- Attachments
-
- latexforumposting.pdf
- (17.43 KiB) Downloaded 162 times
-
- latexforumposting.tex
- (1.95 KiB) Downloaded 143 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
using edge in tikz II
You can have style options for the quoted nodes, such as:
While the color (red) is applied to the whole path, this style options override it for the text, and if you use
because
Stefan
Code: Select all
\draw [red,thick] (A) to ["txt" '{fill=blue,text=yellow}] (B);
edge
instead of to
, you can even override the line color, such as:Code: Select all
\draw [red,thick] (A) edge ["txt" '{fill=blue,text=yellow}, green] (B);
edge
produces its own path.Stefan
LaTeX.org admin
using edge in tikz II
Great! Thanks.
One last question if I may: How to turn the label as bold?
Kent
One last question if I may: How to turn the label as bold?
Kent
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
using edge in tikz II
Again, thank you very much!
Kent

Kent
using edge in tikz II
Can we avoid the "-s around the label?
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
using edge in tikz II
Hi Kent,
not sure what you mean - in the output, or in the code? In the code "..." is a shortcut for a node syntax, so you can write
instead of
Stefan
not sure what you mean - in the output, or in the code? In the code "..." is a shortcut for a node syntax, so you can write
Code: Select all
\draw (A) to ["text"] (C);
Code: Select all
\draw (A) to node [sloped] {text} (C);
LaTeX.org admin
using edge in tikz II
To be precise, I want the macro
\def\mgElabel[#1,#2,#3,#4]{
\draw [#4] (#1) edge [#3 {fill=gray!20,text=black,font=\bfseries}] (#2);
}
to work with the label (argument #3) given without sourounding double apostrophes, i.e. text
instead of "text".
In addition, I have the following defined in my .tex file
\usetikzlibrary{quotes}
...
\begin{tikzpicture}[scale=\scalefactor,every edge quotes/.style={fill=gray!20,sloped}]
. . .
\mgElabel[A,C,"text",red];
. . .
\mgElabel[A,C,"text",red] works fine, but, \mgElabel[A,C,text,red] does not.
Kent
\def\mgElabel[#1,#2,#3,#4]{
\draw [#4] (#1) edge [#3 {fill=gray!20,text=black,font=\bfseries}] (#2);
}
to work with the label (argument #3) given without sourounding double apostrophes, i.e. text
instead of "text".
In addition, I have the following defined in my .tex file
\usetikzlibrary{quotes}
...
\begin{tikzpicture}[scale=\scalefactor,every edge quotes/.style={fill=gray!20,sloped}]
. . .
\mgElabel[A,C,"text",red];
. . .
\mgElabel[A,C,"text",red] works fine, but, \mgElabel[A,C,text,red] does not.
Kent
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
using edge in tikz II
Hi Kent,
the quotes are needed, but you could put them into the macro definition:
Stefan
the quotes are needed, but you could put them into the macro definition:
Code: Select all
\def\mgElabel[#1,#2,#3,#4]{
\draw [#4] (#1) edge ["#3" {fill=gray!20,text=black,font=\bfseries}] (#2);
}
LaTeX.org admin
using edge in tikz II
Stefan, thanks for your quick and kind responses!
For me, edge has been new.
Up to now I have only used node.
Kent
For me, edge has been new.
Up to now I have only used node.
Kent