0

I need to draw a rectangle with only one round edge like following image.

enter image description here

In this case its south-west corner that is round. I looked up n saw this post

Draw a rectangle with rounded ends in TikZ

but i got error when I did

\node (1) [draw, draw, rounded rectangle, rounded rectangle north east arc=0pt] {rounded rectangle}

which is modified version of (Answer 1: Line 11)

\node (2) [draw, rounded rectangle, rounded rectangle west arc=0pt] {rounded rectangle};

4
\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw[sharp corners] (0,0) -- (0,1) -- (1,1)   -- (1,0) [rounded corners] -- cycle;
\end{tikzpicture}
\end{document}
  • this looks good but I find specifying a rectangle by coordinates a bit cumbersome. – NAASI Feb 15 '18 at 19:54
7

as node with such shape:

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

    \begin{document}
\begin{tikzpicture}[
oneroundedge/.style = {%
    minimum width=#1,
    minimum height=12mm, text depth=0.25ex,
    outer sep=0pt,
    append after command={
        \pgfextra{\let\LN\tikzlastnode
    \path[draw, fill=gray!30] (\LN.south west) -| (\LN.north east)
        -- (\LN.north west) [rounded corners=3mm] -- cycle;
                       }     },
        font=\bfseries}
                    ]
\node (n1) [oneroundedge=12mm] {};
\node (n2) [oneroundedge=22mm, right=of n1] {text};
\end{tikzpicture}
    \end{document}

enter image description here

it is easy to add more options to oneroundedge style definition (for example for fill). solution with node enable all possibilities of nodes placement, anchoring etc. note: anchor south west is at south west corner of rectangle which underlay define oneroundedge shape.

2

if you do not need it filled it is possible with simple LaTeX commands:

\documentclass{article}
\unitlength=1cm \thicklines
\begin{document}

\begin{picture}(8,4)
\put(8,4){\oval(16,8)[lb]}
\put(0,4){\line(1,0){8}}\put(8,0){\line(0,1){4}}
\end{picture}

\end{document}

enter image description here

1

I saw many accepted answers and decided to give you a solution:

\documentclass{article} 
\usepackage{tikz}

    \begin{document}

          \begin{tikzpicture}
            \draw[black,fill=gray] (0,0)--(3,0)--(3,-2)--(0.2,-2) to[in=270,out=180] (0,-1.8)--cycle;
          \end{tikzpicture}

    \end{document}

It is a manual solution using the command "to" that I think is a useful command. I am sure there are better solution (So, don't accept it yet)

1

A variation on samcarter's answer, without explicit coordinates of the path:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \node[minimum width=1.5cm, minimum height=1cm] (a) {};
    \draw[fill=black] (a.south west) -- (a.north west) -- (a.north east) -- (a.south east) [rounded corners=10pt] -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.