The following declaration
\tikzset{
ncbar/.style={
to path={%
($(\tikztostart)!#1!90:(\tikztotarget)$)
-- ($(\tikztotarget)!#1!270:(\tikztostart)$)\tikztonodes}},
ncbar/.default=0.5cm,
}
does not pick up the \tikztonodes command, since the two nodes
\draw[<->] (A) to[ncbar=0.2](C) node[midway, sloped, above] {\small $30dm$};
\draw[<->] (C) to[ncbar=0.33](B) node[midway, sloped, above] {\small $40dm$};
do not appear in the picture:
Code inspired by
- How can I invert a 'clip' selection within TikZ?
- Parallel line segments connecting points in tikz
- Tikz - Custom Path Style with a Node to Label the Path
\documentclass{article}
\usepackage{amsmath}
\usepackage{pgf,tikz,pgfplots, tikz-cd}
\usetikzlibrary{arrows, intersections,decorations.markings, patterns, calc}
\usepackage{tkz-euclide}
\usepackage{calc}
\tikzset{
ncbar/.style={
to path={%
($(\tikztostart)!#1!90:(\tikztotarget)$)
-- ($(\tikztotarget)!#1!270:(\tikztostart)$)\tikztonodes}},
ncbar/.default=0.5cm,
}
\begin{document}
\begin{tikzpicture}[remember picture]
% A path that follows the edges of the current page
\tikzstyle{reverseclip}=[insert path={(current page.north east) --
(current page.south east) --
(current page.south west) --
(current page.north west) --
(current page.north east)}
]
\coordinate[] (A) at (-1,0);
\coordinate[] (B) at (1,0);
\coordinate[] (C) at (-0.5,0.86602);
\draw (A) -- (B) -- (C) -- cycle;
\draw (B) arc[start angle=0, end angle=180, radius=1];
\begin{pgfinterruptboundingbox}
\clip (A) -- (B) -- (C) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}
\fill[fill=green!20!white] (B) arc[start angle=0, end angle=180, radius=1];
\draw[<->] (A)+(0,-.2)--($(B)+(0,-.2)$) node[midway, below] {\small $50dm$};
\draw[<->] (A) toncbar=0.2 node[midway, sloped, above] {\small $30dm$};
\draw[<->] (C) toncbar=0.33 node[midway, sloped, above] {\small $40dm$};
\end{tikzpicture}
\end{document}





topath. I have a suspicion that they are being placed inside the clipped area, if you comment out the clip what happens? To qualify for\tikztonodesthen they need to be declared between thetoand the target node. – Andrew Stacey Apr 11 '22 at 08:41