4

I am trying to use the shape "tape" with rounded corners using the following code:

\documentclass[12pt]{scrartcl}

\usepackage{tikz}
\usetikzlibrary{%
    shapes,
    shadows,
}
\tikzset{
    document/.style={
        shape=tape,
        double copy shadow={shadow xshift=1ex, shadow yshift=-0.8ex},
        rounded corners=5pt,
        minimum width=5cm,
        inner ysep=15pt,
        draw, 
        align=center,
        fill=white,
        font=\fontsize{20}{20}\sffamily\bfseries,
        tape bend top=none,
    },
} 
\begin{document}
    \begin{tikzpicture}
        \node[document] (node1) {files};
    \end{tikzpicture}
\end{document}

which gives me this:

enter image description here

any sugestions how to fix the line in the lower right corner?

  • Is a radius of rounded corners=1.5ptenough? Keeping the radius value low enough helps to avoid the overshoot of the curve. – moospit Feb 21 '17 at 15:32
2

We can find the definition of this shape in pgflibraryshapes.symbols.code.tex. What we need to investigate is the background part:

\backgroundpath{%
    \tapedimensions%
    %
    \pgf@xc\halfwidth%
    \pgf@yc\halfheight%    
    %
    \pgf@xc\bendxradius%
    \pgf@yc\bendyradius%    
    {%
      \pgftransformshift{\centerpoint}%
      \pgfpathmoveto{\pgfqpoint{-\halfwidth}{0pt}}%
      \pgfpathlineto{\pgfqpoint{-\halfwidth}{\halfheight}}%
      \ifx\topbendstyle\pgf@lib@sh@inandouttext%
        \pgfpathlineto{\pgf@x-\halfwidth\pgf@y\halfheight\advance\pgf@y\halfbendheight}%
        \pgfpatharc{225}{315}{\bendxradius and \bendyradius}%
        \pgfpatharc{135}{45}{\bendxradius and \bendyradius}%
      \else%
        \ifx\topbendstyle\pgf@lib@sh@outandintext%
          \pgfpathlineto{\pgf@x-\halfwidth\pgf@y\halfheight\advance\pgf@y\halfbendheight}%
          \pgfpatharc{135}{45}{\bendxradius and \bendyradius}%
          \pgfpatharc{225}{315}{\bendxradius and \bendyradius}%
        \else%
          \pgfpathlineto{\pgfqpoint{\halfwidth}{\halfheight}}%
        \fi%
      \fi%
      % ⬇️⬇️⬇️ NOTICE THIS LINE ⬇️⬇️⬇️ (a)
      \pgfpathlineto{\pgfqpoint{\halfwidth}{-\halfheight}}%
      \ifx\bottombendstyle\pgf@lib@sh@inandouttext%
      % ⬇️⬇️⬇️ NOTICE THIS LINE ⬇️⬇️⬇️ (b)
        \pgfpathlineto{\pgf@x\halfwidth\pgf@y-\halfheight\advance\pgf@y-\halfbendheight}%
        \pgfpatharc{45}{135}{\bendxradius and \bendyradius}%
        \pgfpatharc{315}{225}{\bendxradius and \bendyradius}%
      \else%
        \ifx\bottombendstyle\pgf@lib@sh@outandintext%
          \pgfpathlineto{\pgf@x\halfwidth\pgf@y-\halfheight\advance\pgf@y-\halfbendheight}%
          \pgfpatharc{315}{225}{\bendxradius and \bendyradius}%
          \pgfpatharc{45}{135}{\bendxradius and \bendyradius}%
        \else%
      % ⬇️⬇️⬇️ NOTICE THIS LINE ⬇️⬇️⬇️ (c)
          \pgfpathlineto{\pgfqpoint{-\halfwidth}{-\halfheight}}%
        \fi%
      \fi%
      \pgfpathclose%
    }%  
  }

