I want to draw this kind of rectangle using tikzpicture environment:

Rectangle with a new line

a could change to b, c, d, etc.

We should also be able to insert a new line.

If MWE is needed please let me know.


  • 1
    I don't really understand what you're trying to do. Are you trying to draw several of these in a single tikzpicture? What does the 'optional' bit mean? Nodes are rectangular by default and they adjust to the width of the text by default, so the only even slight complication seems to be placing the label in the corner. You need to use another node for that. At least, that'd be simplest. – cfr Dec 7 '18 at 1:20
  • @cfr sorry for the inaccuracies. I want to draw the rectangle of the image. By "optional" I mean that the straight line could be drawn or not. Yes, you are right that the text adjust to the width of it by default. The two things are the label and the line. – manooooh Dec 7 '18 at 1:25

There are already folder symbols on the market that do something like this, e.g. here. That is, if you want to define a new shape, there are answers that give you good start. However, if you want to do it the quick and dirty way, you could do

\begin{tikzpicture}[fluffy with corner/.style={draw,inner ysep=3mm,inner
path picture={
\draw ([xshift=3mm]path picture bounding box.north west) 
-- ([yshift=-3mm]path picture bounding box.north west);
\node[anchor=north east,inner sep=2pt] at (path picture bounding box.north east)
{#1};}},fluffy/.style={draw,inner ysep=3mm,inner xsep=3mm,align=center,
path picture={
\node[anchor=north east,inner sep=2pt] at (path picture bounding box.north east) {#1};}}]
\node[fluffy=b] at (0,0){text here}; 
\node[fluffy with corner=a] at (4,0){text here\\ second line\\ third line};

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.