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};

NAASI
  • 2,809
  • 1
    minimal working example (MWE)? The question you linked to has 5 answers and you don't even tell us which one you tried nor how you modified it. – samcarter_is_at_topanswers.xyz Feb 15 '18 at 18:04
  • 2
    While you wait for an answer to this question, can you go back to your previous ones and look if the answers solve your problems and accept them, if they do? – samcarter_is_at_topanswers.xyz Feb 15 '18 at 18:07
  • 1
    Can you please check if the answers to https://tex.stackexchange.com/q/297639/36296, https://tex.stackexchange.com/q/297385/36296, https://tex.stackexchange.com/q/297230/36296, https://tex.stackexchange.com/q/297167/36296, https://tex.stackexchange.com/q/262259/36296, https://tex.stackexchange.com/q/262256/36296, https://tex.stackexchange.com/q/262156/36296, https://tex.stackexchange.com/q/262071/36296, https://tex.stackexchange.com/q/255314/36296 solve your problem and accept them if they do? – samcarter_is_at_topanswers.xyz Feb 15 '18 at 20:48

5 Answers5

6

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.

Zarko
  • 296,517
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}
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

2

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

CarLaTeX
  • 62,716
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)

koleygr
  • 20,105