A typical form for a node in TikZ is a circle around the text of the node. The shapes packages provides lot of other forms. What I couldn't find is an open half circle (or ellipse) under the node. Any ideas or hints on that? Cheers Renger
Asked
Active
Viewed 1,577 times
2
1 Answers
4
This is mainly inspired from: Creating node shapes
However it is just oriented in one direction here. I'm sure one can improve it to make it easily rotatable.
\documentclass{article}
\usepackage{tikz}
\makeatletter
\tikzset{arc style/.initial={}}
\pgfdeclareshape{half circle}{
\inheritsavedanchors[from=circle]
\inheritanchorborder[from=circle]
\inheritanchor[from=circle]{center}
\inheritanchor[from=circle]{south}
\inheritanchor[from=circle]{west}
\inheritanchor[from=circle]{north}
\inheritanchor[from=circle]{east}
% can add more anchors if necessary
\inheritbackgroundpath[from=circle]
\beforebackgroundpath{
% get and set options
\pgfkeys{/tikz/arc style/.get=\tmp}
\expandafter\tikzset\expandafter{\tmp}
\tikz@options
% get radius length and center coordinates
\radius \pgf@xa=\pgf@x
\centerpoint \pgf@xb=\pgf@x \pgf@yb=\pgf@y
% draw arc
\advance\pgf@yb by \pgf@xa
\pgfpathmoveto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpatharc{90}{-90}{\pgf@xa}
% change the last line to the following line if you want the half circle rotated in the other direction
% \pgfpatharc{90}{270}{\pgf@xa}
\pgfusepath{draw}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[
half circle,
fill=red!10, % can fill the circle if needed
minimum width=2cm,
arc style={red,thick}
] (c) {my half circle};
\end{tikzpicture}
\end{document}
Chachni
- 183
-
The problem with this solution is that you have a bunch of
Missing character: There is no <char> in font nullfont!errors. The line\radius \pgf@xa=\pgf@xis the culprit, but I do not know how to correct it. – Pygmalion Mar 15 '23 at 12:01 -
There was no issue/error in the past as far as I remember. Possibly due to a change in Tex version. Maybe see if the linked solution also gives the same errors. – Chachni Mar 15 '23 at 17:22
-
Yes it gives the same error, so I posted the same comment there as well. – Pygmalion Mar 15 '23 at 18:23

semicircle? – Symbol 1 Aug 18 '17 at 14:30How do I mark a question as duplicate?
– JulianWgs Aug 18 '17 at 19:56\node(A){some text};and then\draw(A.west)to[bend right=45](A.east);? – Symbol 1 Aug 18 '17 at 20:41