Roughly speaking the drawing goes as follows

  • start from west edge
  • draw straight line to northwest corner
  • draw straight line to northeast corner
  • draw straight line to southeast corner
    • user want curved bottom!!
    • draw short straight line toward south (still at southeast corner)
  • draw curve to southwest corner
  • draw straight line to west, close the path

In terms of 's low level commands, there are two consecutive \pgfpathlineto commands and the second line is very short.

This will confuse the rounded corners mechanism because cannot tell if you are going up or down.

If you can replace these two \pgfpathlinetos by just one, then there will be no problem. For instance, you can move line (a) to (c), and then there will be only one line in any case.

There is an exactly same bug at the northwest corner. To prove my point, move line (d) to line (e) and compile the following MWE


\documentclass[tikz,border=30]{standalone}

\usetikzlibrary{%
    shapes,
    shadows,
}

\makeatletter

\def\pgf@sh@bg@tape{
    \tapedimensions%
    %
    \pgf@xc\halfwidth%
    \pgf@yc\halfheight%    
    %
    \pgf@xc\bendxradius%
    \pgf@yc\bendyradius%    
    {%
      \pgftransformshift{\centerpoint}%
      \pgfpathmoveto{\pgfqpoint{-\halfwidth}{0pt}}%
      % ⬇️⬇️⬇️ NOTICE THIS LINE ⬇️⬇️⬇️ (d)
      \pgfpathlineto{\pgfqpoint{-\halfwidth}{\halfheight}}%
      \ifx\topbendstyle\pgf@lib@sh@inandouttext%
        \pgfpathlineto{\pgf@x-\halfwidth\pgf@y\halfheight\advance\pgf@y\halfbendheight}%
        \pgfpatharc{225}{315}{\bendxradius and \bendyradius}%
        \pgfpatharc{135}{45}{\bendxradius and \bendyradius}%
      \else%
        \ifx\topbendstyle\pgf@lib@sh@outandintext%
          \pgfpathlineto{\pgf@x-\halfwidth\pgf@y\halfheight\advance\pgf@y\halfbendheight}%
          \pgfpatharc{135}{45}{\bendxradius and \bendyradius}%
          \pgfpatharc{225}{315}{\bendxradius and \bendyradius}%
        \else%
      % ⬇️⬇️⬇️ NOTICE THIS LINE ⬇️⬇️⬇️ (e)
          \pgfpathlineto{\pgfqpoint{\halfwidth}{\halfheight}}%
        \fi%
      \fi%
      \ifx\bottombendstyle\pgf@lib@sh@inandouttext%
        \pgfpathlineto{\pgf@x\halfwidth\pgf@y-\halfheight\advance\pgf@y-\halfbendheight}%
        \pgfpatharc{45}{135}{\bendxradius and \bendyradius}%
        \pgfpatharc{315}{225}{\bendxradius and \bendyradius}%
      \else%
        \ifx\bottombendstyle\pgf@lib@sh@outandintext%
          \pgfpathlineto{\pgf@x\halfwidth\pgf@y-\halfheight\advance\pgf@y-\halfbendheight}%
          \pgfpatharc{315}{225}{\bendxradius and \bendyradius}%
          \pgfpatharc{45}{135}{\bendxradius and \bendyradius}%
        \else%
          \pgfpathlineto{\pgfqpoint{\halfwidth}{-\halfheight}}%
          \pgfpathlineto{\pgfqpoint{-\halfwidth}{-\halfheight}}%
        \fi%
      \fi%
      \pgfpathclose%
    }%
}


\tikzset{
    document/.style={
        shape=tape,
        rounded corners=5pt,
        minimum width=5cm,
        inner ysep=15pt,
        draw,
        align=center,
        fill=white,
        font=\fontsize{20}{20}\sffamily\bfseries,
        tape bend top=none,
    }
} 
\begin{document}
    \begin{tikzpicture}
        \node[document] (node1) {files};
    \end{tikzpicture}

    \begin{tikzpicture}
        \node[document,tape bend top=in and out] (node1) {files};
    \end{tikzpicture}
\end{document}

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.