Update:
Here is a better solution, but this has an issue, in that the three sided
node lines can be any color you want as long its black :-). The three sided
style defined here is based loosely on How to modify nodes in TikZ to automatically add a line on their top?. The corrected node on the right here was drawn as:
\node [three sided ] (1) at (0, 0) { $1$ };
\node [draw=red, draw opacity=0.5] (2) at (0.5,0) { $2$ };
Further Enhancements:
- Allow for other line colors for the
three sided
node.
Code:
\documentclass{article}
\usepackage{tikz}
\tikzset{three sided/.style={
draw=none,
append after command={
[shorten <= -0.5\pgflinewidth]
([shift={(-1.5\pgflinewidth,-0.5\pgflinewidth)}]\tikzlastnode.north east)
edge([shift={( 0.5\pgflinewidth,-0.5\pgflinewidth)}]\tikzlastnode.north west)
([shift={( 0.5\pgflinewidth,-0.5\pgflinewidth)}]\tikzlastnode.north west)
edge([shift={( 0.5\pgflinewidth,+0.5\pgflinewidth)}]\tikzlastnode.south west)
([shift={( 0.5\pgflinewidth,+0.5\pgflinewidth)}]\tikzlastnode.south west)
edge([shift={(-1.0\pgflinewidth,+0.5\pgflinewidth)}]\tikzlastnode.south east)
}
}
}
\begin{document}
\begin{tikzpicture}[thick, inner sep=0pt, minimum size=0.5cm]
\node [style={draw}] (1) at (0, 0) { $1$ };
\node [style={draw=red, draw opacity=0.5}] (2) at (0.5,0) { $2$ };
\end{tikzpicture}
%
\begin{tikzpicture}[thick, inner sep=0pt, minimum size=0.5cm]
\node [three sided ] (1) at (0, 0) { $1$ };
\node [draw=red, draw opacity=0.5] (2) at (0.5,0) { $2$ };
\end{tikzpicture}
\end{document}
You example did not really illustrate the issue, so I have adapted it to more clearly illustrate the issue, and also allows you to see that it is not duplicated in the second version. The two on the left show the problem, and the two on the right should be the desired result:
Note:
- This is a very manual solution that requires one to use
draw=none
for the node, followed by a call to \DrawNode
to do the actual drawing. There must be some magic postaction
that can be applied to have the same effect which woudl simply the usage.
- Also, I am not sure why you had
style={}
with the node options.
Code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\DrawNode}[2][]{%
\draw [#1]
([shift={(-\pgflinewidth,-0.5\pgflinewidth)}]#2.north east) --
([shift={(0.5\pgflinewidth,-0.5\pgflinewidth)}]#2.north west) --
([shift={(0.5\pgflinewidth,+0.5\pgflinewidth)}]#2.south west) --
([shift={(-\pgflinewidth,+0.5\pgflinewidth)}]#2.south east)
;
}%
\begin{document}
\begin{tikzpicture}[thick]
\node [style={draw, densely dotted, inner sep=0pt, minimum size=0.5cm}] (1) at (0, 0) { $1$ };
\node [style={draw=red, draw opacity=0.5, inner sep=0pt, minimum size=0.5cm}] (2) at (0.5,0) { $2$ };
\end{tikzpicture}
%
\begin{tikzpicture}[thick]
\node [draw=none, inner sep=0pt, minimum size=0.5cm] (1) at (0, 0) { $1$ };
\DrawNode[densely dotted]{1}
\node [draw=red, draw opacity=0.5, inner sep=0pt, minimum size=0.5cm] (2) at (0.5,0) { $2$ };
\end{tikzpicture}
\begin{tikzpicture}[thick]
\node [style={draw, inner sep=0pt, minimum size=0.5cm}] (1) at (0, 0) { $1$ };
\node [style={draw=red, draw opacity=0.5, inner sep=0pt, minimum size=0.5cm}] (2) at (0.5,0) { $2$ };
\end{tikzpicture}
%
\begin{tikzpicture}[thick]
\node [draw=none, inner sep=0pt, minimum size=0.5cm] (1) at (0, 0) { $1$ };
\DrawNode{1}
\node [draw=red, draw opacity=0.5, inner sep=0pt, minimum size=0.5cm] (2) at (0.5,0) { $2$ };
\end{tikzpicture}
\end{document}
You can use tape
shape from shapes
tikz` library.
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[tape, draw]{ABCD};
\node[tape, draw, tape bend top=none,tape bend height=2mm, %% tape bend bottom=none
tape bend bottom=out and in,fill=red,minimum width=2cm,minimum height=3cm] at (2.5, 0) {};
\end{tikzpicture}
\end{document}
If you want to draw them deliberately, here you go:
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[red,thick,fill=olive!40] (0,-3) -- (0,0) -- (3,0) -- (3,-3)
to [out=220,in=30] ( 0, -3) --cycle ;
\end{tikzpicture}
\begin{tikzpicture}
\draw[red,thick,fill=olive] (0,-3) -- (0,0) -- (3,0) -- (3,-3)
to [out=220,in=-40] (1,-3)
to [out=140,in=30] ( 0, -3) --cycle ;
\end{tikzpicture}
\end{document}
Best Answer
Here is a starting point for you. Start to modify it to your needs and if you run into problems, edit your question and comment under this answer, so I get a notification. Then I am going to help you further: