I have a rectangle ABCD and I want to put node info on the its sides and diagonals.
If i do this as in the attached .tex file (see also below), it works for AB, but not for AC, the path starts at B and not A.
It seems that for AC it still uses the last position from AB. How do I reset this position to (A)?
\def\mymacro[#1,#2]{\tikz [every edge quotes/.style={fill=white}] \draw[gray] (#1) edge ["mid"',<->] (#2)};
\mymacro[A,B]; %this gives the edge on the side AB of the rectangle as expected .
\mymacro[A,C]; %however, here the path (as said above) is starting at B, not A.
See the attached files attachment.tex and attachment.pdf -
How can I fix this? Anybody?
Graphics, Figures & Tables ⇒ using edge in tikz
using edge in tikz
- Attachments
-
- attachment.pdf
- (19.79 KiB) Downloaded 185 times
-
- attachment.tex
- (1.93 KiB) Downloaded 111 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Stefan Kottwitz
- Site Admin
- Posts: 10322
- Joined: Mon Mar 10, 2008 9:44 pm
using edge in tikz
Hi Kenth,
welcome to the forum!
Just don't use
Change
to
and move
Stefan
welcome to the forum!
Just don't use
\tikz
in the macro, because that starts another TikZ picture.Change
Code: Select all
\def\mymacro[#1,#2]{\tikz [every edge quotes/.style={fill=white}]
\draw[gray] (#1) edge ["mid"',<->] (#2)};
Code: Select all
\def\mymacro[#1,#2]{\draw[gray] (#1) edge ["mid"',<->] (#2)};
every edge quotes/.style={fill=white}
for example to the tikzpicture options.Stefan
LaTeX.org admin
using edge in tikz
Thanks, it works.
One follow-up question:
If I want mid in bold and mid sloped along the line (diagonal), what do I need to do?
Kent
One follow-up question:
If I want mid in bold and mid sloped along the line (diagonal), what do I need to do?
Kent
using edge in tikz
I solved the slope issue. (Easy in fact, by adding sloped below.)
I would really like the label (here "mid") to be bold and given by as a parameter of the macro such as
\def\mymacro[#1,#2,#3,#4]{\draw[#4] (#1) edge [#3,sloped,<->] (#2)};
This seems not to work.
Anybody?
Kent
I would really like the label (here "mid") to be bold and given by as a parameter of the macro such as
\def\mymacro[#1,#2,#3,#4]{\draw[#4] (#1) edge [#3,sloped,<->] (#2)};
This seems not to work.
Anybody?
Kent