# Rounded corners only at one side of a TikZ node

How can I make rounded corners at one side (only right, only left)?

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [fill=gray, rounded corners=10pt]{

};
\end{tikzpicture}
\end{document}

-

This is possible with the rounded rectangle shape type:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc}
\begin{document}

\begin{tikzpicture}[every node/.style={fill=gray, rounded rectangle, minimum width=2cm, minimum height=1cm}]
\node [](A){};
\node [rounded rectangle west arc=none, below=of A](B){};
\node [rounded rectangle east arc=none, below=of B]{};
\end{tikzpicture}

\end{document}


See Section 48.8 of the TikZ Manual for further options.

-

Above method only allowing east or west non-rounding. I needed that and was not satisfied with the answer.

So we have to adopt method from other solution (Rounded corners in TikZ trees.) and make customized differently rounded corners.

I would be gratefull if someone includes this in future TIKZ.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}

\makeatletter

\pgfkeys{/pgf/.cd,
}
\newif\ifpgf@rectanglewrc@donecorner@
\def\pgf@rectanglewithroundedcorners@docorner#1#2#3#4#5{%
\edef\pgf@marshal{%
\noexpand\pgfintersectionofpaths
{%
\noexpand\pgfpathmoveto{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}%
\noexpand\pgfpathlineto{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
}%
{%
{\noexpand\pgfpoint{\the\pgf@xc}{\the\pgf@yc}}%
{\noexpand\pgfpoint{#1}{#2}}}%
\noexpand\pgfpatharc{#3}{#4}{#5}%
}%
}%
\pgf@process{\pgf@marshal\pgfpointintersectionsolution{1}}%
\pgf@process{\pgftransforminvert\pgfpointtransformed{}}%
\pgf@rectanglewrc@donecorner@true
}
\pgfdeclareshape{rectangle with rounded corners}
{
\inheritsavedanchors[from=rectangle] % this is nearly a rectangle
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{north west}
\inheritanchor[from=rectangle]{north east}
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\inheritanchor[from=rectangle]{mid}
\inheritanchor[from=rectangle]{mid west}
\inheritanchor[from=rectangle]{mid east}
\inheritanchor[from=rectangle]{base}
\inheritanchor[from=rectangle]{base west}
\inheritanchor[from=rectangle]{base east}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{south west}
\inheritanchor[from=rectangle]{south east}

}
}
}
}

\backgroundpath{%
\pgfpathmoveto{}%
\pgfpathlineto{}%
\pgfpathlineto{}%
\pgfpathlineto{}%
\pgfpathlineto{}%

}

\northeast\pgf@x=\pgf@xa}
\southwest\pgf@y=\pgf@ya}
\southwest\pgf@x=\pgf@xa}
\northeast\pgf@y=\pgf@ya}

\anchorborder{%
\pgf@xb=\pgf@x% xb/yb is target
\pgf@yb=\pgf@y%
\southwest%
\pgf@xa=\pgf@x% xa/ya is se
\pgf@ya=\pgf@y%
\northeast%
\pgf@xc=.5\pgf@x% x/y is half width/height
\pgf@yc=.5\pgf@y%
\edef\pgf@marshal{%
\noexpand\pgfpointborderrectangle
{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}
{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
}%
\pgf@process{\pgf@marshal}%
\pgfextract@process\borderpoint{}%
%
\pgf@rectanglewrc@donecorner@false
%
% do southwest corner
\southwest\pgf@xc=\pgf@x\pgf@yc=\pgf@y
\borderpoint
\ifdim\pgf@x<\pgf@xc\relax\ifdim\pgf@y<\pgf@yc\relax
\fi\fi
%
% do southeast corner
\ifpgf@rectanglewrc@donecorner@\else
\southwest\pgf@yc=\pgf@y\relax\northeast\pgf@xc=\pgf@x\relax
\borderpoint
\ifdim\pgf@x>\pgf@xc\relax\ifdim\pgf@y<\pgf@yc\relax
\fi\fi
\fi
%
% do northeast corner
\ifpgf@rectanglewrc@donecorner@\else
\northeast\pgf@xc=\pgf@x\relax\pgf@yc=\pgf@y\relax
\borderpoint
\ifdim\pgf@x>\pgf@xc\relax\ifdim\pgf@y>\pgf@yc\relax
\fi\fi
\fi
%
% do northwest corner
\ifpgf@rectanglewrc@donecorner@\else
\northeast\pgf@yc=\pgf@y\relax\southwest\pgf@xc=\pgf@x\relax
\borderpoint
\ifdim\pgf@x<\pgf@xc\relax\ifdim\pgf@y>\pgf@yc\relax
\fi\fi
\fi
}
}

\makeatother

\begin{tikzpicture}
\draw node(rc)[
rectangle with rounded corners,draw=yellow, fill=yellow!10,align=center,rectangle corner radius north west=0pt]
{\large rectangle with rounded corners\\\large rectangle with rounded corners\\\large rectangle with rounded corners};%
\end{tikzpicture}

\end{document}


-
I've added an image with the output from your code. Welcome to TeX.SX! Please, consider registering to the site, so you can contribute more to it. –  egreg Jun 12 '13 at 8:44
Thank you. Now i want to use that as clipping path and it doesnt work, so now I will try to post a question... –  Khaj Jun 12 '13 at 8:56
Cool stuff, Khaj. For integration into TikZ, I suggest to turn this into a tikz library (loadable with \usetikzlibrary). I don't know how the process is to get something into TikZ CVS, but it might be worth a try. Another option is to publish this on the tex.se package site ("From answers to packages"). –  Daniel Jun 12 '13 at 10:50
Doesn't work well, try this and look at the north east corner: \draw node[ rectangle with rounded corners,draw=yellow, fill=yellow!10,align=center,rectangle corner radius south west=0pt, rectangle corner radius south east=0pt](rr) at (0,-4) {\large rectangle with rounded corners\\\large rectangle with rounded corners\\\large rectangle with rounded corners}; –  Álvaro Aug 16 '13 at 14:52